Intorduce PRINT_FIELD_0X

* 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.
This commit is contained in:
Дмитрий Левин 2017-07-10 02:23:00 +00:00
parent d4f2e8b94f
commit 2d727ee3d2
3 changed files with 12 additions and 12 deletions

View 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);

View File

@ -48,6 +48,11 @@
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]), \

View 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