Re: [PATCH 1/3] hexdump: Implement macro for converting large buffers

From: David Laight
Date: Sun Feb 16 2025 - 06:24:43 EST


On Sun, 16 Feb 2025 09:32:04 +0000
Simon Horman <horms@xxxxxxxxxx> wrote:

>...
> > > Yep, that should fail for all versions of gcc.
> > > Both 'i' and 'rowsize' should be unsigned types.
> > > In fact all three can be 'unsigned int'.
>
> To give a bit more context, a complication changing the types is that the
> type of len and rowsise (but not i) is in the signature of the calling
> function, print_hex_dump(). And I believe that function is widely used
> throughout the tree.

Doesn't matter, nothing with assign the address of the function to a
variable so changing the types (to unsigned) doesn't affect any callers.
The values better be positive!

I just changed the prototypes (include/linux/printk.h) to make both
rowsize and groupsize 'unsigned int'.
The same change in lib/hexdump.c + changing the local 'i, linelen, remaining'
to unsigned int and it all compiled.

FWIW that hexdump code is pretty horrid (especially if groupsize != 1).

David