diff options
author | Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> | 2022-10-18 11:23:15 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-12-18 08:00:00 +0000 |
commit | 20f40cc466a3c9226dd7d729c9b20d61909f0a4a (patch) | |
tree | ec072a6b09866b41c9e31633cb1b28777e66b57c | |
parent | a6e43b0be3bdc6d1098da70b079f016be2454c75 (diff) | |
download | strace-20f40cc466a3c9226dd7d729c9b20d61909f0a4a.tar.gz |
src: introduce printflags_in and printflags64_in helpers
* src/defs.h (printflags64_in): Rename from printflags64.
(printflags_in): Rename from printflags. Use printflags64_in.
(printflags64, printflags): New functions.
* src/capability.c (print_cap_bits): Use printflags_in instead of
printflags.
* src/fanotify.c (SYS_FUNC(fanotify_init)): Likewise.
* src/ipc_msg.c (SYS_FUNC(msgget)): Likewise.
* src/ipc_sem.c (SYS_FUNC(semget)): Likewise.
* src/ipc_shm.c (SYS_FUNC(shmget)): Likewise.
* src/net.c (tprint_sock_type): Likewise.
* src/personality.c (SYS_FUNC(personality)): Likewise.
* src/statx.c (SYS_FUNC(statx)): Likewise.
* src/swapon.c (SYS_FUNC(swapon)): Likewise.
* src/v4l2.c (print_v4l2_buffer_flags, print_v4l2_cid): Likewise.
* src/clone.c (SYS_FUNC(clone)): Use printflags64_in instead of
printflags64.
* src/kexec.c (SYS_FUNC(kexec_load)): Likewise.
* src/mount.c (SYS_FUNC(mount)): Likewise.
* src/term.c (decode_oflag, decode_cflag): Likewise.
Co-authored-by: Dmitry V. Levin <ldv@strace.io>
-rw-r--r-- | src/capability.c | 4 | ||||
-rw-r--r-- | src/clone.c | 2 | ||||
-rw-r--r-- | src/defs.h | 21 | ||||
-rw-r--r-- | src/fanotify.c | 2 | ||||
-rw-r--r-- | src/ipc_msg.c | 2 | ||||
-rw-r--r-- | src/ipc_sem.c | 2 | ||||
-rw-r--r-- | src/ipc_shm.c | 2 | ||||
-rw-r--r-- | src/kexec.c | 2 | ||||
-rw-r--r-- | src/mount.c | 2 | ||||
-rw-r--r-- | src/net.c | 2 | ||||
-rw-r--r-- | src/personality.c | 2 | ||||
-rw-r--r-- | src/statx.c | 6 | ||||
-rw-r--r-- | src/swapon.c | 2 | ||||
-rw-r--r-- | src/term.c | 4 | ||||
-rw-r--r-- | src/v4l2.c | 6 |
15 files changed, 38 insertions, 23 deletions
diff --git a/src/capability.c b/src/capability.c index 1d4bf899c..f7561b34b 100644 --- a/src/capability.c +++ b/src/capability.c @@ -80,12 +80,12 @@ print_cap_bits(const uint32_t lo, const uint32_t hi) { tprint_flags_begin(); if (lo || !hi) - printflags(cap_mask0, lo, "CAP_???"); + printflags_in(cap_mask0, lo, "CAP_???"); if (hi) { if (lo) tprint_flags_or(); - printflags(cap_mask1, hi, "CAP_???"); + printflags_in(cap_mask1, hi, "CAP_???"); } tprint_flags_end(); } diff --git a/src/clone.c b/src/clone.c index f77538636..acd85cfa8 100644 --- a/src/clone.c +++ b/src/clone.c @@ -88,7 +88,7 @@ SYS_FUNC(clone) tprints_arg_name("flags"); if (flags) { tprint_flags_begin(); - printflags64(clone_flags, flags, "CLONE_???"); + printflags64_in(clone_flags, flags, "CLONE_???"); if (sig) { tprint_flags_or(); printsignal(sig); diff --git a/src/defs.h b/src/defs.h index f90763dd5..3654a6bfd 100644 --- a/src/defs.h +++ b/src/defs.h @@ -1548,15 +1548,15 @@ printstr(struct tcb *tcp, kernel_ulong_t addr) } static inline int -printflags64(const struct xlat *x, uint64_t flags, const char *dflt) +printflags64_in(const struct xlat *x, uint64_t flags, const char *dflt) { return printflags_ex(flags, dflt, XLAT_STYLE_DEFAULT, x, NULL); } static inline int -printflags(const struct xlat *x, unsigned int flags, const char *dflt) +printflags_in(const struct xlat *x, unsigned int flags, const char *dflt) { - return printflags64(x, flags, dflt); + return printflags64_in(x, flags, dflt); } static inline int @@ -2046,6 +2046,21 @@ ilog2_32(uint32_t val) # include "print_fields.h" +static inline int +printflags64(const struct xlat *x, uint64_t flags, const char *dflt) +{ + tprint_flags_begin(); + int r = printflags64_in(x, flags, dflt); + tprint_flags_end(); + return r; +} + +static inline int +printflags(const struct xlat *x, unsigned int flags, const char *dflt) +{ + return printflags64(x, flags, dflt); +} + /* * When u64 is interpreted by the kernel as an address, there is a difference * in behaviour between 32-bit and 64-bit kernel in the way u64_to_user_ptr diff --git a/src/fanotify.c b/src/fanotify.c index 36126d643..65cc41cc3 100644 --- a/src/fanotify.c +++ b/src/fanotify.c @@ -28,7 +28,7 @@ SYS_FUNC(fanotify_init) flags &= ~FAN_ALL_CLASS_BITS; if (flags) { tprint_flags_or(); - printflags(fan_init_flags, flags, "FAN_???"); + printflags_in(fan_init_flags, flags, "FAN_???"); } tprint_flags_end(); tprint_arg_next(); diff --git a/src/ipc_msg.c b/src/ipc_msg.c index 91f8d5f1a..79b04f2fb 100644 --- a/src/ipc_msg.c +++ b/src/ipc_msg.c @@ -28,7 +28,7 @@ SYS_FUNC(msgget) /* msgflg */ tprint_flags_begin(); - if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) + if (printflags_in(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) tprint_flags_or(); print_numeric_umode_t(tcp->u_arg[1] & 0777); tprint_flags_end(); diff --git a/src/ipc_sem.c b/src/ipc_sem.c index abca5c9ab..62344f9b8 100644 --- a/src/ipc_sem.c +++ b/src/ipc_sem.c @@ -113,7 +113,7 @@ SYS_FUNC(semget) /* semflg */ tprint_flags_begin(); - if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) + if (printflags_in(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) tprint_flags_or(); print_numeric_umode_t(tcp->u_arg[2] & 0777); tprint_flags_end(); diff --git a/src/ipc_shm.c b/src/ipc_shm.c index 62da796ca..e9999c5f2 100644 --- a/src/ipc_shm.c +++ b/src/ipc_shm.c @@ -45,7 +45,7 @@ SYS_FUNC(shmget) flags &= ~mask; tprint_flags_begin(); if (flags || !hugetlb_value) - printflags(shm_resource_flags, flags, NULL); + printflags_in(shm_resource_flags, flags, NULL); if (hugetlb_value) { if (flags) diff --git a/src/kexec.c b/src/kexec.c index bf74c9c82..b3f36d85f 100644 --- a/src/kexec.c +++ b/src/kexec.c @@ -80,7 +80,7 @@ SYS_FUNC(kexec_load) n &= ~(kernel_ulong_t) KEXEC_ARCH_MASK; if (n) { tprint_flags_or(); - printflags64(kexec_load_flags, n, "KEXEC_???"); + printflags64_in(kexec_load_flags, n, "KEXEC_???"); } tprint_flags_end(); diff --git a/src/mount.c b/src/mount.c index 28fcdef93..08eb12f7d 100644 --- a/src/mount.c +++ b/src/mount.c @@ -60,7 +60,7 @@ SYS_FUNC(mount) tprint_flags_or(); } if (flags || !old_magic) - printflags64(mount_flags, flags, "MS_???"); + printflags64_in(mount_flags, flags, "MS_???"); tprint_flags_end(); tprint_arg_next(); @@ -103,7 +103,7 @@ tprint_sock_type(unsigned int flags) return; tprint_flags_or(); } - printflags(sock_type_flags, flags, "SOCK_???"); + printflags_in(sock_type_flags, flags, "SOCK_???"); tprint_flags_end(); } diff --git a/src/personality.c b/src/personality.c index 6a60753ba..d6e1a9b90 100644 --- a/src/personality.c +++ b/src/personality.c @@ -25,7 +25,7 @@ SYS_FUNC(personality) pers &= ~PER_MASK; if (pers) { tprint_flags_or(); - printflags(personality_flags, pers, NULL); + printflags_in(personality_flags, pers, NULL); } tprint_flags_end(); } diff --git a/src/statx.c b/src/statx.c index f3896af2e..2b9e30d0b 100644 --- a/src/statx.c +++ b/src/statx.c @@ -41,12 +41,12 @@ SYS_FUNC(statx) /* flags */ unsigned int flags = tcp->u_arg[2]; tprint_flags_begin(); - printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE, - NULL); + printflags_in(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE, + NULL); flags &= ~AT_STATX_SYNC_TYPE; if (flags) { tprint_flags_or(); - printflags(at_flags, flags, NULL); + printflags_in(at_flags, flags, NULL); } tprint_flags_end(); tprint_arg_next(); diff --git a/src/swapon.c b/src/swapon.c index 3c92eebd6..aaa409a66 100644 --- a/src/swapon.c +++ b/src/swapon.c @@ -24,7 +24,7 @@ SYS_FUNC(swapon) /* swapflags */ tprint_flags_begin(); if (flags) { - printflags(swap_flags, flags, "SWAP_FLAG_???"); + printflags_in(swap_flags, flags, "SWAP_FLAG_???"); tprint_flags_or(); } PRINT_VAL_U(prio); diff --git a/src/term.c b/src/term.c index 54618c286..1695a33a7 100644 --- a/src/term.c +++ b/src/term.c @@ -64,7 +64,7 @@ decode_oflag(uint64_t val) val &= ~xlats[i].mask; } - printflags64(term_oflags, val, NULL); + printflags64_in(term_oflags, val, NULL); tprint_flags_end(); } @@ -88,7 +88,7 @@ decode_cflag(uint64_t val) tprint_flags_or(); val &= ~(CBAUD | CIBAUD | CSIZE); - printflags64(term_cflags, val, NULL); + printflags64_in(term_cflags, val, NULL); tprint_flags_end(); } diff --git a/src/v4l2.c b/src/v4l2.c index c87bdc6fe..9bd0d748d 100644 --- a/src/v4l2.c +++ b/src/v4l2.c @@ -505,7 +505,7 @@ print_v4l2_buffer_flags(uint32_t val) tprint_flags_begin(); if (flags) { - printflags(v4l2_buf_flags, flags, "V4L2_BUF_FLAG_???"); + printflags_in(v4l2_buf_flags, flags, "V4L2_BUF_FLAG_???"); tprint_flags_or(); } printxval(v4l2_buf_flags_ts_type, ts_type, @@ -816,8 +816,8 @@ print_v4l2_cid(uint32_t cid, bool next_flags) uint32_t flags = cid & v4l2_control_query_flags->flags_mask; if (flags) { - printflags(v4l2_control_query_flags, flags, - "V4L2_CTRL_FLAG_NEXT_???"); + printflags_in(v4l2_control_query_flags, flags, + "V4L2_CTRL_FLAG_NEXT_???"); tprint_flags_or(); cid &= ~flags; } |