From 889012d4b59ab2d8455fb5f86dc415bc3ce01e2b Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 26 Feb 2017 19:14:34 +0000 Subject: 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. --- print_struct_stat.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'print_struct_stat.c') 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(", ..."); } -- cgit v1.2.1