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.
This commit is contained in:
2017-07-09 13:54:01 +00:00
parent cb0ce38988
commit c1506a0ca6
4 changed files with 16 additions and 16 deletions

10
dm.c
View File

@ -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("}");

13
loop.c
View File

@ -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,

View File

@ -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("}");

View File

@ -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 */