summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-07-08 08:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-07-08 08:00:00 +0000
commitac50c254ce492be16777f54929f9a73848a5c02b (patch)
treeb9cd128c133b4ff80a379be9952548855a2a8ccb
parente0a18245162dad8382f0c907af4d3e7f766c575d (diff)
downloadstrace-ac50c254ce492be16777f54929f9a73848a5c02b.tar.gz
loop: use print_fields.h macros
* loop.c (decode_loop_info, decode_loop_info64): Use PRINT_FIELD_* macros from print_fields.h.
-rw-r--r--loop.c74
1 files changed, 33 insertions, 41 deletions
diff --git a/loop.c b/loop.c
index 36a40c557..b3efe4432 100644
--- a/loop.c
+++ b/loop.c
@@ -34,30 +34,28 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
if (umove_or_printaddr(tcp, addr, &info))
return;
- tprintf("{lo_number=%d", info.lo_number);
+ PRINT_FIELD_D("{", info, lo_number);
if (!abbrev(tcp)) {
PRINT_FIELD_DEV(", ", info, lo_device);
- tprintf(", lo_inode=%" PRI_klu, (kernel_ulong_t) info.lo_inode);
+ PRINT_FIELD_U(", ", info, lo_inode);
PRINT_FIELD_DEV(", ", info, lo_rdevice);
}
- tprintf(", lo_offset=%#x", info.lo_offset);
+ PRINT_FIELD_X(", ", info, lo_offset);
if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
- tprints(", lo_encrypt_type=");
- printxval(loop_crypt_type_options, info.lo_encrypt_type,
- "LO_CRYPT_???");
+ PRINT_FIELD_XVAL(", ", info, lo_encrypt_type,
+ loop_crypt_type_options, "LO_CRYPT_???");
/*
- * It is converted to unsigned before use in kernel, see
- * loop_info64_from_old in drivers/block/loop.c
+ * It is converted to unsigned before use in the kernel,
+ * see loop_info64_from_old in drivers/block/loop.c
*/
- tprintf(", lo_encrypt_key_size=%" PRIu32,
- (uint32_t) info.lo_encrypt_key_size);
+ PRINT_FIELD_U(", ", info, lo_encrypt_key_size);
}
- tprints(", lo_flags=");
- printflags(loop_flags_options, info.lo_flags, "LO_FLAGS_???");
+ PRINT_FIELD_FLAGS(", ", info, lo_flags,
+ loop_flags_options, "LO_FLAGS_???");
PRINT_FIELD_CSTRING(", ", info, lo_name);
@@ -68,15 +66,14 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
lo_encrypt_key_size, 0);
}
- if (!abbrev(tcp))
- tprintf(", lo_init=[%#" PRI_klx ", %#" PRI_klx "]"
- ", reserved=[%#hhx, %#hhx, %#hhx, %#hhx]}",
- (kernel_ulong_t) info.lo_init[0],
- (kernel_ulong_t) info.lo_init[1],
- info.reserved[0], info.reserved[1],
- info.reserved[2], info.reserved[3]);
- else
- tprints(", ...}");
+ if (!abbrev(tcp)) {
+ PRINT_FIELD_X_ARRAY(", ", info, lo_init);
+ PRINT_FIELD_X_ARRAY(", ", info, reserved);
+ } else {
+ tprints(", ...");
+ }
+
+ tprints("}");
}
static void
@@ -90,29 +87,24 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr)
if (!abbrev(tcp)) {
PRINT_FIELD_DEV("{", info64, lo_device);
- tprintf(", lo_inode=%" PRIu64, (uint64_t) info64.lo_inode);
+ PRINT_FIELD_U(", ", info64, lo_inode);
PRINT_FIELD_DEV(", ", info64, lo_rdevice);
- tprintf(", lo_offset=%#" PRIx64 ", lo_sizelimit=%" PRIu64
- ", lo_number=%" PRIu32,
- (uint64_t) info64.lo_offset,
- (uint64_t) info64.lo_sizelimit,
- (uint32_t) info64.lo_number);
+ PRINT_FIELD_X(", ", info64, lo_offset);
+ PRINT_FIELD_U(", ", info64, lo_sizelimit);
+ PRINT_FIELD_U(", ", info64, lo_number);
} else {
- tprintf("{lo_offset=%#" PRIx64 ", lo_number=%" PRIu32,
- (uint64_t) info64.lo_offset,
- (uint32_t) info64.lo_number);
+ PRINT_FIELD_X("{", info64, lo_offset);
+ PRINT_FIELD_U(", ", info64, lo_number);
}
if (!abbrev(tcp) || info64.lo_encrypt_type != LO_CRYPT_NONE) {
- tprints(", lo_encrypt_type=");
- printxval(loop_crypt_type_options, info64.lo_encrypt_type,
- "LO_CRYPT_???");
- tprintf(", lo_encrypt_key_size=%" PRIu32,
- info64.lo_encrypt_key_size);
+ PRINT_FIELD_XVAL(", ", info64, lo_encrypt_type,
+ loop_crypt_type_options, "LO_CRYPT_???");
+ PRINT_FIELD_U(", ", info64, lo_encrypt_key_size);
}
- tprints(", lo_flags=");
- printflags(loop_flags_options, info64.lo_flags, "LO_FLAGS_???");
+ PRINT_FIELD_FLAGS(", ", info64, lo_flags,
+ loop_flags_options, "LO_FLAGS_???");
PRINT_FIELD_CSTRING(", ", info64, lo_file_name);
@@ -125,11 +117,11 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr)
}
if (!abbrev(tcp))
- tprintf(", lo_init=[%#" PRIx64 ", %#" PRIx64 "]}",
- (uint64_t) info64.lo_init[0],
- (uint64_t) info64.lo_init[1]);
+ PRINT_FIELD_X_ARRAY(", ", info64, lo_init);
else
- tprints(", ...}");
+ tprints(", ...");
+
+ tprints("}");
}
MPERS_PRINTER_DECL(int, loop_ioctl,