summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-07-02 18:19:07 +0200
committerMartin Nagy <mnagy@redhat.com>2009-08-04 16:50:53 +0200
commit2f68fa390a61676a01cd82bc00e4a44867041299 (patch)
tree20adf39703857163ebd4870603433e398ac28904 /src
parenteb9fc0fb0fffdfc5b078d5dc68b73e5f4b28bdea (diff)
downloadldap_driver-2f68fa390a61676a01cd82bc00e4a44867041299.tar.gz
ldap_driver-2f68fa390a61676a01cd82bc00e4a44867041299.tar.xz
ldap_driver-2f68fa390a61676a01cd82bc00e4a44867041299.zip
Add annotations to printf-like functions
The ISC_FORMAT_PRINTF() macro will make sure that gcc checks if these functions are used correctly. Also fix bugs that were found along the way.
Diffstat (limited to 'src')
-rw-r--r--src/krb5_helper.c2
-rw-r--r--src/ldap_helper.c2
-rw-r--r--src/log.c2
-rw-r--r--src/log.h4
-rw-r--r--src/str.h3
5 files changed, 8 insertions, 5 deletions
diff --git a/src/krb5_helper.c b/src/krb5_helper.c
index c69a947..a52b412 100644
--- a/src/krb5_helper.c
+++ b/src/krb5_helper.c
@@ -137,7 +137,7 @@ get_krb5_tgt(isc_mem_t *mctx, const char *principal, const char *keyfile)
krberr = krb5_cc_resolve(context, str_buf(ccname), &ccache);
CHECK_KRB5(context, krberr,
- "Failed to resolve ccache name %s", ccname);
+ "Failed to resolve ccache name %s", str_buf(ccname));
/* get krb5_principal from string */
krberr = krb5_parse_name(context, principal, &kprincpw);
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index aa5af2d..432efcd 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -1524,7 +1524,7 @@ ldap_sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *sin)
in->len = 0;
ret = LDAP_OTHER;
}
- log_error("result: %s", in->result?in->result:"");
+ log_error("result: %s", (char *)(in->result?in->result:""));
}
return ret;
diff --git a/src/log.c b/src/log.c
index 3bcd767..bdf2745 100644
--- a/src/log.c
+++ b/src/log.c
@@ -19,6 +19,8 @@
#include <stdio.h>
+#include <isc/formatcheck.h>
+
#include <dns/log.h>
#include "log.h"
diff --git a/src/log.h b/src/log.h
index 00f772d..5446b04 100644
--- a/src/log.h
+++ b/src/log.h
@@ -42,7 +42,7 @@
log_func_va("exiting with %s", isc_result_totext(res))
/* Basic logging functions */
-void log_debug(int level, const char *format, ...);
-void log_error(const char *format, ...);
+void log_debug(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
+void log_error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
#endif /* !_LD_LOG_H_ */
diff --git a/src/str.h b/src/str.h
index 4fdf177..7746a25 100644
--- a/src/str.h
+++ b/src/str.h
@@ -20,6 +20,7 @@
#ifndef _LD_STR_H_
#define _LD_STR_H_
+#include <isc/formatcheck.h>
#include <isc/mem.h>
#define LD_MAX_SPLITS 256
@@ -55,7 +56,7 @@ isc_result_t str_cat_char_len(ld_string_t *dest, const char *src, size_t len);
isc_result_t str_cat_isc_region(ld_string_t *dest, const isc_region_t *region);
isc_result_t str_cat_isc_buffer(ld_string_t *dest, const isc_buffer_t *buffer);
isc_result_t str_cat(ld_string_t *dest, const ld_string_t *src);
-isc_result_t str_sprintf(ld_string_t *dest, const char *format, ...);
+isc_result_t str_sprintf(ld_string_t *dest, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
isc_result_t str_vsprintf(ld_string_t *dest, const char *format, va_list ap);
void str_toupper(ld_string_t *str);