From: Dmitry V. Levin Date: Sun, 9 Jul 2017 13:54:01 +0000 (+0000) Subject: Intorduce PRINT_FIELD_DEV X-Git-Tag: v4.19~300 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1506a0ca6b3582a2085cde97b30a46699454cb8;p=strace Intorduce PRINT_FIELD_DEV * print_fields.h (PRINT_FIELD_DEV): New macro. * dm.c (dm_decode_device, dm_decode_dm_name_list): Use it instead of print_dev_t. * loop.c (decode_loop_info, decode_loop_info64): Likewise. * netlink_sock_diag.c (decode_unix_diag_vfs): Likewise. --- diff --git a/dm.c b/dm.c index 24136264..a84b59d1 100644 --- a/dm.c +++ b/dm.c @@ -32,6 +32,7 @@ */ #include "defs.h" +#include "print_fields.h" #ifdef HAVE_LINUX_DM_IOCTL_H @@ -63,8 +64,7 @@ dm_decode_device(const unsigned int code, const struct dm_ioctl *ioc) break; default: if (ioc->dev) { - tprints(", dev="); - print_dev_t(ioc->dev); + PRINT_FIELD_DEV(", ", *ioc, dev); } if (ioc->name[0]) { tprints(", name="); @@ -294,10 +294,8 @@ dm_decode_dm_name_list(struct tcb *const tcp, const kernel_ulong_t addr, if (umove_or_printaddr(tcp, addr + offset, &s)) break; - tprints("{dev="); - print_dev_t(s.dev); - - tprints("name="); + PRINT_FIELD_DEV("{", s, dev); + tprints(", name="); printstr_ex(tcp, addr + offset_end, ioc->data_size - offset_end, QUOTE_0_TERMINATED); tprints("}"); diff --git a/loop.c b/loop.c index df125201..27f1ddd2 100644 --- a/loop.c +++ b/loop.c @@ -36,6 +36,7 @@ typedef struct loop_info struct_loop_info; #include MPERS_DEFS +#include "print_fields.h" #include "xlat/loop_cmds.h" #include "xlat/loop_flags_options.h" #include "xlat/loop_crypt_type_options.h" @@ -52,11 +53,9 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr) tprintf("{lo_number=%d", info.lo_number); if (!abbrev(tcp)) { - tprints(", lo_device="); - print_dev_t(info.lo_device); + PRINT_FIELD_DEV(", ", info, lo_device); tprintf(", lo_inode=%" PRI_klu, (kernel_ulong_t) info.lo_inode); - tprints(", lo_rdevice="); - print_dev_t(info.lo_rdevice); + PRINT_FIELD_DEV(", ", info, lo_rdevice); } tprintf(", lo_offset=%#x", info.lo_offset); @@ -108,11 +107,9 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr) return; if (!abbrev(tcp)) { - tprints("{lo_device="); - print_dev_t(info64.lo_device); + PRINT_FIELD_DEV("{", info64, lo_device); tprintf(", lo_inode=%" PRIu64, (uint64_t) info64.lo_inode); - tprints(", lo_rdevice="); - print_dev_t(info64.lo_rdevice); + PRINT_FIELD_DEV(", ", info64, lo_rdevice); tprintf(", lo_offset=%#" PRIx64 ", lo_sizelimit=%" PRIu64 ", lo_number=%" PRIu32, (uint64_t) info64.lo_offset, diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c index f30eeeca..e0f6fff2 100644 --- a/netlink_sock_diag.c +++ b/netlink_sock_diag.c @@ -157,8 +157,7 @@ decode_unix_diag_vfs(struct tcb *const tcp, if (umove_or_printaddr(tcp, addr, &uv)) return true; - tprints("{udiag_vfs_dev="); - print_dev_t(uv.udiag_vfs_dev); + PRINT_FIELD_DEV("{", uv, udiag_vfs_dev); PRINT_FIELD_U(", ", uv, udiag_vfs_ino); tprints("}"); diff --git a/print_fields.h b/print_fields.h index 5fb652a3..860a039e 100644 --- a/print_fields.h +++ b/print_fields.h @@ -101,4 +101,10 @@ print_ifindex((where_).field_); \ } while (0) +#define PRINT_FIELD_DEV(prefix_, where_, field_) \ + do { \ + STRACE_PRINTF("%s%s=", (prefix_), #field_); \ + print_dev_t((where_).field_); \ + } while (0) + #endif /* !STRACE_PRINT_FIELDS_H */