]> granicus.if.org Git - strace/commitdiff
util.c: introduce printaddr64
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 21 Feb 2018 22:15:54 +0000 (23:15 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)
Sometimes, 64-bit value is expected to be interpreted as an address
(in BTRFS ioctl interface, for example).

* defs.h (printaddr64): New declaration.
* util.c (printaddr64): Rename from printaddr, change argument type
to uint64_t.
(printaddr): Turn into a thin wrapper around printaddr64.
(printnum_addr_int, printnum_addr_int64): Use printaddr64 instead of
printaddr.  printnum_addr_int64 is not used outside the cases where
kernel_long is less or equal than 64 bit currently, so this change
should be safe.

defs.h
util.c

diff --git a/defs.h b/defs.h
index 17f3b4887d40a7d96d79dae66488d5950be27663..69932dfbc96d22fba70a46d12e9df7ff37a7a8dc 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -556,6 +556,7 @@ extern int getllval(struct tcb *, unsigned long long *, int);
 extern int printllval(struct tcb *, const char *, int)
        ATTRIBUTE_FORMAT((printf, 2, 0));
 
+extern void printaddr64(uint64_t addr);
 extern void printaddr(kernel_ulong_t addr);
 extern int printxvals(const uint64_t, const char *, const struct xlat *, ...)
        ATTRIBUTE_SENTINEL;
diff --git a/util.c b/util.c
index 38458658b45b8404a140ef6e2fcb8117b7b77519..281242767f75126473814bdd6253bb71dceb71d6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -228,12 +228,18 @@ printllval(struct tcb *tcp, const char *format, int arg_no)
 }
 
 void
-printaddr(const kernel_ulong_t addr)
+printaddr64(const uint64_t addr)
 {
        if (!addr)
                tprints("NULL");
        else
-               tprintf("%#" PRI_klx, addr);
+               tprintf("%#" PRIx64, addr);
+}
+
+void
+printaddr(const kernel_ulong_t addr)
+{
+       printaddr64(addr);
 }
 
 #define DEF_PRINTNUM(name, type) \
@@ -258,7 +264,7 @@ printnum_addr_ ## name(struct tcb *tcp, const kernel_ulong_t addr)  \
        if (umove_or_printaddr(tcp, addr, &num))                        \
                return false;                                           \
        tprints("[");                                                   \
-       printaddr(num);                                                 \
+       printaddr64(num);                                               \
        tprints("]");                                                   \
        return true;                                                    \
 }