2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-02 15:25:22 +00:00

util: Avoid trailing white space in hex dumps.

ovs_hex_dump() sometimes yields a trailing space in its output.  This is
annoying for the test infrastructure, since we have to specially mark the
trailing white space in Autotest with a "@&t@" marker at the end of the
line.  This commit gets rid of the trailing white space and the annoying
"@&t@" markers.

This also gets rid of an occasional trailing hyphen.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
This commit is contained in:
Ben Pfaff
2017-09-14 17:00:38 -07:00
parent e51d0a1d5a
commit 327a39b6ec
4 changed files with 45 additions and 44 deletions

View File

@@ -658,14 +658,15 @@ ovs_hex_dump(FILE *stream, const void *buf_, size_t size,
n = end - start;
/* Print line. */
fprintf(stream, "%08"PRIxMAX" ", (uintmax_t) ROUND_DOWN(ofs, per_line));
fprintf(stream, "%08"PRIxMAX" ", (uintmax_t) ROUND_DOWN(ofs, per_line));
for (i = 0; i < start; i++)
fprintf(stream, " ");
for (; i < end; i++)
fprintf(stream, "%02x%c",
buf[i - start], i == per_line / 2 - 1? '-' : ' ');
fprintf(stream, "%c%02x",
i == per_line / 2 ? '-' : ' ', buf[i - start]);
if (ascii)
{
fprintf(stream, " ");
for (; i < per_line; i++)
fprintf(stream, " ");
fprintf(stream, "|");