Add format attributes to functions with format strings
[argpar.git] / argpar / argpar.c
index 8cc20cd77490f37a24f169b8d07d7feb2f564ade..13f66812894037b669924eb4446fd3f5472e464b 100644 (file)
 
 #define ARGPAR_ASSERT(_cond) assert(_cond)
 
-static
+#ifdef __MINGW_PRINTF_FORMAT
+# define ARGPAR_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
+#else
+# define ARGPAR_PRINTF_FORMAT printf
+#endif
+
+static __attribute__((format(ARGPAR_PRINTF_FORMAT, 1, 0)))
 char *argpar_vasprintf(const char *fmt, va_list args)
 {
        int len1, len2;
@@ -60,11 +66,12 @@ char *argpar_vasprintf(const char *fmt, va_list args)
        ARGPAR_ASSERT(len1 == len2);
 
 end:
+       va_end(args2);
        return str;
 }
 
 
-static
+static __attribute__((format(ARGPAR_PRINTF_FORMAT, 1, 2)))
 char *argpar_asprintf(const char *fmt, ...)
 {
        va_list args;
@@ -77,7 +84,7 @@ char *argpar_asprintf(const char *fmt, ...)
        return str;
 }
 
-static
+static __attribute__((format(ARGPAR_PRINTF_FORMAT, 2, 3)))
 bool argpar_string_append_printf(char **str, const char *fmt, ...)
 {
        char *new_str = NULL;
This page took 0.023079 seconds and 4 git commands to generate.