From 2540bb79b728cbfb88ed80e8ca2c2d8c0edc129b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Nov 2003 23:19:28 -0500 Subject: [PATCH] com_err.h, com_err.c: Use GCC attributes to mark com_err and default_com_err_proc as taking printf-style format strings. --- lib/et/ChangeLog | 6 ++++++ lib/et/com_err.c | 5 +++++ lib/et/com_err.h | 15 ++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog index 91a4752..6a68934 100644 --- a/lib/et/ChangeLog +++ b/lib/et/ChangeLog @@ -1,3 +1,9 @@ +2003-11-26 Theodore Ts'o + + * com_err.h, com_err.c: Use GCC attributes to mark com_err and + default_com_err_proc as taking printf-style format + strings. + 2003-11-22 Theodore Ts'o * com_err.h: Retore the type of n_msgs in the error_table diff --git a/lib/et/com_err.c b/lib/et/com_err.c index 76fdc78..77938b0 100644 --- a/lib/et/com_err.c +++ b/lib/et/com_err.c @@ -19,6 +19,11 @@ static void default_com_err_proc (const char *whoami, errcode_t code, const char *fmt, va_list args) + COM_ERR_ATTR((format(printf, 3, 0))); + +static void +default_com_err_proc (const char *whoami, errcode_t code, const + char *fmt, va_list args) { if (whoami) { fputs(whoami, stderr); diff --git a/lib/et/com_err.h b/lib/et/com_err.h index 60494c2..a49c5a5 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -10,6 +10,12 @@ #if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__) +#ifdef __GNUC__ +#define COM_ERR_ATTR(x) __attribute__(x) +#else +#define COM_ERR_ATTR(x) +#endif + #include typedef long errcode_t; @@ -19,12 +25,15 @@ struct error_table { long base; int n_msgs; }; - struct et_list; -extern void com_err (const char *, long, const char *, ...); +extern void com_err (const char *, long, const char *, ...) + COM_ERR_ATTR((format(printf, 3, 4))); + extern void com_err_va (const char *whoami, errcode_t code, const char *fmt, - va_list args); + va_list args) + COM_ERR_ATTR((format(printf, 3, 0))); + extern char const *error_message (long); extern void (*com_err_hook) (const char *, long, const char *, va_list); extern void (*set_com_err_hook (void (*) (const char *, long, -- 1.8.3.1