Skip to content

Commit b4334a4

Browse files
Nick ChildNipaLocal
authored andcommitted
hexdump: Use for_each macro in print_hex_dump
The looping logic in print_hex_dump can be handled by the macro for_each_line_in_hex_dump. Signed-off-by: Nick Child <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 17c5f79 commit b4334a4

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/hexdump.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,14 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
263263
const void *buf, size_t len, bool ascii)
264264
{
265265
const u8 *ptr = buf;
266-
int i, linelen, remaining = len;
266+
int i;
267267
unsigned char linebuf[32 * 3 + 2 + 32 + 1];
268268

269269
if (rowsize != 16 && rowsize != 32)
270270
rowsize = 16;
271271

272-
for (i = 0; i < len; i += rowsize) {
273-
linelen = min(remaining, rowsize);
274-
remaining -= rowsize;
275-
276-
hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
277-
linebuf, sizeof(linebuf), ascii);
278-
272+
for_each_line_in_hex_dump(i, rowsize, linebuf, sizeof(linebuf),
273+
groupsize, buf, len) {
279274
switch (prefix_type) {
280275
case DUMP_PREFIX_ADDRESS:
281276
printk("%s%s%p: %s\n",

0 commit comments

Comments
 (0)