]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: Disable Visual Studio warning "conditional expression is constant"
authorJay Satiro <raysatiro@yahoo.com>
Sat, 30 Nov 2019 08:29:36 +0000 (03:29 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Mon, 2 Dec 2019 00:01:02 +0000 (19:01 -0500)
- Disable warning C4127 "conditional expression is constant" globally
  in curl_setup.h for when building with Microsoft's compiler.

This mainly affects building with the Visual Studio project files found
in the projects dir.

Prior to this change the cmake and winbuild build systems already
disabled 4127 globally for when building with Microsoft's compiler.
Also, 4127 was already disabled for all build systems in the limited
circumstance of the WHILE_FALSE macro which disabled the warning
specifically for while(0). This commit removes the WHILE_FALSE macro and
all other cruft in favor of disabling globally in curl_setup.

Background:

We have various macros that cause 0 or 1 to be evaluated, which would
cause warning C4127 in Visual Studio. For example this causes it:

    #define Curl_resolver_asynch() 1

Full behavior is not clearly defined and inconsistent across versions.
However it is documented that since VS 2015 Update 3 Microsoft has
addressed this somewhat but not entirely, not warning on while(true) for
example.

Prior to this change some C4127 warnings occurred when I built with
Visual Studio using the generated projects in the projects dir.

Closes https://github.com/curl/curl/pull/4658

32 files changed:
lib/CMakeLists.txt
lib/cookie.c
lib/curl_multibyte.h
lib/curl_setup.h
lib/curl_setup_once.h
lib/doh.c
lib/http2.c
lib/ldap.c
lib/memdebug.h
lib/mprintf.c
lib/select.h
lib/sendf.c
lib/sha256.c
lib/telnet.c
lib/transfer.c
lib/url.c
lib/vquic/ngtcp2.c
lib/vquic/quiche.c
lib/vssh/libssh.c
lib/vtls/nss.c
lib/vtls/openssl.c
src/tool_doswin.c
src/tool_easysrc.c
src/tool_getparam.c
src/tool_metalink.c
src/tool_setopt.c
src/tool_setopt.h
tests/libtest/CMakeLists.txt
tests/libtest/test.h
tests/server/CMakeLists.txt
tests/unit/curlcheck.h
winbuild/MakefileBuild.vc

index eca9a8af934e18a66623bb7a05f8252d9d005484..a9c90b66507b14b1a271506cfa923570874b80ff 100644 (file)
@@ -20,7 +20,6 @@ list(APPEND HHEADERS
 
 if(MSVC)
   list(APPEND CSOURCES libcurl.rc)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
 endif()
 
 # SET(CSOURCES
index c9e420ad4b3404405e4278b946cc98d9b7c78cf6..0091132aa34cd318ab3720d695dc0e8b6402a79e 100644 (file)
@@ -1227,7 +1227,7 @@ static int cookie_sort_ct(const void *p1, const void *p2)
       if(!d->field)                      \
         goto fail;                       \
     }                                    \
-  } WHILE_FALSE
+  } while(0)
 
 static struct Cookie *dup_cookie(struct Cookie *src)
 {
index e30008be4fca6df0d21505cb2bc4e39481b8d77e..5225e1811ba2d9c6f8e753d30175e8fdd380f5d9 100644 (file)
@@ -62,7 +62,7 @@ char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w);
 #define Curl_convert_UTF8_to_tchar(ptr) Curl_convert_UTF8_to_wchar((ptr))
 #define Curl_convert_tchar_to_UTF8(ptr) Curl_convert_wchar_to_UTF8((ptr))
 #define Curl_unicodefree(ptr) \
-  do {if((ptr)) {free((ptr)); (ptr) = NULL;}} WHILE_FALSE
+  do {if((ptr)) {free((ptr)); (ptr) = NULL;}} while(0)
 
 typedef union {
   unsigned short       *tchar_ptr;
@@ -76,7 +76,7 @@ typedef union {
 #define Curl_convert_UTF8_to_tchar(ptr) (ptr)
 #define Curl_convert_tchar_to_UTF8(ptr) (ptr)
 #define Curl_unicodefree(ptr) \
-  do {(ptr) = NULL;} WHILE_FALSE
+  do {(ptr) = NULL;} while(0)
 
 typedef union {
   char                *tchar_ptr;
index b4ba92931bd9b507881cfa1e48c5f6d4d7b13e97..cc36e28ec8b514863bf5aac894c1506707bb652b 100644 (file)
 #define CURL_NO_OLDIES
 #endif
 
+/*
+ * Disable Visual Studio warnings:
+ * 4127 "conditional expression is constant"
+ */
+#ifdef _MSC_VER
+#pragma warning(disable:4127)
+#endif
+
 /*
  * Define WIN32 when build target is Win32 API
  */
@@ -714,7 +722,7 @@ int netware_init(void);
  */
 
 #ifndef Curl_nop_stmt
-#  define Curl_nop_stmt do { } WHILE_FALSE
+#  define Curl_nop_stmt do { } while(0)
 #endif
 
 /*
index 413ccea917300e468c80d7771425ef20d6d9b629..9d504cb6e3da23d494bb36af3ef6a0089f326d48 100644 (file)
@@ -329,27 +329,6 @@ struct timeval {
 
 #include "curl_ctype.h"
 
-/*
- * Macro WHILE_FALSE may be used to build single-iteration do-while loops,
- * avoiding compiler warnings. Mostly intended for other macro definitions.
- */
-
-#define WHILE_FALSE  while(0)
-
-#if defined(_MSC_VER) && !defined(__POCC__)
-#  undef WHILE_FALSE
-#  if (_MSC_VER < 1500)
-#    define WHILE_FALSE  while(1, 0)
-#  else
-#    define WHILE_FALSE \
-__pragma(warning(push)) \
-__pragma(warning(disable:4127)) \
-while(0) \
-__pragma(warning(pop))
-#  endif
-#endif
-
-
 /*
  * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
  */
@@ -387,7 +366,7 @@ typedef int sig_atomic_t;
 #ifdef DEBUGBUILD
 #define DEBUGF(x) x
 #else
-#define DEBUGF(x) do { } WHILE_FALSE
+#define DEBUGF(x) do { } while(0)
 #endif
 
 
@@ -398,7 +377,7 @@ typedef int sig_atomic_t;
 #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
 #define DEBUGASSERT(x) assert(x)
 #else
-#define DEBUGASSERT(x) do { } WHILE_FALSE
+#define DEBUGASSERT(x) do { } while(0)
 #endif
 
 
index 1588a7f32f5573fcc6ed97ad161a9cf8afbc6a2e..c8735a64810c8493472aaea58e616839fdac8ece 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -218,7 +218,7 @@ do {                                      \
   result = curl_easy_setopt(doh, x, y);   \
   if(result)                              \
     goto error;                           \
-} WHILE_FALSE
+} while(0)
 
 static CURLcode dohprobe(struct Curl_easy *data,
                          struct dnsprobe *p, DNStype dnstype,
index 6315fc401415ea77ea46c454f80f66f34555bc78..b741aed483cd10272fef93e299aa8361e44decff 100644 (file)
@@ -68,7 +68,7 @@
 #ifdef DEBUG_HTTP2
 #define H2BUGF(x) x
 #else
-#define H2BUGF(x) do { } WHILE_FALSE
+#define H2BUGF(x) do { } while(0)
 #endif
 
 
index af3d61c57e7163620f24a6ce638897b7146b63a9..771edb4e984d03616b12484469c72c6310102c12 100644 (file)
@@ -112,7 +112,7 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp);
   #define LDAP_TRACE(x)   do { \
                             _ldap_trace("%u: ", __LINE__); \
                             _ldap_trace x; \
-                          } WHILE_FALSE
+                          } while(0)
 
   static void _ldap_trace(const char *fmt, ...);
 #else
index 5236f60fa544c1b690b779fcc539c1384aae0f7f..7ca44262690e069a0ab89582b3d1d0b5f1e0d2b7 100644 (file)
@@ -169,6 +169,6 @@ CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
  */
 
 #define Curl_safefree(ptr) \
-  do { free((ptr)); (ptr) = NULL;} WHILE_FALSE
+  do { free((ptr)); (ptr) = NULL;} while(0)
 
 #endif /* HEADER_CURL_MEMDEBUG_H */
index 4234e1bf4533d924de5e7563dbf7ac78cf21b8a4..bc0091351dd5bd1d6faebf84737a259f830fb1f7 100644 (file)
@@ -104,7 +104,7 @@ static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
       done++; \
     else \
      return done; /* return immediately on failure */ \
-  } WHILE_FALSE
+  } while(0)
 
 /* Data type to read from the arglist */
 typedef enum {
index f5652a74f7d4f521f4d80fc995fc5be0dfb5427b..687ab164c428bfbc4ab85edcdcaef103ba6d163f 100644 (file)
@@ -109,7 +109,7 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
     SET_SOCKERRNO(EINVAL); \
     return -1; \
   } \
-} WHILE_FALSE
+} while(0)
 #endif
 
 #endif /* HEADER_CURL_SELECT_H */
index 000fbb164165fb93460a7131baed4a01b32aee91..6c38b04b2373238004b2cf101bf085e6258f8bce 100644 (file)
@@ -224,7 +224,7 @@ bool Curl_recv_has_postponed_data(struct connectdata *conn, int sockindex)
   (void)sockindex;
   return false;
 }
-#define pre_receive_plain(c,n) do {} WHILE_FALSE
+#define pre_receive_plain(c,n) do {} while(0)
 #define get_pre_recved(c,n,b,l) 0
 #endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
 
index b467ee558b40c1b14bf9dda2e4d67ee5eb5d9e56..bcaaeae30867f89d36bdfdb64e2c9f9149c4d395 100644 (file)
@@ -58,7 +58,7 @@ do {                                                                \
   (a)[1] = (unsigned char)((((unsigned long) (val)) >> 16) & 0xff); \
   (a)[2] = (unsigned char)((((unsigned long) (val)) >> 8) & 0xff);  \
   (a)[3] = (unsigned char)(((unsigned long) (val)) & 0xff);         \
-} WHILE_FALSE;
+} while(0)
 
 #ifdef HAVE_LONGLONG
 #define WPA_PUT_BE64(a, val)                                    \
@@ -71,7 +71,7 @@ do {                                                            \
   (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16);  \
   (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8);   \
   (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
-} WHILE_FALSE;
+} while(0)
 #else
 #define WPA_PUT_BE64(a, val)                                  \
 do {                                                          \
index 955255c36c2e5bf4565933290de6f40e8853d170..4bf4c652c21fc6e42a63cdbf73d77fc86285091d 100644 (file)
   do {                                                  \
     x->subend = x->subpointer;                          \
     CURL_SB_CLEAR(x);                                   \
-  } WHILE_FALSE
+  } while(0)
 #define CURL_SB_ACCUM(x,c)                                      \
   do {                                                          \
     if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer)))   \
       *x->subpointer++ = (c);                                   \
-  } WHILE_FALSE
+  } while(0)
 
 #define  CURL_SB_GET(x) ((*x->subpointer++)&0xff)
 #define  CURL_SB_LEN(x) (x->subend - x->subpointer)
index f16e29bdb0fae1ac097ad16fff41598084a8a697..ead8b36db9bd1700425271b451322c541b312faa 100644 (file)
@@ -1177,7 +1177,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
     }
 
 
-  } WHILE_FALSE; /* just to break out from! */
+  } while(0); /* just to break out from! */
 
   return CURLE_OK;
 }
index 99a8b13599b2d9cf65397bf9e1f9a96cf6f73863..1af9f90e0ab93a921b887e6f417673e7d93db412 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -674,7 +674,7 @@ static void conn_reset_all_postponed_data(struct connectdata *conn)
 }
 #else  /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
 /* Use "do-nothing" macro instead of function when workaround not used */
-#define conn_reset_all_postponed_data(c) do {} WHILE_FALSE
+#define conn_reset_all_postponed_data(c) do {} while(0)
 #endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
 
 
index 7d8b98e90ca7eef38d70e4b8893da9f1732b5318..c39dba23a141df8045436102e7697c5ec0e31659 100644 (file)
@@ -49,7 +49,7 @@
 #ifdef DEBUG_HTTP3
 #define H3BUGF(x) x
 #else
-#define H3BUGF(x) do { } WHILE_FALSE
+#define H3BUGF(x) do { } while(0)
 #endif
 
 /*
index b2c98d255a876e6d7caba916ccf223811400e91e..e2f43237fa8ccc5a0c2c0bb00758a3a73fd337cd 100644 (file)
@@ -45,7 +45,7 @@
 #ifdef DEBUG_HTTP3
 #define H3BUGF(x) x
 #else
-#define H3BUGF(x) do { } WHILE_FALSE
+#define H3BUGF(x) do { } while(0)
 #endif
 
 #define QUIC_MAX_STREAMS (256*1024)
index ef874524654fadc9146846a88197cfa688ac3f4c..070879d94631b9e824ac55c9a28ca0c839e0e605 100644 (file)
@@ -98,7 +98,7 @@
 /* A recent macro provided by libssh. Or make our own. */
 #ifndef SSH_STRING_FREE_CHAR
 #define SSH_STRING_FREE_CHAR(x) \
-    do { if((x) != NULL) { ssh_string_free_char(x); x = NULL; } } WHILE_FALSE
+    do { if((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
 #endif
 
 /* Local functions: */
index a375f00da2a77d52247ea00d074e37e014d268ca..ef51b0d9122f232d3828d44f98210bb0c6030c55 100644 (file)
@@ -113,7 +113,7 @@ typedef struct {
   ptr->type = (_type);                                      \
   ptr->pValue = (_val);                                     \
   ptr->ulValueLen = (_len);                                 \
-} WHILE_FALSE
+} while(0)
 
 #define CERT_NewTempCertificate __CERT_NewTempCertificate
 
index 32d0e449e7215d0c50011ae7f686395d61a73797..7c6854d1f80de27159362372acea803a496dad15 100644 (file)
@@ -3077,7 +3077,7 @@ do {                              \
   Curl_ssl_push_certinfo_len(data, _num, _label, ptr, info_len); \
   if(1 != BIO_reset(mem))                                        \
     break;                                                       \
-} WHILE_FALSE
+} while(0)
 
 static void pubkey_show(struct Curl_easy *data,
                         BIO *mem,
@@ -3109,7 +3109,7 @@ do {                              \
   if(_type->_name) { \
     pubkey_show(data, mem, _num, #_type, #_name, _type->_name); \
   } \
-} WHILE_FALSE
+} while(0)
 #endif
 
 static int X509V3_ext(struct Curl_easy *data,
index 779a3cb8fd90a1faec947a935200c9bea119c903..a64a81633fe4a16ac88185c4defebb353601868e 100644 (file)
 
 #include "memdebug.h" /* keep this as LAST include */
 
-/*
- * Macros ALWAYS_TRUE and ALWAYS_FALSE are used to avoid compiler warnings.
- */
-
-#define ALWAYS_TRUE   (1)
-#define ALWAYS_FALSE  (0)
-
-#if defined(_MSC_VER) && !defined(__POCC__)
-#  undef ALWAYS_TRUE
-#  undef ALWAYS_FALSE
-#  if (_MSC_VER < 1500)
-#    define ALWAYS_TRUE   (0, 1)
-#    define ALWAYS_FALSE  (1, 0)
-#  else
-#    define ALWAYS_TRUE \
-__pragma(warning(push)) \
-__pragma(warning(disable:4127)) \
-(1) \
-__pragma(warning(pop))
-#    define ALWAYS_FALSE \
-__pragma(warning(push)) \
-__pragma(warning(disable:4127)) \
-(0) \
-__pragma(warning(pop))
-#  endif
-#endif
-
 #ifdef WIN32
 #  undef  PATH_MAX
 #  define PATH_MAX MAX_PATH
@@ -79,9 +52,9 @@ __pragma(warning(pop))
 #endif
 
 #ifdef WIN32
-#  define _use_lfn(f) ALWAYS_TRUE   /* long file names always available */
+#  define _use_lfn(f) (1)   /* long file names always available */
 #elif !defined(__DJGPP__) || (__DJGPP__ < 2)  /* DJGPP 2.0 has _use_lfn() */
-#  define _use_lfn(f) ALWAYS_FALSE  /* long file names never available */
+#  define _use_lfn(f) (0)  /* long file names never available */
 #elif defined(__DJGPP__)
 #  include <fcntl.h>                /* _use_lfn(f) prototype */
 #endif
index cb30e404bb64e46c24f9d713865c612a3b7ac41f..87ad4bbaa8bd6f96a61873e5b96c3eac8a6fb389 100644 (file)
@@ -123,7 +123,7 @@ CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
   return ret;
 }
 
-#define CHKRET(v) do {CURLcode ret = (v); if(ret) return ret;} WHILE_FALSE
+#define CHKRET(v) do {CURLcode ret = (v); if(ret) return ret;} while(0)
 
 CURLcode easysrc_init(void)
 {
index 3efc23e1e569f630ddb7c421c11f7951ba01f69a..a7bcdafacc440195e2a11036005856766f25ec88 100644 (file)
@@ -58,7 +58,7 @@
     if(!(*(str)))          \
       return PARAM_NO_MEM; \
   } \
-} WHILE_FALSE
+} while(0)
 
 struct LongShort {
   const char *letter; /* short name option */
index 889da4bffef92345cfcb289cd6fc80b6fe940c14..6d62f2d9380e61c7276f5d8bd5ea6f64cc5109b6 100644 (file)
@@ -119,7 +119,7 @@ struct win32_crypto_hash {
     *(str) = strdup((val)); \
   if(!(val)) \
     return PARAM_NO_MEM; \
-} WHILE_FALSE
+} while(0)
 
 #if defined(USE_OPENSSL)
 /* Functions are already defined */
index 4c98d9057fed27402c518892d73eedd9741e93f6..e56af1317fafae8bc97176c73b8d87f25288e09a 100644 (file)
@@ -181,18 +181,18 @@ static const NameValue setopt_nv_CURLNONZERODEFAULTS[] = {
   ret = easysrc_add args; \
   if(ret) \
     goto nomem; \
-} WHILE_FALSE
+} while(0)
 #define ADDF(args) do { \
   ret = easysrc_addf args; \
   if(ret) \
     goto nomem; \
-} WHILE_FALSE
+} while(0)
 #define NULL_CHECK(p) do { \
   if(!p) { \
     ret = CURLE_OUT_OF_MEMORY; \
     goto nomem; \
   } \
-} WHILE_FALSE
+} while(0)
 
 #define DECL0(s) ADD((&easysrc_decl, s))
 #define DECL1(f,a) ADDF((&easysrc_decl, f,a))
index 63401337faf4ed3326dd42bdd0f88a256d6d1b0e..48e9e818de6c4ad63fb96f3e92ce247f87c82215 100644 (file)
@@ -35,7 +35,7 @@
       if(result)                                \
         break;                                  \
     }                                           \
-  } WHILE_FALSE
+  } while(0)
 
 /* allow removed features to simulate success: */
 bool tool_setopt_skip(CURLoption tag);
index aa70d053d04699b8e144d46f3dfe8913fde97b49..6b14ad3e328d36dbb08ac974bd1dfbdc7ee9f9d6 100644 (file)
@@ -1,9 +1,5 @@
 set(TARGET_LABEL_PREFIX "Test ")
 
-if(MSVC)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
-endif()
-
 function(setup_test TEST_NAME)          # ARGN are the files in the test
   add_executable( ${TEST_NAME} ${ARGN} )
   string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
index 3c8323de4c64d4549b2a8658a4aa2a0d46b0e627..fd88365c6902c9a0431395f1b08b579796237b7e 100644 (file)
@@ -131,7 +131,7 @@ extern int unitfail;
     fprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \
     res = TEST_ERR_EASY_INIT;                                     \
   }                                                               \
-} WHILE_FALSE
+} while(0)
 
 #define res_easy_init(A) \
   exe_easy_init((A), (__FILE__), (__LINE__))
@@ -140,7 +140,7 @@ extern int unitfail;
   exe_easy_init((A), (Y), (Z));   \
   if(res)                         \
     goto test_cleanup;            \
-} WHILE_FALSE
+} while(0)
 
 #define easy_init(A) \
   chk_easy_init((A), (__FILE__), (__LINE__))
@@ -152,7 +152,7 @@ extern int unitfail;
     fprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \
     res = TEST_ERR_MULTI_INIT;                                     \
   }                                                                \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_init(A) \
   exe_multi_init((A), (__FILE__), (__LINE__))
@@ -161,7 +161,7 @@ extern int unitfail;
   exe_multi_init((A), (Y), (Z));   \
   if(res)                          \
     goto test_cleanup;             \
-} WHILE_FALSE
+} while(0)
 
 #define multi_init(A) \
   chk_multi_init((A), (__FILE__), (__LINE__))
@@ -176,7 +176,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_easy_strerror(ec));    \
     res = (int)ec;                                         \
   }                                                        \
-} WHILE_FALSE
+} while(0)
 
 #define res_easy_setopt(A, B, C) \
   exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
@@ -185,7 +185,7 @@ extern int unitfail;
   exe_easy_setopt((A), (B), (C), (Y), (Z)); \
   if(res)                                   \
     goto test_cleanup;                      \
-} WHILE_FALSE
+} while(0)
 
 #define easy_setopt(A, B, C) \
   chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
@@ -200,7 +200,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_multi_strerror(ec));    \
     res = (int)ec;                                          \
   }                                                         \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_setopt(A,B,C) \
   exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
@@ -209,7 +209,7 @@ extern int unitfail;
   exe_multi_setopt((A), (B), (C), (Y), (Z)); \
   if(res)                                    \
     goto test_cleanup;                       \
-} WHILE_FALSE
+} while(0)
 
 #define multi_setopt(A,B,C) \
   chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
@@ -224,7 +224,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_multi_strerror(ec));     \
     res = (int)ec;                                           \
   }                                                          \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_add_handle(A, B) \
   exe_multi_add_handle((A), (B), (__FILE__), (__LINE__))
@@ -233,7 +233,7 @@ extern int unitfail;
   exe_multi_add_handle((A), (B), (Y), (Z));   \
   if(res)                                     \
     goto test_cleanup;                        \
-} WHILE_FALSE
+} while(0)
 
 #define multi_add_handle(A, B) \
   chk_multi_add_handle((A), (B), (__FILE__), (__LINE__))
@@ -248,7 +248,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_multi_strerror(ec));        \
     res = (int)ec;                                              \
   }                                                             \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_remove_handle(A, B) \
   exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
@@ -257,7 +257,7 @@ extern int unitfail;
   exe_multi_remove_handle((A), (B), (Y), (Z));   \
   if(res)                                        \
     goto test_cleanup;                           \
-} WHILE_FALSE
+} while(0)
 
 
 #define multi_remove_handle(A, B) \
@@ -279,7 +279,7 @@ extern int unitfail;
             (Y), (Z), (int)*((B)));                              \
     res = TEST_ERR_NUM_HANDLES;                                  \
   }                                                              \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_perform(A, B) \
   exe_multi_perform((A), (B), (__FILE__), (__LINE__))
@@ -288,7 +288,7 @@ extern int unitfail;
   exe_multi_perform((A), (B), (Y), (Z));   \
   if(res)                                  \
     goto test_cleanup;                     \
-} WHILE_FALSE
+} while(0)
 
 #define multi_perform(A,B) \
   chk_multi_perform((A), (B), (__FILE__), (__LINE__))
@@ -309,7 +309,7 @@ extern int unitfail;
             (Y), (Z), (int)*((E)));                                  \
     res = TEST_ERR_NUM_HANDLES;                                      \
   }                                                                  \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_fdset(A, B, C, D, E) \
   exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -318,7 +318,7 @@ extern int unitfail;
     exe_multi_fdset((A), (B), (C), (D), (E), (Y), (Z)); \
     if(res)                                             \
       goto test_cleanup;                                \
-  } WHILE_FALSE
+  } while(0)
 
 #define multi_fdset(A, B, C, D, E) \
   chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -339,7 +339,7 @@ extern int unitfail;
             (Y), (Z), (long)*((B)));                         \
     res = TEST_ERR_BAD_TIMEOUT;                              \
   }                                                          \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_timeout(A, B) \
   exe_multi_timeout((A), (B), (__FILE__), (__LINE__))
@@ -348,7 +348,7 @@ extern int unitfail;
     exe_multi_timeout((A), (B), (Y), (Z)); \
     if(res)                                \
       goto test_cleanup;                   \
-  } WHILE_FALSE
+  } while(0)
 
 #define multi_timeout(A, B) \
   chk_multi_timeout((A), (B), (__FILE__), (__LINE__))
@@ -369,7 +369,7 @@ extern int unitfail;
             (Y), (Z), (int)*((E)));                                 \
     res = TEST_ERR_NUM_HANDLES;                                     \
   }                                                                 \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_poll(A, B, C, D, E) \
   exe_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -378,7 +378,7 @@ extern int unitfail;
   exe_multi_poll((A), (B), (C), (D), (E), (Y), (Z)); \
   if(res)                                            \
     goto test_cleanup;                               \
-} WHILE_FALSE
+} while(0)
 
 #define multi_poll(A, B, C, D, E) \
   chk_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -393,7 +393,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
     res = (int)ec;                                       \
   }                                                      \
-} WHILE_FALSE
+} while(0)
 
 #define res_multi_wakeup(A) \
   exe_multi_wakeup((A), (__FILE__), (__LINE__))
@@ -402,7 +402,7 @@ extern int unitfail;
   exe_multi_wakeup((A), (Y), (Z));     \
   if(res)                              \
     goto test_cleanup;                 \
-} WHILE_FALSE
+} while(0)
 
 #define multi_wakeup(A) \
   chk_multi_wakeup((A), (__FILE__), (__LINE__))
@@ -418,7 +418,7 @@ extern int unitfail;
               (Y), (Z), ec, strerror(ec));                      \
       res = TEST_ERR_SELECT;                                    \
     }                                                           \
-  } WHILE_FALSE
+  } while(0)
 
 #define res_select_test(A, B, C, D, E) \
   exe_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -427,7 +427,7 @@ extern int unitfail;
     exe_select_test((A), (B), (C), (D), (E), (Y), (Z)); \
     if(res)                                             \
       goto test_cleanup;                                \
-  } WHILE_FALSE
+  } while(0)
 
 #define select_test(A, B, C, D, E) \
   chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
@@ -436,7 +436,7 @@ extern int unitfail;
 
 #define start_test_timing() do { \
   tv_test_start = tutil_tvnow(); \
-} WHILE_FALSE
+} while(0)
 
 #define exe_test_timedout(Y,Z) do {                                    \
   if(tutil_tvdiff(tutil_tvnow(), tv_test_start) > TEST_HANG_TIMEOUT) { \
@@ -444,7 +444,7 @@ extern int unitfail;
                     "that it would have run forever.\n", (Y), (Z));    \
     res = TEST_ERR_RUNS_FOREVER;                                       \
   }                                                                    \
-} WHILE_FALSE
+} while(0)
 
 #define res_test_timedout() \
   exe_test_timedout((__FILE__), (__LINE__))
@@ -453,7 +453,7 @@ extern int unitfail;
     exe_test_timedout(Y, Z);         \
     if(res)                          \
       goto test_cleanup;             \
-  } WHILE_FALSE
+  } while(0)
 
 #define abort_on_test_timeout() \
   chk_test_timedout((__FILE__), (__LINE__))
@@ -468,7 +468,7 @@ extern int unitfail;
             (Y), (Z), (int)ec, curl_easy_strerror(ec)); \
     res = (int)ec;                                      \
   }                                                     \
-} WHILE_FALSE
+} while(0)
 
 #define res_global_init(A) \
   exe_global_init((A), (__FILE__), (__LINE__))
@@ -477,7 +477,7 @@ extern int unitfail;
     exe_global_init((A), (Y), (Z));   \
     if(res)                           \
       return res;                     \
-  } WHILE_FALSE
+  } while(0)
 
 /* global_init() is different than other macros. In case of
    failure it 'return's instead of going to 'test_cleanup'. */
index 78b9b7029727ff9ced9e8611705915d705148790..d532436085c5a9f9d6c3dbb6ca58cdbe99004fa1 100644 (file)
@@ -1,7 +1,7 @@
 set(TARGET_LABEL_PREFIX "Test server ")
 
 if(MSVC)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4306")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4306")
 endif()
 
 function(SETUP_EXECUTABLE TEST_NAME)    # ARGN are the files in the test
index c358afa6eb9a4c514ad8e41fca321c71d3bab822..ecc5565330b95829076ac904e16888612c89d68b 100644 (file)
@@ -52,7 +52,7 @@
     fprintf(stderr, "%s:%d test failed: '%s'\n",                       \
             __FILE__, __LINE__, msg);                                  \
     unitfail++;                                                        \
-  } WHILE_FALSE
+  } while(0)
 
 
 /* The abort macros mark the current test step as failed, and exit the test */
@@ -77,7 +77,7 @@
             __FILE__, __LINE__, msg);                         \
     unitfail++;                                               \
     goto unit_test_abort;                                     \
-  } WHILE_FALSE
+  } while(0)
 
 
 
index 8267250c24a44f4725a9acb01f44714c6b1712ed..6f34257c5f04af3be5a4baa80535fd77948b49f1 100644 (file)
@@ -61,11 +61,11 @@ CC = cl.exe
 !IF "$(VC)"=="6"\r
 CC_NODEBUG  = $(CC) /O2 /DNDEBUG\r
 CC_DEBUG    = $(CC) /Od /Gm /Zi /D_DEBUG /GZ\r
-CFLAGS      = /I. /I../lib /I../include /nologo /W4 /wd4127 /GX /DWIN32 /YX /FD /c /DBUILDING_LIBCURL\r
+CFLAGS      = /I. /I../lib /I../include /nologo /W4 /GX /DWIN32 /YX /FD /c /DBUILDING_LIBCURL\r
 !ELSE\r
 CC_NODEBUG  = $(CC) /O2 /DNDEBUG\r
 CC_DEBUG    = $(CC) /Od /D_DEBUG /RTC1 /Z7 /LDd\r
-CFLAGS      = /I. /I ../lib /I../include /nologo /W4 /wd4127 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL\r
+CFLAGS      = /I. /I ../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL\r
 !ENDIF\r
 \r
 LFLAGS     = /nologo /machine:$(MACHINE)\r