]> granicus.if.org Git - mutt/commitdiff
Fix nested macro warning.
authorKevin McCarthy <kevin@8t8.us>
Tue, 21 Aug 2018 22:51:09 +0000 (15:51 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 21 Aug 2018 22:51:09 +0000 (15:51 -0700)
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 f1997ac8b13757b5264b0578053be900d658f999..05e24f2671a79b87641f7fae998613c68e9bb186 100644 (file)
@@ -604,6 +604,7 @@ static int imap_open_mailbox (CONTEXT* ctx)
   int count = 0;
   IMAP_MBOX mx, pmx;
   int rc;
+  const char *condstore;
 
   if (imap_parse_path (ctx->path, &mx))
   {
@@ -669,15 +670,17 @@ static int imap_open_mailbox (CONTEXT* ctx)
     imap_status (Postponed, 1);
   FREE (&pmx.mbox);
 
-  snprintf (bufout, sizeof (bufout), "%s %s%s",
-            ctx->readonly ? "EXAMINE" : "SELECT",
-            buf,
 #if USE_HCACHE
-            mutt_bit_isset (idata->capabilities, CONDSTORE) &&
-            option (OPTIMAPCONDSTORE) ? " (CONDSTORE)" : "");
-#else
-            "");
+  if (mutt_bit_isset (idata->capabilities, CONDSTORE) &&
+      option (OPTIMAPCONDSTORE))
+    condstore = " (CONDSTORE)";
+  else
 #endif
+    condstore = "";
+
+  snprintf (bufout, sizeof (bufout), "%s %s%s",
+            ctx->readonly ? "EXAMINE" : "SELECT",
+            buf, condstore);
 
   idata->state = IMAP_SELECTED;