From 64c0e8d4bcf5f6822cdef368ee84074c3ea234c7 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 10 Jun 2016 11:19:51 -0700 Subject: Add format check for gpr_log and gpr_asprintf --- include/grpc/impl/codegen/log.h | 4 +++- include/grpc/support/string_util.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/grpc/impl/codegen/log.h b/include/grpc/impl/codegen/log.h index aa86fc4c17..9090a34cd5 100644 --- a/include/grpc/impl/codegen/log.h +++ b/include/grpc/impl/codegen/log.h @@ -34,6 +34,7 @@ #ifndef GRPC_IMPL_CODEGEN_LOG_H #define GRPC_IMPL_CODEGEN_LOG_H +#include #include #include /* for abort() */ @@ -74,7 +75,8 @@ const char *gpr_log_severity_string(gpr_log_severity severity); /* Log a message. It's advised to use GPR_xxx above to generate the context * for each message */ GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...); + const char *format, ...) + __attribute__((format(printf, 4, 5))); GPRAPI void gpr_log_message(const char *file, int line, gpr_log_severity severity, const char *message); diff --git a/include/grpc/support/string_util.h b/include/grpc/support/string_util.h index f981bc0db0..c68577b626 100644 --- a/include/grpc/support/string_util.h +++ b/include/grpc/support/string_util.h @@ -54,7 +54,8 @@ GPRAPI char *gpr_strdup(const char *src); On error, returns -1 and sets *strp to NULL. If the format string is bad, the result is undefined. */ -GPRAPI int gpr_asprintf(char **strp, const char *format, ...); +GPRAPI int gpr_asprintf(char **strp, const char *format, ...) + __attribute__((format(printf, 2, 3))); #ifdef __cplusplus } -- cgit v1.2.3