From: Kevin McCarthy Date: Tue, 21 Aug 2018 22:51:09 +0000 (-0700) Subject: Fix nested macro warning. X-Git-Tag: 2019-10-25~665^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a4af59fdc19084d5818c29e88132f9e169dbdd9;p=neomutt Fix nested macro warning. Pull the #if/#else outside of the snprintf in imap.c. On some platforms, snprintf is a macro itself, which leads to a warning about undefined behavior. Thanks to Charles Diza for pointing out the problem. --- diff --git a/imap/imap.c b/imap/imap.c index 05663d097..329c1af19 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2007,6 +2007,7 @@ static int imap_mbox_open(struct Context *ctx) int count = 0; struct ImapMbox mx, pmx; int rc; + const char *condstore; if (imap_parse_path(ctx->path, &mx)) { @@ -2078,14 +2079,15 @@ static int imap_mbox_open(struct Context *ctx) if (ImapCheckSubscribed) imap_exec(idata, "LSUB \"\" \"*\"", IMAP_CMD_QUEUE); - snprintf(bufout, sizeof(bufout), "%s %s%s", ctx->readonly ? "EXAMINE" : "SELECT", buf, #if USE_HCACHE - mutt_bit_isset(idata->capabilities, CONDSTORE) && ImapCondStore ? - " (CONDSTORE)" : - ""); -#else - ""); + if (mutt_bit_isset(idata->capabilities, CONDSTORE) && ImapCondStore) + condstore = " (CONDSTORE)"; + else #endif + condstore = ""; + + snprintf(bufout, sizeof(bufout), "%s %s%s", + ctx->readonly ? "EXAMINE" : "SELECT", buf, condstore); idata->state = IMAP_SELECTED;