From 0c7b7a19e5a3c23fbb789238dcc4d43cd55387a0 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Mon, 19 Jun 2000 18:02:32 +0000 Subject: [PATCH] Use GCC's format attribute for better error checking when possible. --- lib/isc/include/isc/log.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 59ec435efd..7865eb5cc7 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: log.h,v 1.22 2000/06/01 17:20:40 tale Exp $ */ +/* $Id: log.h,v 1.23 2000/06/19 18:02:32 bwelling Exp $ */ #ifndef ISC_LOG_H #define ISC_LOG_H 1 @@ -29,6 +29,17 @@ ISC_LANG_BEGINDECLS +/* + * fmt is the location of the format string parameter + * args is the location of the first argument (or 0 for no argument checking) + * Note: the first parameter is 1, not 0 + */ +#ifdef __GNUC__ +#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((format (printf, fmt, args))) +#else +#define ISC_FORMAT_PRINTF(fmt, args) +#endif + /* * Severity levels, patterned after Unix's syslog levels. * @@ -498,7 +509,8 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, void isc_log_write(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *format, ...); + isc_logmodule_t *module, int level, const char *format, ...) +ISC_FORMAT_PRINTF(5, 6); /* * Write a message to the log channels. * @@ -517,7 +529,7 @@ isc_log_write(isc_log_t *lctx, isc_logcategory_t *category, * range of known ids, as estabished by isc_log_registercategories() * and isc_log_registermodules(). * - * level != ISC_LOG_DYNAMiC. ISC_LOG_DYNAMIC is used only to define + * level != ISC_LOG_DYNAMIC. ISC_LOG_DYNAMIC is used only to define * channels, and explicit debugging level must be identified for * isc_log_write() via ISC_LOG_DEBUG(level). * @@ -535,7 +547,8 @@ isc_log_write(isc_log_t *lctx, isc_logcategory_t *category, void isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category, isc_logmodule_t *module, int level, const char *format, - va_list args); + va_list args) +ISC_FORMAT_PRINTF(5, 0); /* * Write a message to the log channels. * @@ -554,7 +567,7 @@ isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category, * range of known ids, as estabished by isc_log_registercategories() * and isc_log_registermodules(). * - * level != ISC_LOG_DYNAMiC. ISC_LOG_DYNAMIC is used only to define + * level != ISC_LOG_DYNAMIC. ISC_LOG_DYNAMIC is used only to define * channels, and explicit debugging level must be identified for * isc_log_write() via ISC_LOG_DEBUG(level). * @@ -571,7 +584,8 @@ isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category, void isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *format, ...); + isc_logmodule_t *module, int level, const char *format, ...) +ISC_FORMAT_PRINTF(5, 6); /* * Write a message to the log channels, pruning duplicates that occur within * a configurable amount of seconds (see isc_log_[sg]etduplicateinterval). @@ -581,7 +595,8 @@ isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category, void isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category, isc_logmodule_t *module, int level, const char *format, - va_list args); + va_list args) +ISC_FORMAT_PRINTF(5, 0); /* * Write a message to the log channels, pruning duplicates that occur within * a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).