[Groonga-commit] groonga/groonga [master] Use __attribute__ ((format(printf, x, y))) for checking format strings.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 5月 1日 (火) 10:04:12 JST


Susumu Yata	2012-05-01 10:04:12 +0900 (Tue, 01 May 2012)

  New Revision: da02c819e316890097da4a617bfd605367d3c1e9

  Log:
    Use __attribute__ ((format(printf, x, y))) for checking format strings.

  Modified files:
    include/groonga.h
    include/groonga/plugin.h
    lib/ctx.h

  Modified: include/groonga.h (+8 -1)
===================================================================
--- include/groonga.h    2012-04-29 08:46:39 +0900 (3ed4bc5)
+++ include/groonga.h    2012-05-01 10:04:12 +0900 (76ca58e)
@@ -2015,8 +2015,15 @@ struct _grn_logger_info {
 
 GRN_API grn_rc grn_logger_info_set(grn_ctx *ctx, const grn_logger_info *info);
 
+#ifdef __GNUC__
+#define GRN_ATTRIBUTE_PRINTF(fmt_pos) \
+  __attribute__ ((format(printf, fmt_pos, fmt_pos + 1)))
+#else
+#define GRN_ATTRIBUTE_PRINTF(fmt_pos)
+#endif /* __GNUC__ */
+
 GRN_API void grn_logger_put(grn_ctx *ctx, grn_log_level level,
-                            const char *file, int line, const char *func, const char *fmt, ...);
+                            const char *file, int line, const char *func, const char *fmt, ...) GRN_ATTRIBUTE_PRINTF(6);
 
 GRN_API int grn_logger_pass(grn_ctx *ctx, grn_log_level level);
 

  Modified: include/groonga/plugin.h (+1 -1)
===================================================================
--- include/groonga/plugin.h    2012-04-29 08:46:39 +0900 (cadef39)
+++ include/groonga/plugin.h    2012-05-01 10:04:12 +0900 (c7f265b)
@@ -89,7 +89,7 @@ void grn_plugin_free(grn_ctx *ctx, void *ptr, const char *file,
 void grn_plugin_set_error(grn_ctx *ctx, grn_log_level level,
                           grn_rc error_code,
                           const char *file, int line, const char *func,
-                          const char *format, ...);
+                          const char *format, ...) GRN_ATTRIBUTE_PRINTF(7);
 
 /*
   Don't call these functions directly. grn_plugin_backtrace() and

  Modified: lib/ctx.h (+1 -1)
===================================================================
--- lib/ctx.h    2012-04-29 08:46:39 +0900 (1cebf75)
+++ lib/ctx.h    2012-05-01 10:04:12 +0900 (eebea10)
@@ -417,7 +417,7 @@ GRN_API grn_rc grn_timeval_now(grn_ctx *ctx, grn_timeval *tv);
 GRN_API grn_rc grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf);
 grn_rc grn_str2timeval(const char *str, uint32_t str_len, grn_timeval *tv);
 
-GRN_API void grn_ctx_log(grn_ctx *ctx, const char *fmt, ...);
+GRN_API void grn_ctx_log(grn_ctx *ctx, const char *fmt, ...) GRN_ATTRIBUTE_PRINTF(2);
 void grn_ctx_qe_fin(grn_ctx *ctx);
 void grn_ctx_loader_clear(grn_ctx *ctx);
 void grn_log_reopen(grn_ctx *ctx);




Groonga-commit メーリングリストの案内
Back to archive index