]> granicus.if.org Git - strace/commitdiff
Intorduce PRINT_FIELD_0X
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 10 Jul 2017 02:23:00 +0000 (02:23 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 10 Jul 2017 02:23:00 +0000 (02:23 +0000)
* print_fields.h (PRINT_FIELD_0X): New macro.
* sockaddr.c (print_sockaddr_data_ipx, print_sockaddr_data_nl): Use it
instead of manual tprintf statements.
* netlink_sock_diag.c (PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS): Remove.
(decode_smc_diag_conninfo): Replace it with PRINT_FIELD_0X.

netlink_sock_diag.c
print_fields.h
sockaddr.c

index d162fbd959e336d0b8228b0a7751e13689a8943b..1bb832e709019c5e91074743f8960349e394c8fc 100644 (file)
@@ -916,11 +916,6 @@ print_smc_diag_cursor(const struct smc_diag_cursor *const cursor)
                print_smc_diag_cursor(&(where_).field_);                \
        } while (0)
 
-#define PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS(prefix_, where_, field_)   \
-       tprintf("%s%s=%#0*x",                                           \
-               (prefix_), #field_,                                     \
-               (int) sizeof(where_).field_, (where_).field_)
-
 static bool
 decode_smc_diag_conninfo(struct tcb *const tcp,
                         const kernel_ulong_t addr,
@@ -942,10 +937,10 @@ decode_smc_diag_conninfo(struct tcb *const tcp,
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, rx_cons);
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, tx_prod);
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, tx_cons);
-       PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS(", ", cinfo, rx_prod_flags);
-       PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS(", ", cinfo, rx_conn_state_flags);
-       PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS(", ", cinfo, tx_prod_flags);
-       PRINT_FIELD_SMC_DIAG_CONNINFO_FLAGS(", ", cinfo, tx_conn_state_flags);
+       PRINT_FIELD_0X(", ", cinfo, rx_prod_flags);
+       PRINT_FIELD_0X(", ", cinfo, rx_conn_state_flags);
+       PRINT_FIELD_0X(", ", cinfo, tx_prod_flags);
+       PRINT_FIELD_0X(", ", cinfo, tx_conn_state_flags);
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, tx_prep);
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, tx_sent);
        PRINT_FIELD_SMC_DIAG_CURSOR(", ", cinfo, tx_fin);
index e7bf5d8d8d57ef887836726d395afa4302aeeb72..49e5def0c2b096c4f7b1e8a4815215775d6561b3 100644 (file)
        STRACE_PRINTF("%s%s=%#llx", (prefix_), #field_,                 \
                      zero_extend_signed_to_ull((where_).field_))
 
+#define PRINT_FIELD_0X(prefix_, where_, field_)                                \
+       STRACE_PRINTF("%s%s=%#0*llx", (prefix_), #field_,               \
+                     (int) sizeof((where_).field_) * 2,                \
+                     zero_extend_signed_to_ull((where_).field_))
+
 #define PRINT_FIELD_COOKIE(prefix_, where_, field_)                    \
        STRACE_PRINTF("%s%s=[%llu, %llu]", (prefix_), #field_,          \
                      zero_extend_signed_to_ull((where_).field_[0]),    \
index 1e8fbdc1ff144774f5c7b624b8d1ce8a3fe95d75..875b22df13a69a67e39b2193d20e9b0044b6361d 100644 (file)
@@ -158,7 +158,7 @@ print_sockaddr_data_ipx(const void *const buf, const int addrlen)
                tprintf("%s%#02x", i ? ", " : "",
                        sa_ipx->sipx_node[i]);
        }
-       tprintf("], sipx_type=%#02x", sa_ipx->sipx_type);
+       PRINT_FIELD_0X("], ", *sa_ipx, sipx_type);
 }
 
 static void
@@ -166,8 +166,8 @@ print_sockaddr_data_nl(const void *const buf, const int addrlen)
 {
        const struct sockaddr_nl *const sa_nl = buf;
 
-       tprintf("nl_pid=%d, nl_groups=%#08x",
-               sa_nl->nl_pid, sa_nl->nl_groups);
+       PRINT_FIELD_D("", *sa_nl, nl_pid);
+       PRINT_FIELD_0X(", ", *sa_nl, nl_groups);
 }
 
 static void