Page MenuHomeFreeBSD

linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump()
Needs ReviewPublic

Authored by dumbbell on Jul 26 2025, 3:51 PM.
Tags
None
Referenced Files
F135572067: D51558.id159187.diff
Mon, Nov 10, 10:47 PM
Unknown Object (File)
Sun, Nov 9, 5:29 AM
Unknown Object (File)
Fri, Nov 7, 11:59 AM
Unknown Object (File)
Sat, Nov 1, 1:38 AM
Unknown Object (File)
Tue, Oct 28, 2:18 PM
Unknown Object (File)
Mon, Oct 27, 11:15 AM
Unknown Object (File)
Mon, Oct 27, 7:38 AM
Unknown Object (File)
Fri, Oct 24, 10:20 PM
Subscribers

Details

Reviewers
bz
Group Reviewers
linuxkpi
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 Skipped
Unit
Tests Skipped

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.