]> granicus.if.org Git - neomutt/commitdiff
Fix nested macro warning.
authorKevin McCarthy <kevin@8t8.us>
Tue, 21 Aug 2018 22:51:09 +0000 (15:51 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 3 Sep 2018 15:38:30 +0000 (16:38 +0100)
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.

imap/imap.c

index 05663d0974cb1958bd7aa2bcd221b4bfa99b30d5..329c1af1979c806658d344db43850a404455aaae 100644 (file)
@@ -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;