summaryrefslogtreecommitdiff
path: root/print_struct_stat.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-02-26 19:14:34 +0000
committerDmitry V. Levin <ldv@altlinux.org>2017-02-26 19:14:34 +0000
commit889012d4b59ab2d8455fb5f86dc415bc3ce01e2b (patch)
treee6e7e676685ef0039ea6519e8305ba50f5db47f1 /print_struct_stat.c
parentf7b9a6ac636c97090f35453f00f2cde6e09714ae (diff)
downloadstrace-889012d4b59ab2d8455fb5f86dc415bc3ce01e2b.tar.gz
print_struct_stat.c: macroize printing of atime, mtime, and ctime fields
Introduce a macro for printing similar time related fields. * print_struct_stat.c (PRINT_ST_TIME): New macro. (print_struct_stat): Use it.
Diffstat (limited to 'print_struct_stat.c')
-rw-r--r--print_struct_stat.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/print_struct_stat.c b/print_struct_stat.c
index 7e9e23380..b5e0167ec 100644
--- a/print_struct_stat.c
+++ b/print_struct_stat.c
@@ -65,18 +65,15 @@ print_struct_stat(struct tcb *tcp, const struct strace_stat *const st)
}
if (!abbrev(tcp)) {
- tprints(", st_atime=");
- tprints(sprinttime(st->atime));
- if (st->atime_nsec)
- tprintf(".%09llu", st->atime_nsec);
- tprints(", st_mtime=");
- tprints(sprinttime(st->mtime));
- if (st->mtime_nsec)
- tprintf(".%09llu", st->mtime_nsec);
- tprints(", st_ctime=");
- tprints(sprinttime(st->ctime));
- if (st->ctime_nsec)
- tprintf(".%09llu", st->ctime_nsec);
+#define PRINT_ST_TIME(field) \
+ tprints(", st_" #field "="); \
+ tprints(sprinttime(st->field)); \
+ if (st->field ## _nsec) \
+ tprintf(".%09llu", st->field ## _nsec)
+
+ PRINT_ST_TIME(atime);
+ PRINT_ST_TIME(mtime);
+ PRINT_ST_TIME(ctime);
} else {
tprints(", ...");
}