public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrey Vagin <avagin@openvz.org>
To: util-linux@vger.kernel.org
Cc: Karel Zak <kzak@redhat.com>, Andrew Vagin <avagin@openvz.org>
Subject: [PATCH] hexdump: convert a variable type according with fmt
Date: Fri, 27 Dec 2013 17:45:57 +0400	[thread overview]
Message-ID: <1388151957-9209-1-git-send-email-avagin@openvz.org> (raw)

From: Andrew Vagin <avagin@openvz.org>

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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/text-utils/hexdump-display.c b/text-utils/hexdump-display.c
index 67f426d..b195a01 100644
--- a/text-utils/hexdump-display.c
+++ b/text-utils/hexdump-display.c
@@ -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));
-- 
1.8.4.2


             reply	other threads:[~2013-12-27 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-27 13:45 Andrey Vagin [this message]
2014-01-06 13:03 ` [PATCH] hexdump: convert a variable type according with fmt Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388151957-9209-1-git-send-email-avagin@openvz.org \
    --to=avagin@openvz.org \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox