Page MenuHomeFreeBSD

linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump()
ClosedPublic

Authored by dumbbell on Jul 26 2025, 3:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 28, 2:41 AM
Unknown Object (File)
Sat, Dec 13, 3:56 AM
Unknown Object (File)
Nov 26 2025, 12:47 PM
Unknown Object (File)
Nov 25 2025, 4:57 AM
Unknown Object (File)
Nov 24 2025, 10:30 PM
Unknown Object (File)
Nov 22 2025, 1:27 AM
Unknown Object (File)
Nov 10 2025, 10:47 PM
Unknown Object (File)
Nov 9 2025, 5:29 AM
Subscribers

Details

Summary

We use the return value of the callback to track the number of bytes written. We use it to determine if a group of characters should be prepended with a whitespace. This way, we never add a trailing whitespace.

We need to pay attention to the return value of the callback: if it is negative, it's an error and we return immediately. Otherwise, we would decrease the number of written bytes and possibly make it negative.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested changes to this revision.Jul 30 2025, 9:18 AM
bz added a subscriber: bz.

As pointed out in the other review; the callback functions can return negative values; you need to catch those and make sure you do not go negative or backwards.

This revision now requires changes to proceed.Jul 30 2025, 9:18 AM

Handle negative return value from callback.

@bz: Do you have any remaining objections to this patch?

I don't think so; I thought I had approved it a few days ago.

This revision is now accepted and ready to land.Thu, Dec 18, 10:01 PM