From 0bf550423c1846d32acec367912bba5e215ab985 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sun, 27 Nov 2016 18:46:31 +0300 Subject: [PATCH] tests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests * tests/futimesat.c: Print tv_sec and tv_usec fields as signed types. * tests/utimes.c: Likewise. --- tests/futimesat.c | 13 +++++-------- tests/utimes.c | 14 +++++--------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/futimesat.c b/tests/futimesat.c index d1e18efe..3e04bd3c 100644 --- a/tests/futimesat.c +++ b/tests/futimesat.c @@ -32,14 +32,11 @@ #ifdef __NR_futimesat +# include # include # include # include -#define CAST_NUM(n) \ - (sizeof(n) == sizeof(long) ? \ - (unsigned long long) (unsigned long) (n) : \ - (unsigned long long) (n)) int main(void) @@ -69,10 +66,10 @@ main(void) (void) close(0); rc = syscall(__NR_futimesat, 0, "", ts); - printf("futimesat(0, \"\", [{tv_sec=%llu, tv_usec=%llu}, " - "{tv_sec=%llu, tv_usec=%llu}]) = %ld %s (%m)\n", - CAST_NUM(ts[0].tv_sec), CAST_NUM(ts[0].tv_usec), - CAST_NUM(ts[1].tv_sec), CAST_NUM(ts[1].tv_usec), + printf("futimesat(0, \"\", [{tv_sec=%jd, tv_usec=%jd}, " + "{tv_sec=%jd, tv_usec=%jd}]) = %ld %s (%m)\n", + (intmax_t) ts[0].tv_sec, (intmax_t) ts[0].tv_usec, + (intmax_t) ts[1].tv_sec, (intmax_t) ts[1].tv_usec, rc, errno2name()); puts("+++ exited with 0 +++"); diff --git a/tests/utimes.c b/tests/utimes.c index 8a3d7d30..1a2c9495 100644 --- a/tests/utimes.c +++ b/tests/utimes.c @@ -32,15 +32,11 @@ #ifdef __NR_utimes +# include # include # include # include -#define CAST_NUM(n) \ - (sizeof(n) == sizeof(long) ? \ - (unsigned long long) (unsigned long) (n) : \ - (unsigned long long) (n)) - int main(void) { @@ -66,10 +62,10 @@ main(void) ts[1].tv_usec = tv.tv_usec + 1; rc = syscall(__NR_utimes, "", ts); - printf("utimes(\"\", [{tv_sec=%llu, tv_usec=%llu}, " - "{tv_sec=%llu, tv_usec=%llu}]) = %ld %s (%m)\n", - CAST_NUM(ts[0].tv_sec), CAST_NUM(ts[0].tv_usec), - CAST_NUM(ts[1].tv_sec), CAST_NUM(ts[1].tv_usec), + printf("utimes(\"\", [{tv_sec=%jd, tv_usec=%jd}, " + "{tv_sec=%jd, tv_usec=%jd}]) = %ld %s (%m)\n", + (intmax_t) ts[0].tv_sec, (intmax_t) ts[0].tv_usec, + (intmax_t) ts[1].tv_sec, (intmax_t) ts[1].tv_usec, rc, errno2name()); puts("+++ exited with 0 +++");