commit df22514ced8e6a62e6456496b645609af0b07930
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Tue Aug 4 16:54:28 2020 +0200

    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 ...

 src/common.h      |  1 +
 src/drv_maildir.c | 12 +++++++-----
 src/util.c        | 15 +++++++++++----
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/common.h b/src/common.h
index a04e9f9..b15cc15 100644
--- a/src/common.h
+++ b/src/common.h
@@ -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 );
 
diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 984e36c..777280d 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -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;
                }
diff --git a/src/util.c b/src/util.c
index 93e6e7e..d506273 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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 )
 {


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to