commit 26e2a97: [Minor] enable Wmissing-format-attribute
Christian Göttsche
cgzones at googlemail.com
Tue Apr 14 09:56:13 UTC 2020
Author: Christian Göttsche
Date: 2020-04-06 16:27:42 +0200
URL: https://github.com/rspamd/rspamd/commit/26e2a97b1cbb099fae5a7b613ea1edbb342a4061
[Minor] enable Wmissing-format-attribute
---
cmake/CompilerWarnings.cmake | 4 ++++
contrib/hiredis/async.h | 6 ++++++
contrib/hiredis/hiredis.h | 18 ++++++++++++++++++
contrib/hiredis/sds.h | 3 +++
contrib/librdns/dns_private.h | 3 +++
contrib/librdns/logger.h | 6 ++++++
contrib/librdns/resolver.c | 6 +++---
contrib/replxx/include/replxx.h | 3 +++
contrib/replxx/include/replxx.hxx | 3 +++
contrib/uthash/utstring.h | 3 +++
src/libstat/backends/redis_backend.c | 9 +++++++++
11 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake
index 2dcad92ef..fe6735c35 100644
--- a/cmake/CompilerWarnings.cmake
+++ b/cmake/CompilerWarnings.cmake
@@ -11,6 +11,7 @@ CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES)
CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG)
CHECK_C_COMPILER_FLAG(-Wno-unused-const-variable SUPPORT_WNO_UNUSED_CONST)
CHECK_C_COMPILER_FLAG(-Wmissing-noreturn SUPPORT_WMISSING_NORETURN)
+CHECK_C_COMPILER_FLAG(-Wmissing-format-attribute SUPPORT_WMISSING_FORMAT_ATTRIBUTE)
# GCC 6 specific
CHECK_C_COMPILER_FLAG(-Wnull-dereference SUPPORT_WNULL_DEREFERENCE)
CHECK_C_COMPILER_FLAG(-Wduplicated-cond SUPPORT_WDUPLICATED_COND)
@@ -71,6 +72,9 @@ ENDIF(SUPPORT_WIMPLICIT_FALLTHROUGH)
IF(SUPPORT_WMISSING_NORETURN)
ADD_COMPILE_OPTIONS("-Wmissing-noreturn")
ENDIF(SUPPORT_WMISSING_NORETURN)
+IF(SUPPORT_WMISSING_FORMAT_ATTRIBUTE)
+ ADD_COMPILE_OPTIONS("-Wmissing-format-attribute")
+ENDIF(SUPPORT_WMISSING_FORMAT_ATTRIBUTE)
CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC)
IF(SUPPORT_FPIC)
diff --git a/contrib/hiredis/async.h b/contrib/hiredis/async.h
index 3d20241c6..40a5a49c8 100644
--- a/contrib/hiredis/async.h
+++ b/contrib/hiredis/async.h
@@ -119,7 +119,13 @@ void redisAsyncHandleWrite(redisAsyncContext *ac);
/* Command functions for an async context. Write the command to the
* output buffer and register the provided callback. */
+#ifdef __GNUC__
+__attribute__((format(printf, 4, 0)))
+#endif
int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, va_list ap);
+#ifdef __GNUC__
+__attribute__((format(printf, 4, 5)))
+#endif
int redisAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *format, ...);
int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen);
int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char *cmd, size_t len);
diff --git a/contrib/hiredis/hiredis.h b/contrib/hiredis/hiredis.h
index 153bfd7a6..6b531b910 100644
--- a/contrib/hiredis/hiredis.h
+++ b/contrib/hiredis/hiredis.h
@@ -125,7 +125,13 @@ redisReader *redisReaderCreate(void);
void freeReplyObject(void *reply);
/* Functions to format a command according to the protocol. */
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 0)))
+#endif
int redisvFormatCommand(char **target, const char *format, va_list ap);
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 3)))
+#endif
int redisFormatCommand(char **target, const char *format, ...);
int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen);
int redisFormatSdsCommandArgv(sds *target, int argc, const char ** argv, const size_t *argvlen);
@@ -204,7 +210,13 @@ int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len);
/* Write a command to the output buffer. Use these functions in blocking mode
* to get a pipeline of commands. */
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 0)))
+#endif
int redisvAppendCommand(redisContext *c, const char *format, va_list ap);
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 3)))
+#endif
int redisAppendCommand(redisContext *c, const char *format, ...);
int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen);
@@ -213,7 +225,13 @@ int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const s
* NULL if there was an error in performing the request, otherwise it will
* return the reply. In a non-blocking context, it is identical to calling
* only redisAppendCommand and will always return NULL. */
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 0)))
+#endif
void *redisvCommand(redisContext *c, const char *format, va_list ap);
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 3)))
+#endif
void *redisCommand(redisContext *c, const char *format, ...);
void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen);
diff --git a/contrib/hiredis/sds.h b/contrib/hiredis/sds.h
index 19a2abd31..a494f2efc 100644
--- a/contrib/hiredis/sds.h
+++ b/contrib/hiredis/sds.h
@@ -71,6 +71,9 @@ sds sdscatsds(sds s, const sds t);
sds sdscpylen(sds s, const char *t, size_t len);
sds sdscpy(sds s, const char *t);
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 0)))
+#endif
sds sdscatvprintf(sds s, const char *fmt, va_list ap);
#ifdef __GNUC__
sds sdscatprintf(sds s, const char *fmt, ...)
diff --git a/contrib/librdns/dns_private.h b/contrib/librdns/dns_private.h
index f734e2312..3f0bee437 100644
--- a/contrib/librdns/dns_private.h
+++ b/contrib/librdns/dns_private.h
@@ -138,6 +138,9 @@ struct rdns_resolver {
struct rdns_plugin *curve_plugin;
struct rdns_fake_reply *fake_elts;
+#ifdef __GNUC__
+ __attribute__((format(printf, 4, 0)))
+#endif
rdns_log_function logger;
void *log_data;
enum rdns_log_level log_level;
diff --git a/contrib/librdns/logger.h b/contrib/librdns/logger.h
index f9c33bbe4..80728763e 100644
--- a/contrib/librdns/logger.h
+++ b/contrib/librdns/logger.h
@@ -26,10 +26,16 @@
#include <stdarg.h>
#include "dns_private.h"
+#ifdef __GNUC__
+__attribute__((format(printf, 4, 0)))
+#endif
void rdns_logger_internal (void *log_data, enum rdns_log_level level,
const char *function, const char *format,
va_list args);
+#ifdef __GNUC__
+__attribute__((format(printf, 4, 5)))
+#endif
void rdns_logger_helper (struct rdns_resolver *resolver,
enum rdns_log_level level,
const char *function, const char *format, ...);
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index aec0e9381..98807f38e 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -758,14 +758,14 @@ rdns_make_request_full (
type = req->requested_names[i].type;
if (queries > 1) {
if (!rdns_add_rr (req, cur_name, clen, type, &comp)) {
- rdns_err ("cannot add rr", cur_name);
+ rdns_err ("cannot add rr");
REF_RELEASE (req);
rnds_compression_free (comp);
return NULL;
}
} else {
if (!rdns_add_rr (req, cur_name, clen, type, NULL)) {
- rdns_err ("cannot add rr", cur_name);
+ rdns_err ("cannot add rr");
REF_RELEASE (req);
rnds_compression_free (comp);
return NULL;
@@ -1125,4 +1125,4 @@ void rdns_resolver_set_fake_reply (struct rdns_resolver *resolver,
HASH_ADD (hh, resolver->fake_elts, key, sizeof (*srch) + len, fake_rep);
}
-}
\ No newline at end of file
+}
diff --git a/contrib/replxx/include/replxx.h b/contrib/replxx/include/replxx.h
index cb1c917b4..4bdad5127 100644
--- a/contrib/replxx/include/replxx.h
+++ b/contrib/replxx/include/replxx.h
@@ -356,6 +356,9 @@ REPLXX_IMPEXP void replxx_set_state( Replxx*, ReplxxState* state );
*
* \param fmt - printf style format.
*/
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 3)))
+#endif
REPLXX_IMPEXP int replxx_print( Replxx*, char const* fmt, ... );
/*! \brief Schedule an emulated key press event.
diff --git a/contrib/replxx/include/replxx.hxx b/contrib/replxx/include/replxx.hxx
index 3fe90e670..1401ea27c 100644
--- a/contrib/replxx/include/replxx.hxx
+++ b/contrib/replxx/include/replxx.hxx
@@ -370,6 +370,9 @@ public:
*
* \param fmt - printf style format.
*/
+#ifdef __GNUC__
+ __attribute__((format(printf, 2, 3)))
+#endif
void print( char const* fmt, ... );
/*! \brief Schedule an emulated key press event.
diff --git a/contrib/uthash/utstring.h b/contrib/uthash/utstring.h
index f11f34b77..6130fac53 100644
--- a/contrib/uthash/utstring.h
+++ b/contrib/uthash/utstring.h
@@ -120,6 +120,9 @@ do { \
#define utstring_body(s) ((s)->d)
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 0)))
+#endif
_UNUSED_ static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) {
int n;
va_list cp;
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 107af3490..392f1704e 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -372,6 +372,12 @@ rspamd_redis_maybe_auth (struct redis_stat_ctx *ctx, redisAsyncContext *redis)
}
}
+// the `b` conversion type character is unknown to gcc
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
+#endif
static rspamd_fstring_t *
rspamd_redis_tokens_to_query (struct rspamd_task *task,
struct redis_stat_runtime *rt,
@@ -625,6 +631,9 @@ rspamd_redis_tokens_to_query (struct rspamd_task *task,
return out;
}
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
static void
rspamd_redis_store_stat_signature (struct rspamd_task *task,
More information about the Commits
mailing list