]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: convert a variable type according with fmt
authorAndrew Vagin <avagin@openvz.org>
Fri, 27 Dec 2013 13:45:57 +0000 (17:45 +0400)
committerKarel Zak <kzak@redhat.com>
Mon, 6 Jan 2014 13:02:21 +0000 (14:02 +0100)
hexdump works uncorrectly on Rassberry Pi (raspbian wheezy):
0000000 3200000000 3400000000 3600000000 3800000000 a00000000
000000a

The problem is that the %qx format is used for printing
the (short int) variable.

Here is the output from hexdump with this patch:
0000000 3231 3433 3635 3837 0a39
000000a

Currently raspbian uses hexdump from bsdmainutils.
bsdmainutils: /usr/bin/hexdump

Signed-off-by: Andrew Vagin <avagin@openvz.org>
text-utils/hexdump-display.c

index 67f426df81ea112be9ebbe46b5c0c524aa935a36..b195a01ae47d6858b6b6aac6d897f16d2c444b4c 100644 (file)
@@ -93,15 +93,15 @@ print(struct hexdump_pr *pr, unsigned char *bp) {
 
                switch(pr->bcnt) {
                case 1:
-                       printf(pr->fmt, *bp);
+                       printf(pr->fmt, (unsigned long long) *bp);
                        break;
                case 2:
                        memmove(&sval, bp, sizeof(sval));
-                       printf(pr->fmt, sval);
+                       printf(pr->fmt, (unsigned long long) sval);
                        break;
                case 4:
                        memmove(&ival, bp, sizeof(ival));
-                       printf(pr->fmt, ival);
+                       printf(pr->fmt, (unsigned long long) ival);
                        break;
                case 8:
                        memmove(&Lval, bp, sizeof(Lval));
@@ -130,15 +130,15 @@ print(struct hexdump_pr *pr, unsigned char *bp) {
 
                switch(pr->bcnt) {
                case 1:
-                       printf(pr->fmt, *bp);
+                       printf(pr->fmt, (unsigned long long) *bp);
                        break;
                case 2:
                        memmove(&sval, bp, sizeof(sval));
-                       printf(pr->fmt, sval);
+                       printf(pr->fmt, (unsigned long long) sval);
                        break;
                case 4:
                        memmove(&ival, bp, sizeof(ival));
-                       printf(pr->fmt, ival);
+                       printf(pr->fmt, (unsigned long long) ival);
                        break;
                case 8:
                        memmove(&Lval, bp, sizeof(Lval));