Re: [PATCH 1/3] hexdump: more output formatting

From: Jesper Juhl
Date: Wed May 30 2007 - 18:36:25 EST


On 30/05/07, Randy Dunlap <randy.dunlap@xxxxxxxxxx> wrote:
From: Randy Dunlap <randy.dunlap@xxxxxxxxxx>


Some friendly nitpicking below :-)

Add a prefix string parameter. Callers are responsible for any
string length/alignment that they want to see in the output. I.e.,
callers should pad strings to achieve alignment if they want that.

Add rowsize parameter. This is the number of raw data bytes
to be printed per line. Must be 16 or 32.

Add a group_size parameter. This allows callers to dump values

One is called "rowsize" the other "group_size". How about consistent
naming; either "row_size" and "group_size" or "rowsize" and
"groupsize" ?

as 1-byte, 2-byte, 4-byte, or 8-byte numbers. Default is
1-byte numbers. If the total length is not an even multiple
of group_size, 1-byte numbers are printed.

Add an "ascii" output parameter. This causes ASCII data output
following the hex data output.

Clean up some doc examples.

Signed-off-by: Randy Dunlap <randy.dunlap@xxxxxxxxxx>
---
[snip]
+
+ switch (group_size) {
+ case 8: {
+ const u64 *ptr8 = buf;
+ int ngroups = len / group_size;
+
+ for (j = 0; j < ngroups; j++)
+ lx += scnprintf(linebuf + lx, linebuflen - lx,
+ "%16.16llx ", (unsigned long long)*(ptr8 + j));
+ break;
+ }
+

I don't see the point in this (and the other) extra blank lines
between closing brace of one case and the start of the next. Removing
the blank line wouldn't hurt readability but would allow more lines of
code to be visible on the screen at once.

+ case 4: {

[snip]


Apart from those nits, nice patch, nice improvement.


--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/