summaryrefslogtreecommitdiff
path: root/tests/libtest/test.h
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2019-11-30 03:29:36 -0500
committerJay Satiro <raysatiro@yahoo.com>2019-12-01 19:01:02 -0500
commit9c1806ae4684ec5ef1aeb39bb9f15cece1c27256 (patch)
tree519c34c7411ae2afda27b38500f77d456bb8cad9 /tests/libtest/test.h
parent0436d4438a9dbfd5dc1364de31281505c7915b25 (diff)
downloadcurl-9c1806ae4684ec5ef1aeb39bb9f15cece1c27256.tar.gz
build: Disable Visual Studio warning "conditional expression is constant"
- 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
Diffstat (limited to 'tests/libtest/test.h')
-rw-r--r--tests/libtest/test.h58
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/libtest/test.h b/tests/libtest/test.h
index 3c8323de4..fd88365c6 100644
--- a/tests/libtest/test.h
+++ b/tests/libtest/test.h
@@ -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'. */