turn maildir_again() into a proper varargs function

this is mostly to work around the fact that both gcc and clang won't
accept the format string declaration (i.e., will complain with
-Wformat-nonliteral) if the *called* function does not actually take a
va_list.

on the upside, it makes one caller cleaner. yay ...
This commit is contained in:
Oswald Buddenhagen 2020-08-04 16:54:28 +02:00
parent 234becf530
commit df22514ced
3 changed files with 19 additions and 9 deletions

View File

@ -130,6 +130,7 @@ void ATTR_PRINTFLIKE(1, 2) progress( const char *, ... );
void ATTR_PRINTFLIKE(1, 2) notice( const char *, ... );
void ATTR_PRINTFLIKE(1, 2) warn( const char *, ... );
void ATTR_PRINTFLIKE(1, 2) error( const char *, ... );
void ATTR_PRINTFLIKE(1, 0) vsys_error( const char *, va_list va );
void ATTR_PRINTFLIKE(1, 2) sys_error( const char *, ... );
void flushn( void );

View File

@ -1510,14 +1510,16 @@ maildir_rescan( maildir_store_t *ctx )
return DRV_OK;
}
static int
maildir_again( maildir_store_t *ctx, maildir_message_t *msg,
const char *err, const char *fn, const char *fn2 )
static int ATTR_PRINTFLIKE(3, 0)
maildir_again( maildir_store_t *ctx, maildir_message_t *msg, const char *err, ... )
{
int ret;
if (errno != ENOENT) {
sys_error( err, fn, fn2 );
va_list va;
va_start( va, err );
vsys_error( err, va );
va_end( va );
return DRV_BOX_BAD;
}
if ((ret = maildir_rescan( ctx )) != DRV_OK)
@ -1539,7 +1541,7 @@ maildir_fetch_msg( store_t *gctx, message_t *gmsg, msg_data_t *data,
nfsnprintf( buf, sizeof(buf), "%s/%s/%s", ctx->path, subdirs[gmsg->status & M_RECENT], msg->base );
if ((fd = open( buf, O_RDONLY )) >= 0)
break;
if ((ret = maildir_again( ctx, msg, "Cannot open %s", buf, 0 )) != DRV_OK) {
if ((ret = maildir_again( ctx, msg, "Cannot open %s", buf )) != DRV_OK) {
cb( ret, aux );
return;
}

View File

@ -149,19 +149,26 @@ error( const char *msg, ... )
}
void
sys_error( const char *msg, ... )
vsys_error( const char *msg, va_list va )
{
va_list va;
char buf[1024];
flushn();
va_start( va, msg );
if ((uint)vsnprintf( buf, sizeof(buf), msg, va ) >= sizeof(buf))
oob();
va_end( va );
perror( buf );
}
void
sys_error( const char *msg, ... )
{
va_list va;
va_start( va, msg );
vsys_error( msg, va );
va_end( va );
}
void
add_string_list_n( string_list_t **list, const char *str, int len )
{