test: fix printf("%s", NULL) in error path
authorRan Benita <ran@unusedvar.com>
Fri, 18 Oct 2019 21:37:48 +0000 (00:37 +0300)
committerRan Benita <ran@unusedvar.com>
Fri, 18 Oct 2019 21:38:43 +0000 (00:38 +0300)
    ../test/common.c: In function ‘test_get_path’:
    ../test/common.c:171:9: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
      171 |         fprintf(stderr, "Failed to allocate path (%d chars) for %s\n",
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      172 |                 (int) path_len, path);
          |                 ~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ran Benita <ran@unusedvar.com>
test/common.c

index c909707..c371272 100644 (file)
@@ -169,7 +169,7 @@ test_get_path(const char *path_rel)
     path = malloc(path_len);
     if (!path) {
         fprintf(stderr, "Failed to allocate path (%d chars) for %s\n",
-                (int) path_len, path);
+                (int) path_len, path_rel);
         return NULL;
     }
     snprintf(path, path_len,