]> granicus.if.org Git - strace/blobdiff - tests/waitid.c
tests: extend TEST_NETLINK_OBJECT macro
[strace] / tests / waitid.c
index 6df25da627e5d5d9094ec0a6c377aa299dbc288e..26f5b86922bc630fe8f5ebed4511c2d3c81c56c8 100644 (file)
@@ -2,6 +2,7 @@
  * Check decoding of waitid syscall.
  *
  * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,8 +43,8 @@ sprint_rusage(const struct rusage *const ru)
 {
        static char buf[1024];
        snprintf(buf, sizeof(buf),
-                "{ru_utime={tv_sec=%lld, tv_usec=%lld}"
-                ", ru_stime={tv_sec=%lld, tv_usec=%lld}"
+                "{ru_utime={tv_sec=%lld, tv_usec=%llu}"
+                ", ru_stime={tv_sec=%lld, tv_usec=%llu}"
 #if VERBOSE
                 ", ru_maxrss=%llu"
                 ", ru_ixrss=%llu"
@@ -63,9 +64,9 @@ sprint_rusage(const struct rusage *const ru)
                 ", ...}"
 #endif
                 , (long long) ru->ru_utime.tv_sec
-                , (long long) ru->ru_utime.tv_usec
+                , zero_extend_signed_to_ull(ru->ru_utime.tv_usec)
                 , (long long) ru->ru_stime.tv_sec
-                , (long long) ru->ru_stime.tv_usec
+                , zero_extend_signed_to_ull(ru->ru_stime.tv_usec)
 #if VERBOSE
                 , zero_extend_signed_to_ull(ru->ru_maxrss)
                 , zero_extend_signed_to_ull(ru->ru_ixrss)
@@ -110,7 +111,8 @@ si_code_2_name(const int code)
 #ifdef CLD_CONTINUED
        CASE(CLD_CONTINUED);
 #endif
-       default: perror_msg_and_fail("unknown si_code %d", code);
+       default:
+               perror_msg_and_fail("unknown si_code %d", code);
        }
 }
 
@@ -144,7 +146,7 @@ poison(unsigned int v)
 static long
 do_waitid(const unsigned int idtype,
          const unsigned int id,
-         const siginfo_t const *infop,
+         const siginfo_t *const infop,
          const unsigned int options,
          const struct rusage *const rusage)
 {
@@ -185,9 +187,9 @@ main(void)
                perror_msg_and_fail("waitid #1");
        tprintf("waitid(P_PID, %d, NULL, WNOHANG|WEXITED, NULL) = 0\n", pid);
 
-       siginfo_t *const sinfo = tail_alloc(sizeof(*sinfo));
+       TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, sinfo);
        memset(sinfo, 0, sizeof(*sinfo));
-       struct rusage *const rusage = tail_alloc(sizeof(*rusage));
+       TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, rusage);
        if (do_waitid(P_PID, pid, sinfo, WNOHANG|WEXITED|WSTOPPED, rusage))
                perror_msg_and_fail("waitid #2");
        tprintf("waitid(P_PID, %d, {}, WNOHANG|WEXITED|WSTOPPED, %s) = 0\n",