]> granicus.if.org Git - strace/commitdiff
Intorduce PRINT_FIELD_DEV
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 9 Jul 2017 13:54:01 +0000 (13:54 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 9 Jul 2017 18:43:34 +0000 (18:43 +0000)
* 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.

dm.c
loop.c
netlink_sock_diag.c
print_fields.h

diff --git a/dm.c b/dm.c
index 2413626461363a79f0d3bbb1a5b1e3cb5dbde1d7..a84b59d14aaef9f5ffd66802e59e9a49fe1d92b9 100644 (file)
--- 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 df12520145d76a6189174c2e18fc4964cbd11328..27f1ddd24a8a616065c62ad767d29fe48a445ec8 100644 (file)
--- 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,
index f30eeeca57e7bbd450677d75f05adc78a55fd003..e0f6fff2647ceb16b13e9c6015b5718b0b874118 100644 (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("}");
 
index 5fb652a360aaadbb9ff8aa9b23b42a2bbcfd2b4e..860a039ed3bbfdb6c1d50c8310976310284b578f 100644 (file)
                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 */