[network-manager-openvpn/nm-1-0] tests: avoid string-format warning in test helpers



commit caabac2375977654243b12de22bff9b24890b665
Author: Thomas Haller <thaller redhat com>
Date:   Wed Sep 21 12:08:19 2016 +0200

    tests: avoid string-format warning in test helpers
    
        In file included from test-import-export.c:34:
        ../../nm-test-helpers.h:38:20: error: format string is not a string literal 
[-Werror,-Wformat-nonliteral]
                vfprintf (stderr, buf, args);
                                  ^~~

 nm-test-helpers.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/nm-test-helpers.h b/nm-test-helpers.h
index 840e25f..9097607 100644
--- a/nm-test-helpers.h
+++ b/nm-test-helpers.h
@@ -26,17 +26,17 @@
 #include <unistd.h>
 #include <stdarg.h>
 
+__attribute__ ((__format__ (__printf__, 2, 3)))
 static void
 FAIL(const char *test_name, const char *fmt, ...)
 {
        va_list args;
-       char buf[500];
-
-       snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
 
+       fprintf (stderr, "FAIL: (%s) ", test_name);
        va_start (args, fmt);
-       vfprintf (stderr, buf, args);
+       vfprintf (stderr, fmt, args);
        va_end (args);
+       fprintf (stderr, "\n");
        _exit (1);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]