]> granicus.if.org Git - strace/commitdiff
Fix omission of field names in printers of timeval structure
authorEugene Syromyatnikov <evgsyr@gmail.com>
Thu, 24 Nov 2016 21:48:00 +0000 (00:48 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 26 Nov 2016 00:40:53 +0000 (00:40 +0000)
* print_time.c (time_fmt): Remove.
(timeval_fmt): New constant.
(print_timeval_t, sprint_timeval, print_timeval32_t, sprint_timeval32):
Use it instead of time_fmt.
* print_timex.c (print_timex): Print field names of the time field.
* printrusage.c (printrusage, printrusage32): Print field names
of ru_utime and ru_stime fields.
* tests/adjtimex.c (main): Add field names to expected output.
* tests/clock_nanosleep.c (main): Likewise.
* tests/futimesat.c (main): Likewise.
* tests/getrusage.c (main): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/oldselect.expected: Likewise.
* tests/utimes.c (main): Likewise.
* tests/wait4.c (sprint_rusage): Likewise.
* tests/waitid.c (sprint_rusage): Likewise.
* tests/xetitimer.c (main): Likewise.
* tests/xettimeofday.c (main): Likewise.
* tests/xselect.c (main): Likewise.

15 files changed:
print_time.c
print_timex.c
printrusage.c
tests/adjtimex.c
tests/clock_nanosleep.c
tests/futimesat.c
tests/getrusage.c
tests/nanosleep.c
tests/oldselect.expected
tests/utimes.c
tests/wait4.c
tests/waitid.c
tests/xetitimer.c
tests/xettimeofday.c
tests/xselect.c

index 6276b08d8a34254f2d8c3078b4ae8019f05ece26..34c1c304d4e172673f5ee51b654699c109c67d71 100644 (file)
@@ -44,7 +44,7 @@ typedef struct timeval timeval_t;
 #endif
 
 static const char timespec_fmt[] = "{tv_sec=%jd, tv_nsec=%jd}";
-static const char time_fmt[] = "{%jd, %jd}";
+static const char timeval_fmt[]  = "{tv_sec=%jd, tv_usec=%jd}";
 
 static void
 print_timespec_t(const timespec_t *t)
@@ -71,7 +71,7 @@ print_timespec_t_utime(const timespec_t *t)
 static void
 print_timeval_t(const timeval_t *t)
 {
-       tprintf(time_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
+       tprintf(timeval_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
 }
 
 MPERS_PRINTER_DECL(void, print_timespec,
@@ -164,7 +164,7 @@ MPERS_PRINTER_DECL(const char *, sprint_timeval,
                   struct tcb *tcp, const long addr)
 {
        timeval_t t;
-       static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
+       static char buf[sizeof(timeval_fmt) + 3 * sizeof(t)];
 
        if (!addr) {
                strcpy(buf, "NULL");
@@ -172,7 +172,7 @@ MPERS_PRINTER_DECL(const char *, sprint_timeval,
                   umove(tcp, addr, &t)) {
                snprintf(buf, sizeof(buf), "%#lx", addr);
        } else {
-               snprintf(buf, sizeof(buf), time_fmt,
+               snprintf(buf, sizeof(buf), timeval_fmt,
                         (intmax_t) t.tv_sec, (intmax_t) t.tv_usec);
        }
 
@@ -215,7 +215,7 @@ typedef struct {
 static void
 print_timeval32_t(const timeval32_t *t)
 {
-       tprintf(time_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
+       tprintf(timeval_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
 }
 
 void
@@ -263,7 +263,7 @@ const char *
 sprint_timeval32(struct tcb *tcp, const long addr)
 {
        timeval32_t t;
-       static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
+       static char buf[sizeof(timeval_fmt) + 3 * sizeof(t)];
 
        if (!addr) {
                strcpy(buf, "NULL");
@@ -271,7 +271,7 @@ sprint_timeval32(struct tcb *tcp, const long addr)
                   umove(tcp, addr, &t)) {
                snprintf(buf, sizeof(buf), "%#lx", addr);
        } else {
-               snprintf(buf, sizeof(buf), time_fmt,
+               snprintf(buf, sizeof(buf), timeval_fmt,
                         (intmax_t) t.tv_sec, (intmax_t) t.tv_usec);
        }
 
index ad6a7114c1a91f0c1f491426ab5f3abfcf23b15d..21ac0e4a7e36873ae3e825fc582d78706455491f 100644 (file)
@@ -56,7 +56,7 @@ MPERS_PRINTER_DECL(int, print_timex, struct tcb *tcp, const long addr)
        tprintf(", constant=%jd, precision=%ju, tolerance=%jd",
                (intmax_t) tx.constant, (uintmax_t) tx.precision,
                (intmax_t) tx.tolerance);
-       tprintf(", time={%jd, %jd}",
+       tprintf(", time={tv_sec=%jd, tv_usec=%jd}",
                (intmax_t) tx.time.tv_sec, (intmax_t) tx.time.tv_usec);
        tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd",
                (intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter);
index 548af828b5a2738d506cce5ea06fcf0517cc3d7d..5dff1c6e0af7f49e99fb46fccdb05c2321263ddb 100644 (file)
@@ -44,7 +44,8 @@ MPERS_PRINTER_DECL(void, printrusage, struct tcb *tcp, long addr)
        if (umove_or_printaddr(tcp, addr, &ru))
                return;
 
-       tprintf("{ru_utime={%llu, %llu}, ru_stime={%llu, %llu}, ",
+       tprintf("{ru_utime={tv_sec=%llu, tv_usec=%llu}, "
+               "ru_stime={tv_sec=%llu, tv_usec=%llu}, ",
                zero_extend_signed_to_ull(ru.ru_utime.tv_sec),
                zero_extend_signed_to_ull(ru.ru_utime.tv_usec),
                zero_extend_signed_to_ull(ru.ru_stime.tv_sec),
@@ -99,7 +100,8 @@ printrusage32(struct tcb *tcp, long addr)
        if (umove_or_printaddr(tcp, addr, &ru))
                return;
 
-       tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
+       tprintf("{ru_utime={tv_sec=%lu, tv_usec=%lu}, "
+               "ru_stime={tv_sec=%lu, tv_usec=%lu}, ",
                (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
                (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
        if (abbrev(tcp))
index 9507fbeee8d2fefc59a8cc24dfb4f041df3d4f51..1638b53564c40ba2c9f7ffa7a1cac5be89850f5b 100644 (file)
@@ -48,9 +48,9 @@ main(void)
 
        printf("adjtimex\\(\\{modes=0, offset=%jd, freq=%jd, maxerror=%jd"
               ", esterror=%jd, status=%s, constant=%jd, precision=%jd"
-              ", tolerance=%jd, time=\\{%jd, %jd\\}, tick=%jd, ppsfreq=%jd"
-              ", jitter=%jd, shift=%d, stabil=%jd, jitcnt=%jd, calcnt=%jd"
-              ", errcnt=%jd, stbcnt=%jd"
+              ", tolerance=%jd, time=\\{tv_sec=%jd, tv_usec=%jd\\}, tick=%jd, "
+              "ppsfreq=%jd, jitter=%jd, shift=%d, stabil=%jd, jitcnt=%jd, "
+              "calcnt=%jd, errcnt=%jd, stbcnt=%jd"
 #ifdef HAVE_STRUCT_TIMEX_TAI
               ", tai=%d"
 #endif
index 87a3d5d3d2df8f28128399aadeb6491a7a69541c..98407d7e8cc8b0f12dfa4c9e637d475e32d408a1 100644 (file)
@@ -89,8 +89,8 @@ main(void)
 
        if (setitimer(ITIMER_REAL, &itv, NULL))
                perror_msg_and_skip("setitimer");
-       printf("setitimer(ITIMER_REAL, {it_interval={%jd, %jd}"
-              ", it_value={%jd, %jd}}, NULL) = 0\n",
+       printf("setitimer(ITIMER_REAL, {it_interval={tv_sec=%jd, tv_usec=%jd}"
+              ", it_value={tv_sec=%jd, tv_usec=%jd}}, NULL) = 0\n",
               (intmax_t) itv.it_interval.tv_sec,
               (intmax_t) itv.it_interval.tv_usec,
               (intmax_t) itv.it_value.tv_sec,
index b56911c4976b6c103e54ed2badbd3e087f40ffdf..d1e18efe016932756fdbe8cfef26892f1bf40970 100644 (file)
@@ -69,8 +69,8 @@ main(void)
 
        (void) close(0);
        rc = syscall(__NR_futimesat, 0, "", ts);
-       printf("futimesat(0, \"\", [{%llu, %llu}, {%llu, %llu}])"
-              " = %ld %s (%m)\n",
+       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),
               rc, errno2name());
index 3c09aa6e0533af6ce755c69e6e21655f6b406bac..8bea24f2a6ab11624246c530b48c2ced20a226d0 100644 (file)
@@ -41,9 +41,9 @@ main(void)
 {
        struct rusage *const usage = tail_alloc(sizeof(struct rusage));
        int rc = syscall(__NR_getrusage, RUSAGE_SELF, usage);
-       printf("getrusage(RUSAGE_SELF, {ru_utime={%ju, %ju}"
-              ", ru_stime={%ju, %ju}, ru_maxrss=%lu, ru_ixrss=%lu"
-              ", ru_idrss=%lu, ru_isrss=%lu, ru_minflt=%lu"
+       printf("getrusage(RUSAGE_SELF, {ru_utime={tv_sec=%ju, tv_usec=%ju}"
+              ", ru_stime={tv_sec=%ju, tv_usec=%ju}, ru_maxrss=%lu"
+              ", ru_ixrss=%lu, ru_idrss=%lu, ru_isrss=%lu, ru_minflt=%lu"
               ", ru_majflt=%lu, ru_nswap=%lu, ru_inblock=%lu"
               ", ru_oublock=%lu, ru_msgsnd=%lu, ru_msgrcv=%lu"
               ", ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}) = %d\n",
index 86bc2a458e792ebc661265235c842737905c048d..9f0e626f14cb83f78620a0d9e490765c2d0bbef3 100644 (file)
@@ -78,8 +78,8 @@ main(void)
 
        if (setitimer(ITIMER_REAL, &itv, NULL))
                perror_msg_and_skip("setitimer");
-       printf("setitimer(ITIMER_REAL, {it_interval={%jd, %jd}"
-              ", it_value={%jd, %jd}}, NULL) = 0\n",
+       printf("setitimer(ITIMER_REAL, {it_interval={tv_sec=%jd, tv_usec=%jd}"
+              ", it_value={tv_sec=%jd, tv_usec=%jd}}, NULL) = 0\n",
               (intmax_t) itv.it_interval.tv_sec,
               (intmax_t) itv.it_interval.tv_usec,
               (intmax_t) itv.it_value.tv_sec,
index c0426f42b00aa1f50e19441e06befddf0392f89e..d6e7f3c4b5a94a79c31d9b68b3ed3270bfbabe34 100644 (file)
@@ -1,2 +1,2 @@
-select(2, [1], [0], NULL, {0, 42}) = 0 (Timeout)
+select(2, [1], [0], NULL, {tv_sec=0, tv_usec=42}) = 0 (Timeout)
 +++ exited with 0 +++
index 401d18a14b1851d3f85ea6b2c3585e0793e269ff..8a3d7d302c8e10bbf138167057234b5b3f258e3e 100644 (file)
@@ -66,8 +66,8 @@ main(void)
        ts[1].tv_usec = tv.tv_usec + 1;
 
        rc = syscall(__NR_utimes, "", ts);
-       printf("utimes(\"\", [{%llu, %llu}, {%llu, %llu}])"
-              " = %ld %s (%m)\n",
+       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),
               rc, errno2name());
index 2d316aa67874a05ea7e3dbafdc4c7e2fc8e2df6f..ccb3ebb9a00fe8c392feb6c371c2338af0c67bc9 100644 (file)
@@ -40,8 +40,8 @@ sprint_rusage(const struct rusage *const ru)
 {
        static char buf[1024];
        snprintf(buf, sizeof(buf),
-                "{ru_utime={%lu, %lu}"
-                ", ru_stime={%lu, %lu}"
+                "{ru_utime={tv_sec=%lu, tv_usec=%lu}"
+                ", ru_stime={tv_sec=%lu, tv_usec=%lu}"
 #if VERBOSE
                 ", ru_maxrss=%lu"
                 ", ru_ixrss=%lu"
index c7fc507b2fa8edb9e130bce0bd2105f25f14baa9..db15b824204770f1d96b0c0e0e59650640bb026f 100644 (file)
@@ -42,8 +42,8 @@ sprint_rusage(const struct rusage *const ru)
 {
        static char buf[1024];
        snprintf(buf, sizeof(buf),
-                "{ru_utime={%llu, %llu}"
-                ", ru_stime={%llu, %llu}"
+                "{ru_utime={tv_sec=%llu, tv_usec=%llu}"
+                ", ru_stime={tv_sec=%llu, tv_usec=%llu}"
 #if VERBOSE
                 ", ru_maxrss=%llu"
                 ", ru_ixrss=%llu"
index 9c9fd997adc7f9c13e64444b5f44488cb0ecacf0..4b17edd3a67efee6cb7eac6909eb158c853a974d 100644 (file)
@@ -49,9 +49,10 @@ main(void)
        if (setitimer(ITIMER_REAL, &new.itv, &old.itv))
                perror_msg_and_skip("setitimer");
        printf("setitimer(ITIMER_REAL"
-              ", {it_interval={%jd, %jd}, it_value={%jd, %jd}}"
-              ", {it_interval={%jd, %jd}, it_value={%jd, %jd}}"
-              ") = 0\n",
+              ", {it_interval={tv_sec=%jd, tv_usec=%jd}, "
+              "it_value={tv_sec=%jd, tv_usec=%jd}}"
+              ", {it_interval={tv_sec=%jd, tv_usec=%jd}, "
+              "it_value={tv_sec=%jd, tv_usec=%jd}}) = 0\n",
               (intmax_t) new.itv.it_interval.tv_sec,
               (intmax_t) new.itv.it_interval.tv_usec,
               (intmax_t) new.itv.it_value.tv_sec,
@@ -64,8 +65,8 @@ main(void)
        if (getitimer(ITIMER_REAL, &old.itv))
                perror_msg_and_skip("getitimer");
        printf("getitimer(ITIMER_REAL"
-              ", {it_interval={%jd, %jd}, it_value={%jd, %jd}}"
-              ") = 0\n",
+              ", {it_interval={tv_sec=%jd, tv_usec=%jd}, "
+              "it_value={tv_sec=%jd, tv_usec=%jd}}) = 0\n",
               (intmax_t) old.itv.it_interval.tv_sec,
               (intmax_t) old.itv.it_interval.tv_usec,
               (intmax_t) old.itv.it_value.tv_sec,
index dd050917974754e423ffdacfc872b6d02df575c6..d36c57b4bf1126350a2ceece8ba6a62307133820 100644 (file)
@@ -48,12 +48,12 @@ main(void)
 
        if (syscall(__NR_gettimeofday, &t.tv, NULL))
                perror_msg_and_skip("gettimeofday");
-       printf("gettimeofday({%jd, %jd}, NULL) = 0\n",
+       printf("gettimeofday({tv_sec=%jd, tv_usec=%jd}, NULL) = 0\n",
               (intmax_t) t.tv.tv_sec, (intmax_t) t.tv.tv_usec);
 
        if (syscall(__NR_gettimeofday, &t.tv, &t.tz))
                perror_msg_and_skip("gettimeofday");
-       printf("gettimeofday({%jd, %jd}"
+       printf("gettimeofday({tv_sec=%jd, tv_usec=%jd}"
               ", {tz_minuteswest=%d, tz_dsttime=%d}) = 0\n",
               (intmax_t) t.tv.tv_sec, (intmax_t) t.tv.tv_usec,
               t.tz.tz_minuteswest, t.tz.tz_dsttime);
@@ -61,7 +61,7 @@ main(void)
        t.tv.tv_sec = -1;
        t.tv.tv_usec = 1000000000;
        assert(syscall(__NR_settimeofday, &t.tv, &t.tz) == -1);
-       printf("settimeofday({%jd, %jd}"
+       printf("settimeofday({tv_sec=%jd, tv_usec=%jd}"
               ", {tz_minuteswest=%d, tz_dsttime=%d})"
               " = -1 EINVAL (%m)\n",
               (intmax_t) t.tv.tv_sec, (intmax_t) t.tv.tv_usec,
index 08e29e1f4459cf7f676505d3cc2b08ad7e2d041d..39e87ac79e3240dfd3cbb2e0460dddc727b9fe9b 100644 (file)
@@ -72,8 +72,8 @@ int main(void)
        FD_SET(fds[0], set);
        FD_SET(fds[1], set);
        assert(syscall(TEST_SYSCALL_NR, fds[1] + 1, NULL, set, NULL, &tm.tv) == 3);
-       printf("%s(%d, NULL, [1 2 %d %d], NULL, {%lld, %lld})"
-              " = 3 (out [1 2 %d], left {%lld, %lld})\n",
+       printf("%s(%d, NULL, [1 2 %d %d], NULL, {tv_sec=%lld, tv_usec=%lld})"
+              " = 3 (out [1 2 %d], left {tv_sec=%lld, tv_usec=%lld})\n",
               TEST_SYSCALL_STR, fds[1] + 1, fds[0], fds[1],
               (long long) tm_in.tv.tv_sec, (long long) tm_in.tv.tv_usec,
               fds[1],
@@ -97,7 +97,7 @@ int main(void)
        tm.tv.tv_sec = 0;
        tm.tv.tv_usec = 123;
        assert(syscall(TEST_SYSCALL_NR, FD_SETSIZE + 1, set, set + 1, NULL, &tm.tv) == 0);
-       printf("%s(%d, [%d], [], NULL, {0, 123}) = 0 (Timeout)\n",
+       printf("%s(%d, [%d], [], NULL, {tv_sec=0, tv_usec=123}) = 0 (Timeout)\n",
               TEST_SYSCALL_STR, FD_SETSIZE + 1, fds[0]);
 
        puts("+++ exited with 0 +++");