From: Ralph Corderoy Date: Sat, 26 Aug 2017 14:01:35 +0000 (+0100) Subject: Add more NORETURN and CHECK_PRINTF function attributes. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/6015bb1f7aaa3e4f3c71c28219016ad951cefc04?ds=inline;hp=96b4a2bc9d64b14a9dfd2b432a5de2fc17044933 Add more NORETURN and CHECK_PRINTF function attributes. And fix the errors that the compiler then detects. --- diff --git a/h/netsec.h b/h/netsec.h index e381af86..b3018a24 100644 --- a/h/netsec.h +++ b/h/netsec.h @@ -201,7 +201,7 @@ int netsec_write(netsec_context *ns_context, const void *buffer, size_t size, */ int netsec_printf(netsec_context *ns_context, char **errstr, - const char *format, ...); + const char *format, ...) CHECK_PRINTF(3, 4); /* * Write bytes using a va_list argument. @@ -217,7 +217,7 @@ int netsec_printf(netsec_context *ns_context, char **errstr, */ int netsec_vprintf(netsec_context *ns_context, char **errstr, - const char *format, va_list ap); + const char *format, va_list ap) CHECK_PRINTF(3, 0); /* * Flush any buffered bytes to the network. @@ -418,4 +418,5 @@ int netsec_negotiate_tls(netsec_context *ns_context, char **errstr); * */ -void netsec_err(char **errstr, const char *format, ...); +void netsec_err(char **errstr, const char *format, ...) + CHECK_PRINTF(2, 3); diff --git a/h/prototypes.h b/h/prototypes.h index 2a1132c7..7caa3d0f 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -385,10 +385,10 @@ int sc_width(void); int build_form (char *, char *, int *, char *, char *, char *, char *, char *, char *); int sendsbr (char **, int, char *, char *, struct stat *, int, const char *); -int SOprintf (char *, ...); +int SOprintf (char *, ...) CHECK_PRINTF(1, 2); int what_now (char *, int, int, char *, char *, int, struct msgs *, char *, int, char *, int); -int WhatNow(int, char **); +int WhatNow(int, char **) NORETURN; /* Includes trailing NUL */ diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index 7808e1a7..fed756b7 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -59,9 +59,9 @@ static int sendmail_init (char *, int, int, int, int, const char *, const char *); static int rclient (char *, char *, char **); -static int sm_ierror (const char *fmt, ...); +static int sm_ierror (const char *fmt, ...) CHECK_PRINTF(1, 2); static int sm_nerror (char *); -static int smtalk (int time, char *fmt, ...); +static int smtalk (int time, char *fmt, ...) CHECK_PRINTF(2, 3); static int sm_wstream (char *, int); static int smhear (void); static char *EHLOset (char *); diff --git a/sbr/netsec.c b/sbr/netsec.c index 58cab1bb..a533042e 100644 --- a/sbr/netsec.c +++ b/sbr/netsec.c @@ -473,7 +473,7 @@ retry: */ if (count >= nsc->ns_inbufsize / 2) { - netsec_err(errstr, "Unable to find a line terminator after %d bytes", + netsec_err(errstr, "Unable to find a line terminator after %zu bytes", count); return NULL; } diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 909d21de..88dfb153 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -125,7 +125,8 @@ static int fix_filename_encoding (CT); static int write_content (CT, const char *, char *, FILE *, int, int); static void set_text_ctparams(CT, char *, int); static int remove_file (const char *); -static void report (char *, char *, char *, char *, ...); +static void report (char *, char *, char *, char *, ...) + CHECK_PRINTF(4, 5); static void pipeser (int); diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 550af614..1efc1e6a 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -327,7 +327,7 @@ static void putch (char, unsigned long); static void intrser (int); static void pipeser (int); static void quitser (int); -static void mhladios (char *, char *, ...); +static void mhladios (char *, char *, ...) CHECK_PRINTF(2, 3); static void mhldone (int); static void filterbody (struct mcomp *, char *, int, int, m_getfld_state_t); @@ -1305,7 +1305,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) if ((ovtxt = c1->c_ovtxt ? c1->c_ovtxt : global.c_ovtxt) == NULL) ovtxt = ""; if (wid < ovoff + strlen (ovtxt) + 5) - mhladios (NULL, "component: %s width(%d) too small for overflow(%d)", + mhladios(NULL, "component: %s width(%d) too small for overflow(%zu)", c1->c_name, wid, ovoff + strlen (ovtxt) + 5); onelp = NULL; diff --git a/uip/mhmisc.c b/uip/mhmisc.c index 53406c03..d987f693 100644 --- a/uip/mhmisc.c +++ b/uip/mhmisc.c @@ -32,7 +32,7 @@ static char *errs = NULL; int part_ok (CT); int part_exact(CT ct); int type_ok (CT, int); -void content_error (char *, CT, char *, ...); +void content_error (char *, CT, char *, ...) CHECK_PRINTF(3, 4); void flush_errors (void); diff --git a/uip/popsbr.c b/uip/popsbr.c index ca6599e0..d4a65212 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -24,11 +24,12 @@ static netsec_context *nsc = NULL; * static prototypes */ -static int command(const char *, ...); +static int command(const char *, ...) CHECK_PRINTF(1, 2); static int multiline(void); -static int traverse (int (*)(void *, char *), void *closure, const char *, ...); -static int vcommand(const char *, va_list); +static int traverse(int (*)(void *, char *), void *closure, + const char *, ...) CHECK_PRINTF(3, 4); +static int vcommand(const char *, va_list) CHECK_PRINTF(1, 0); static int pop_getline (char *, int, netsec_context *); static int pop_sasl_callback(enum sasl_message_type, unsigned const char *, unsigned int, unsigned char **, unsigned int *, diff --git a/uip/post.c b/uip/post.c index 08e52426..11170615 100644 --- a/uip/post.c +++ b/uip/post.c @@ -306,7 +306,7 @@ static void sigon (void); static void sigoff (void); static void p_refile (char *); static void fcc (char *, char *); -static void die (char *, char *, ...); +static void die (char *, char *, ...) CHECK_PRINTF(2, 3); static void post (char *, int, int, int, char *, int, char *); static void do_text (char *file, int fd); static void do_an_address (struct mailname *, int); diff --git a/uip/slocal.c b/uip/slocal.c index b249dc4b..e136f101 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -172,9 +172,9 @@ static int usr_folder (int, char *); static void alrmser (int); static void get_sender (char *, char **); static int copy_message (int, char *, int); -static void verbose_printf (char *fmt, ...); -static void adorn (char *, char *, ...); -static void debug_printf (char *fmt, ...); +static void verbose_printf (char *fmt, ...) CHECK_PRINTF(1, 2); +static void adorn (char *, char *, ...) CHECK_PRINTF(2, 3); +static void debug_printf (char *fmt, ...) CHECK_PRINTF(1, 2); static int suppress_duplicates (int, char *); static char *trim (char *); @@ -802,12 +802,12 @@ parse (int fd) p->p_value = getcpy (q ? q->p_value : ""); p->p_flags &= ~P_CHK; if (debug) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } if (debug) { for (p = hdrs; p->p_name; p++) - debug_printf ("hdrs[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("hdrs[%ld]: name=\"%s\" value=\"%s\"\n", p - hdrs, p->p_name, p->p_value ? trim(p->p_value) : ""); } @@ -887,7 +887,7 @@ glob (int fd) if (debug) { for (p = vars; p->p_name; p++) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } }