]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
tests: avoid passing NULL strings to vprintf
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 22 Aug 2016 23:53:34 +0000 (19:53 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 5 Oct 2016 12:24:01 +0000 (08:24 -0400)
Some libc implementations will crash when NULL string arguments are given to
*printf.  Avoid passing NULL string arguments in the make check tests that did
so, and pass the string "(null)" instead.

Reviewed-on: https://gerrit.openafs.org/12377
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 2fe3a28c6ec0ff9d19ddec5500b3a5e69b483210)

Change-Id: Id8f1635444b5b49e3250addf36b64fccafd59941
Reviewed-on: https://gerrit.openafs.org/12396
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
tests/util/exec-alt-t.c

index f8921a0348a57cf1e2beda2cd0849b41d43e9530..711412f2f8400086853acf27b6d3b7cc3c90298c 100644 (file)
@@ -24,6 +24,7 @@
 
 #define FAILSTR "exec test failure\n"
 #define ARGSTRING "teststring"
+#define PSTR(s) ((s) != NULL ? (s) : "(null)")
 
 static struct exec_test {
     const char *prefix; /* program prefix to run */
@@ -196,7 +197,7 @@ main(int argc, char **argv)
            nBytes = read(fds[0], buf, sizeof(buf)-1);
            is_int(result_len, nBytes,
                   "child output size for prefix=%s, suffix=%s",
-                  t->prefix, t->suffix);
+                  PSTR(t->prefix), PSTR(t->suffix));
 
            if (nBytes < 0) {
                skip("read() failed; cannot test read buffer");
@@ -206,7 +207,7 @@ main(int argc, char **argv)
 
                is_string(result, buf,
                          "child output for prefix=%s, suffix=%s",
-                         t->prefix, t->suffix);
+                         PSTR(t->prefix), PSTR(t->suffix));
            }
 
            if (close(fds[0])) {
@@ -225,12 +226,12 @@ main(int argc, char **argv)
            }
 
            ok(WIFEXITED(status), "child exited for prefix=%s, suffix=%s",
-                                 t->prefix, t->suffix);
+                                 PSTR(t->prefix), PSTR(t->suffix));
 
            if (WIFEXITED(status)) {
                is_int(0, WEXITSTATUS(status),
                       "child exit code for prefix=%s, suffix=%s",
-                      t->prefix, t->suffix);
+                      PSTR(t->prefix), PSTR(t->suffix));
            } else {
                skip("!WIFEXITED(status) (status=%d), cannot check exit code",
                     status);