* [PATCH] dmesg: print only 2 hex digits for each hex-escaped byte
@ 2017-06-21 23:43 Ivan Delalande
2017-06-22 8:46 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Delalande @ 2017-06-21 23:43 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
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>
---
sys-utils/dmesg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
}
--
2.13.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmesg: print only 2 hex digits for each hex-escaped byte
2017-06-21 23:43 [PATCH] dmesg: print only 2 hex digits for each hex-escaped byte Ivan Delalande
@ 2017-06-22 8:46 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2017-06-22 8:46 UTC (permalink / raw)
To: Ivan Delalande; +Cc: util-linux
On Wed, Jun 21, 2017 at 04:43:05PM -0700, Ivan Delalande wrote:
> sys-utils/dmesg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-22 8:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21 23:43 [PATCH] dmesg: print only 2 hex digits for each hex-escaped byte Ivan Delalande
2017-06-22 8:46 ` Karel Zak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.