diff options
author | Ivan Delalande | 2017-06-22 01:43:05 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-22 10:44:35 +0200 |
commit | 2e45524d969440501c83af3c39d5cab41c573e2f (patch) | |
tree | 004ba2c9d89ba3688200369d0b57ae30bed5e8ee /sys-utils/dmesg.c | |
parent | build-sys: update DISTCHECK_CONFIGURE_FLAGS (diff) | |
download | kernel-qcow2-util-linux-2e45524d969440501c83af3c39d5cab41c573e2f.tar.gz kernel-qcow2-util-linux-2e45524d969440501c83af3c39d5cab41c573e2f.tar.xz kernel-qcow2-util-linux-2e45524d969440501c83af3c39d5cab41c573e2f.zip |
dmesg: print only 2 hex digits for each hex-escaped byte
As buf is passed as a signed char buffer in fwrite_hex, fprintf will
print every byte from 0x80 as a signed-extended int causing each of
these bytes to be printed as "\xffffff80" and such, which can be pretty
confusing. Force fprintf to use the argument as a char to make it print
only 2 digits, e.g. "\x80".
Signed-off-by: Ivan Delalande <colona@arista.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r-- | sys-utils/dmesg.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index b83cfb1bb..821d8bbb2 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -613,7 +613,7 @@ static int fwrite_hex(const char *buf, size_t size, FILE *out) size_t i; for (i = 0; i < size; i++) { - int rc = fprintf(out, "\\x%02x", buf[i]); + int rc = fprintf(out, "\\x%02hhx", buf[i]); if (rc < 0) return rc; } |