]> granicus.if.org Git - strace/commitdiff
Use kernel_ulong_t instead of unsigned long long where appropriate
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Dec 2016 16:56:45 +0000 (16:56 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Dec 2016 19:58:16 +0000 (19:58 +0000)
* defs.h (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t.  All callers updated.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t.  All callers updated.
(PRI_kl, PRI_kld, PRI_klu, PRI_klx): New macros.
* bjm.c (SYS_FUNC(init_module)): Print kernel_ulong_t type using
PRI_klu format.
* desc.c (SYS_FUNC(pselect6)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Print kernel_ulong_t type using
PRI_klx format.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Print kernel_ulong_t type using PRI_kld, PRI_klu, or PRI_klx format.
* util.c (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.

12 files changed:
bjm.c
clone.c
defs.h
desc.c
fadvise.c
kcmp.c
keyctl.c
lookup_dcookie.c
mq.c
pkeys.c
prctl.c
util.c

diff --git a/bjm.c b/bjm.c
index 054f110b25cb5ce63e4df8c84fbe27a2fddc42e5..6adbb6fa8800e8ac8c9016da89dac1d33c078ffe 100644 (file)
--- a/bjm.c
+++ b/bjm.c
@@ -44,8 +44,8 @@ SYS_FUNC(delete_module)
 
 SYS_FUNC(init_module)
 {
-       printaddr_ull(getarg_ull(tcp, 0));
-       tprintf(", %llu, ", getarg_ull(tcp, 1));
+       printaddr_klu(getarg_klu(tcp, 0));
+       tprintf(", %" PRI_klu ", ", getarg_klu(tcp, 1));
        printstr(tcp, tcp->u_arg[2], -1);
 
        return RVAL_DECODED;
diff --git a/clone.c b/clone.c
index 0f2d32c2f6938c5accc5438fcd6f82da40b49930..075bb75c53f3319516e044139f87934e0840faaf 100644 (file)
--- a/clone.c
+++ b/clone.c
@@ -153,7 +153,7 @@ SYS_FUNC(setns)
 
 SYS_FUNC(unshare)
 {
-       printflags64(unshare_flags, getarg_ull(tcp, 0), "CLONE_???");
+       printflags64(unshare_flags, getarg_klu(tcp, 0), "CLONE_???");
        return RVAL_DECODED;
 }
 
diff --git a/defs.h b/defs.h
index 758f2e707142765b78f0825e4e538716ed9ac7dc..acd9115a5199e8012cd5f462e9d7aa36edc63bff 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -571,14 +571,14 @@ extern int getllval(struct tcb *, unsigned long long *, int);
 extern int printllval(struct tcb *, const char *, int)
        ATTRIBUTE_FORMAT((printf, 2, 0));
 
-extern void printaddr_ull(unsigned long long);
+extern void printaddr_klu(kernel_ulong_t addr);
 extern int printxvals(const uint64_t, const char *, const struct xlat *, ...)
        ATTRIBUTE_SENTINEL;
 extern int printxval_searchn(const struct xlat *xlat, size_t xlat_size,
        uint64_t val, const char *dflt);
 #define printxval_search(xlat__, val__, dflt__) \
        printxval_searchn(xlat__, ARRAY_SIZE(xlat__), val__, dflt__)
-extern unsigned long long getarg_ull(struct tcb *tcp, int argn);
+extern kernel_ulong_t getarg_klu(struct tcb *tcp, int argn);
 extern int printargs(struct tcb *);
 extern int printargs_u(struct tcb *);
 extern int printargs_d(struct tcb *);
@@ -709,7 +709,7 @@ extern void unwind_capture_stacktrace(struct tcb* tcp);
 static inline void
 printaddr(unsigned long addr)
 {
-       printaddr_ull(addr);
+       printaddr_klu(addr);
 }
 
 static inline void
@@ -913,6 +913,16 @@ scno_is_valid(kernel_scno_t scno)
 
 #define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(sys_ ## syscall_name)(struct tcb *tcp)
 
+#if SIZEOF_KERNEL_LONG_T > SIZEOF_LONG
+# define PRI_kl "ll"
+#else
+# define PRI_kl "l"
+#endif
+
+#define PRI_kld PRI_kl"d"
+#define PRI_klu PRI_kl"u"
+#define PRI_klx PRI_kl"x"
+
 /*
  * The kernel used to define 64-bit types on 64-bit systems on a per-arch
  * basis.  Some architectures would use unsigned long and others would use
diff --git a/desc.c b/desc.c
index dc47a7f0aeac9e1d17f77f1459ff55f969150d22..4183c778a8b5e2761f6bfbcb104be3529a7678af 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -261,7 +261,7 @@ SYS_FUNC(pselect6)
                        /* NB: kernel requires data[1] == NSIG / 8 */
                        print_sigset_addr_len(tcp, (unsigned long) data[0],
                                              (unsigned long) data[1]);
-                       tprintf(", %llu}", (unsigned long long) data[1]);
+                       tprintf(", %" PRI_klu "}", data[1]);
                }
        }
 
index 34933f77fcb4e1e741f26a662f7945062e2317d4..909da5def99f577180180af9d629b6a490e2b676 100644 (file)
--- a/fadvise.c
+++ b/fadvise.c
@@ -42,7 +42,7 @@ SYS_FUNC(fadvise64)
 
        printfd(tcp, tcp->u_arg[0]);
        argn = printllval(tcp, ", %lld", 1);
-       tprintf(", %llu, ", getarg_ull(tcp, argn++));
+       tprintf(", %" PRI_klu ", ", getarg_klu(tcp, argn++));
        printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
 
        return RVAL_DECODED;
diff --git a/kcmp.c b/kcmp.c
index 4668b48f11d44e951372eb19c5420015223414ed..8b5bd708be449567f5078fca97f0bbe657507644 100644 (file)
--- a/kcmp.c
+++ b/kcmp.c
@@ -33,8 +33,8 @@ SYS_FUNC(kcmp)
        pid_t pid1 = tcp->u_arg[0];
        pid_t pid2 = tcp->u_arg[1];
        int type = tcp->u_arg[2];
-       unsigned long long idx1 = getarg_ull(tcp, 3);
-       unsigned long long idx2 = getarg_ull(tcp, 4);
+       kernel_ulong_t idx1 = getarg_klu(tcp, 3);
+       kernel_ulong_t idx2 = getarg_klu(tcp, 4);
 
        tprintf("%d, %d, ", pid1, pid2);
        printxval(kcmp_types, type, "KCMP_???");
@@ -51,7 +51,7 @@ SYS_FUNC(kcmp)
                case KCMP_VM:
                        break;
                default:
-                       tprintf(", %#llx, %#llx", idx1, idx2);
+                       tprintf(", %#" PRI_klx ", %#" PRI_klx, idx1, idx2);
        }
 
        return RVAL_DECODED;
index 94c297655974ab325dda44a5096ebc30ec0ee8e9..edf59e59c7b85f076314bb2cdc0b942140cddf48 100644 (file)
--- a/keyctl.c
+++ b/keyctl.c
@@ -268,10 +268,10 @@ keyctl_dh_compute(struct tcb *tcp, kernel_ulong_t params, kernel_ulong_t buf,
 SYS_FUNC(keyctl)
 {
        int cmd = tcp->u_arg[0];
-       unsigned long long arg2 = getarg_ull(tcp, 1);
-       unsigned long long arg3 = getarg_ull(tcp, 2);
-       unsigned long long arg4 = getarg_ull(tcp, 3);
-       unsigned long long arg5 = getarg_ull(tcp, 4);
+       kernel_ulong_t arg2 = getarg_klu(tcp, 1);
+       kernel_ulong_t arg3 = getarg_klu(tcp, 2);
+       kernel_ulong_t arg4 = getarg_klu(tcp, 3);
+       kernel_ulong_t arg5 = getarg_klu(tcp, 4);
 
        if (entering(tcp)) {
                printxval(keyctl_commands, cmd, "KEYCTL_???");
@@ -363,7 +363,9 @@ SYS_FUNC(keyctl)
                return 0;
 
        default:
-               tprintf("%#llx, %#llx, %#llx, %#llx", arg2, arg3, arg4, arg5);
+               tprintf("%#" PRI_klx ", %#" PRI_klx
+                       ", %#" PRI_klx ", %#" PRI_klx,
+                       arg2, arg3, arg4, arg5);
                break;
        }
 
index a58214a116bd77e07aa818477b23d227c5aa77f4..13f4370fcefede8fac875957f08a2fcac21d50a4 100644 (file)
@@ -43,7 +43,7 @@ SYS_FUNC(lookup_dcookie)
                printstr(tcp, tcp->u_arg[argn], tcp->u_rval);
 
        /* len */
-       tprintf(", %llu", getarg_ull(tcp, argn + 1));
+       tprintf(", %" PRI_klu, getarg_klu(tcp, argn + 1));
 
        return 0;
 }
diff --git a/mq.c b/mq.c
index 1970f930d699e79399733e6a8ac43882878c3b81..c1d47ab1125053e972e3b4c6c1f25c04d684e58f 100644 (file)
--- a/mq.c
+++ b/mq.c
@@ -49,7 +49,7 @@ SYS_FUNC(mq_timedsend)
 {
        tprintf("%d, ", (int) tcp->u_arg[0]);
        printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
-       tprintf(", %llu, %u, ", getarg_ull(tcp, 2),
+       tprintf(", %" PRI_klu ", %u, ", getarg_klu(tcp, 2),
                (unsigned int) tcp->u_arg[3]);
        print_timespec(tcp, tcp->u_arg[4]);
        return RVAL_DECODED;
@@ -64,7 +64,7 @@ SYS_FUNC(mq_timedreceive)
                        printstr(tcp, tcp->u_arg[1], tcp->u_rval);
                else
                        printaddr(tcp->u_arg[1]);
-               tprintf(", %llu, ", getarg_ull(tcp, 2));
+               tprintf(", %" PRI_klu ", ", getarg_klu(tcp, 2));
                printnum_int(tcp, tcp->u_arg[3], "%u");
                tprintf(", ");
                /*
diff --git a/pkeys.c b/pkeys.c
index 5b4e116889e1601ebdc45f5b9c3897c442bcd7a7..91be9158e46b87907237f9c1ee4fdb3c67727657 100644 (file)
--- a/pkeys.c
+++ b/pkeys.c
@@ -4,8 +4,8 @@
 
 SYS_FUNC(pkey_alloc)
 {
-       tprintf("%#llx, ", getarg_ull(tcp, 0));
-       printflags64(pkey_access, getarg_ull(tcp, 1), "PKEY_???");
+       tprintf("%#" PRI_klx ", ", getarg_klu(tcp, 0));
+       printflags64(pkey_access, getarg_klu(tcp, 1), "PKEY_???");
 
        return RVAL_DECODED;
 }
diff --git a/prctl.c b/prctl.c
index bc15df810e6f7671646e370a0478e3137e984c2e..a2abfb793d51b7ecd526d3e9943c20baab9af0ff 100644 (file)
--- a/prctl.c
+++ b/prctl.c
@@ -70,21 +70,21 @@ print_prctl_args(struct tcb *tcp, const unsigned int first)
        unsigned int i;
 
        for (i = first; i < tcp->s_ent->nargs; ++i)
-               tprintf(", %#llx", getarg_ull(tcp, i));
+               tprintf(", %#" PRI_klx, getarg_klu(tcp, i));
 }
 
 SYS_FUNC(prctl)
 {
        const unsigned int option = tcp->u_arg[0];
-       const unsigned long long arg2 = getarg_ull(tcp, 1);
-       const unsigned long long arg3 = getarg_ull(tcp, 2);
+       const kernel_ulong_t arg2 = getarg_klu(tcp, 1);
+       const kernel_ulong_t arg3 = getarg_klu(tcp, 2);
        /*
         * PR_SET_VMA is the only command which actually uses these arguments
         * currently, and it is available only on Android for now.
         */
 #ifdef __ANDROID__
-       const unsigned long long arg4 = getarg_ull(tcp, 3);
-       const unsigned long long arg5 = getarg_ull(tcp, 4);
+       const kernel_ulong_t arg4 = getarg_klu(tcp, 3);
+       const kernel_ulong_t arg5 = getarg_klu(tcp, 4);
 #endif
        unsigned int i;
 
@@ -194,7 +194,7 @@ SYS_FUNC(prctl)
        case PR_SET_FPEXC:
        case PR_SET_KEEPCAPS:
        case PR_SET_TIMING:
-               tprintf(", %llu", arg2);
+               tprintf(", %" PRI_klu, arg2);
                return RVAL_DECODED;
 
        case PR_SET_DUMPABLE:
@@ -234,7 +234,7 @@ SYS_FUNC(prctl)
                        printxval64(pr_mce_kill_policy, arg3,
                                    "PR_MCE_KILL_???");
                else
-                       tprintf("%#llx", arg3);
+                       tprintf("%#" PRI_klx, arg3);
                print_prctl_args(tcp, 3);
                return RVAL_DECODED;
 
@@ -250,8 +250,8 @@ SYS_FUNC(prctl)
 # endif
        case PR_SET_VMA:
                if (arg2 == PR_SET_VMA_ANON_NAME) {
-                       tprintf(", PR_SET_VMA_ANON_NAME, %#llx", arg3);
-                       tprintf(", %llu, ", arg4);
+                       tprintf(", PR_SET_VMA_ANON_NAME, %#" PRI_klx, arg3);
+                       tprintf(", %" PRI_klu ", ", arg4);
                        printstr(tcp, arg5, -1);
                } else {
                        /* There are no other sub-options now, but there
@@ -270,7 +270,7 @@ SYS_FUNC(prctl)
        case PR_SET_PDEATHSIG:
                tprints(", ");
                if (arg2 > 128)
-                       tprintf("%llu", arg2);
+                       tprintf("%" PRI_klu, arg2);
                else
                        tprints(signame(arg2));
                return RVAL_DECODED;
@@ -280,7 +280,7 @@ SYS_FUNC(prctl)
                if ((int) arg2 == -1)
                        tprints("PR_SET_PTRACER_ANY");
                else
-                       tprintf("%llu", arg2);
+                       tprintf("%" PRI_klu, arg2);
                return RVAL_DECODED;
 
        case PR_SET_SECCOMP:
@@ -303,7 +303,7 @@ SYS_FUNC(prctl)
                return RVAL_DECODED;
 
        case PR_SET_TIMERSLACK:
-               tprintf(", %lld", arg2);
+               tprintf(", %" PRI_kld, arg2);
                return RVAL_DECODED;
 
        case PR_SET_TSC:
@@ -318,7 +318,7 @@ SYS_FUNC(prctl)
 
        case PR_SET_NO_NEW_PRIVS:
        case PR_SET_THP_DISABLE:
-               tprintf(", %llu", arg2);
+               tprintf(", %" PRI_klu, arg2);
                print_prctl_args(tcp, 2);
                return RVAL_DECODED;
 
@@ -356,7 +356,7 @@ SYS_FUNC(prctl)
 SYS_FUNC(arch_prctl)
 {
        const unsigned int option = tcp->u_arg[0];
-       const unsigned long long addr = getarg_ull(tcp, 1);
+       const kernel_ulong_t addr = getarg_klu(tcp, 1);
 
        if (entering(tcp))
                printxval(archvals, option, "ARCH_???");
@@ -371,7 +371,7 @@ SYS_FUNC(arch_prctl)
                return 0;
        }
 
-       tprintf(", %#llx", addr);
+       tprintf(", %#" PRI_klx, addr);
        return RVAL_DECODED;
 }
 #endif /* X86_64 || X32 */
diff --git a/util.c b/util.c
index 4137e9ee9344ac3f01929c23f91b55eb586ebc78..2805091aef856975db65c36e7b13dfda11fa959a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -467,12 +467,12 @@ printflags64(const struct xlat *xlat, uint64_t flags, const char *dflt)
 }
 
 void
-printaddr_ull(const unsigned long long addr)
+printaddr_klu(const kernel_ulong_t addr)
 {
        if (!addr)
                tprints("NULL");
        else
-               tprintf("%#llx", addr);
+               tprintf("%#" PRI_klx, addr);
 }
 
 #define DEF_PRINTNUM(name, type) \
@@ -1490,8 +1490,8 @@ print_array(struct tcb *tcp,
        return cur >= end_addr;
 }
 
-unsigned long long
-getarg_ull(struct tcb *tcp, int argn)
+kernel_ulong_t
+getarg_klu(struct tcb *tcp, int argn)
 {
 #if HAVE_STRUCT_TCB_EXT_ARG
 # if SUPPORTED_PERSONALITIES > 1
@@ -1511,7 +1511,7 @@ printargs(struct tcb *tcp)
        const int n = tcp->s_ent->nargs;
        int i;
        for (i = 0; i < n; ++i)
-               tprintf("%s%#llx", i ? ", " : "", getarg_ull(tcp, i));
+               tprintf("%s%#" PRI_klx, i ? ", " : "", getarg_klu(tcp, i));
        return RVAL_DECODED;
 }