[CRIU] [crtools-bot] hex_dump: Convert argument to long
Kir Kolyshkin
kir at openvz.org
Tue Jan 31 08:08:27 EST 2012
On 01/31/2012 04:54 PM, Cyrill Gorcunov wrote:
> The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
> ------>
> commit a9ba9732c984d464f4500d6a69e41dad53b3640f
> Author: Cyrill Gorcunov<gorcunov at openvz.org>
> Date: Tue Jan 31 16:52:17 2012 +0400
>
> hex_dump: Convert argument to long
>
> To eliminate format problem
>
> | util.c:60:10: error: format ‘%lx’ expects argument of
> | type ‘long unsigned int’, but argument 2 has type
> | ‘unsigned char *’ [-Werror=format]
>
> Signed-off-by: Cyrill Gorcunov<gorcunov at openvz.org>
> ---
> util.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/util.c b/util.c
> index 5ee6e50..72252b6 100644
> --- a/util.c
> +++ b/util.c
> @@ -56,7 +56,7 @@ void hex_dump(void *addr, unsigned long len)
>
> for (i = 0; i< len; i += 8) {
> printk("%08lx: %02x %02x %02x %02x %02x %02x %02x %02x\n",
Actually 8 characters are not enough for 64-bit address in hex, so
specifying width doesn't make sense here.
> - p, p[i+0], p[i+1], p[i+2], p[i+3],
> + (long)p, p[i+0], p[i+1], p[i+2], p[i+3],
You are (and were) printing the same address on every line.
> p[i+4], p[i+5], p[i+6], p[i+7]);
> }
> }
Below is the fix to both problems.
---
From b86f7cf3dc6cf01721393f45e0b3472467d0426e Mon Sep 17 00:00:00 2001
From: Kir Kolyshkin<kir at openvz.org>
Date: Tue, 31 Jan 2012 17:01:37 +0400
Subject: [PATCH] hex_dump(): fix address printing
(1) Fix printing the same address on every line (ie p+i, not p).
(2) Use GNU %p to print pointer, to avoid messing with width etc.
Side effect: 0x is added, hope that's ok.
Signed-off-by: Kir Kolyshkin<kir at openvz.org>
---
util.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/util.c b/util.c
index 72252b6..2cd16c0 100644
--- a/util.c
+++ b/util.c
@@ -55,8 +55,8 @@ void hex_dump(void *addr, unsigned long len)
len = (len + 8)& ~7;
for (i = 0; i< len; i += 8) {
- printk("%08lx: %02x %02x %02x %02x %02x %02x %02x %02x\n",
- (long)p, p[i+0], p[i+1], p[i+2], p[i+3],
+ printk("%p: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ &p[i], p[i+0], p[i+1], p[i+2], p[i+3],
p[i+4], p[i+5], p[i+6], p[i+7]);
}
}
--
1.7.4.4
More information about the CRIU
mailing list