]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
wolfssl: silence compiler warning (MSVC 2019), simplify existing
authorViktor Szakats <commit@vsz.me>
Fri, 7 Feb 2025 00:48:24 +0000 (01:48 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 7 Feb 2025 09:52:55 +0000 (10:52 +0100)
Seen with VS2019 and older versions:
```
lib\vtls\wolfssl.c(773): warning C4706: assignment within conditional expression
```
Ref: https://github.com/curl/curl/actions/runs/13190321645/job/36821938202?pr=16217#step:9:30

Also replace pragma suppression with this simpler method, and silence
`checksrc` where it complains about the extra ` != NULL` this needs.

Closes #16230

lib/ftp.c
lib/telnet.c
lib/vtls/wolfssl.c
src/tool_writeout_json.c
tests/libtest/lib1945.c

index cb0fada0c7545d45d5023a4504315512dbfd98af..6c6a20704f0244841bde7227d150b3ed7dbd2b8a 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -4107,11 +4107,6 @@ static CURLcode ftp_disconnect(struct Curl_easy *data,
   return CURLE_OK;
 }
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4706) /* assignment within conditional expression */
-#endif
-
 /***********************************************************************
  *
  * ftp_parse_url_path()
@@ -4202,7 +4197,8 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
         }
 
         /* parse the URL path into separate path components */
-        while((slashPos = strchr(curPos, '/'))) {
+        /* !checksrc! disable EQUALSNULL 1 */
+        while((slashPos = strchr(curPos, '/')) != NULL) {
           size_t compLen = slashPos - curPos;
 
           /* path starts with a slash: add that as a directory */
@@ -4266,10 +4262,6 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
   return CURLE_OK;
 }
 
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
 /* call this when the DO phase has completed */
 static CURLcode ftp_dophase_done(struct Curl_easy *data, bool connected)
 {
index 589f9dab4938568ce29b0f905d363bdf79a4b729..1cb6221d6e1829f827261effbfd8bac93bda8770 100644 (file)
@@ -777,22 +777,15 @@ static void printsub(struct Curl_easy *data,
   }
 }
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4706) /* assignment within conditional expression */
-#endif
 static bool str_is_nonascii(const char *str)
 {
   char c;
-  while((c = *str++))
+  while((c = *str++) != 0)
     if(c & 0x80)
       return TRUE;
 
   return FALSE;
 }
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
 
 static CURLcode check_telnet_options(struct Curl_easy *data)
 {
index 82b21afb8c4f425e220ee47782e6cdb9f3bb36c0..546ba034af4704ca1fa0dd955b56788991c33244 100644 (file)
@@ -770,7 +770,7 @@ wssl_add_default_ciphers(bool tls13, struct dynbuf *buf)
   int i;
   char *str;
 
-  for(i = 0; (str = wolfSSL_get_cipher_list(i)); i++) {
+  for(i = 0; (str = wolfSSL_get_cipher_list(i)) != NULL; i++) {
     size_t n;
     if((strncmp(str, "TLS13", 5) == 0) != tls13)
       continue;
index d85243b51ac215b0881313bb2c3444f981e317ec..dff136174f45ac773d0127a9a39c84c1d445a2f4 100644 (file)
@@ -118,11 +118,6 @@ void ourWriteOutJSON(FILE *stream, const struct writeoutvar mappings[],
   fprintf(stream, "}");
 }
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4706) /* assignment within conditional expression */
-#endif
-
 void headerJSON(FILE *stream, struct per_transfer *per)
 {
   struct curl_header *header;
@@ -130,7 +125,7 @@ void headerJSON(FILE *stream, struct per_transfer *per)
 
   fputc('{', stream);
   while((header = curl_easy_nextheader(per->curl, CURLH_HEADER, -1,
-                                       prev))) {
+                                       prev)) != NULL) {
     if(header->amount > 1) {
       if(!header->index) {
         /* act on the 0-index entry and pull the others in, then output in a
@@ -169,7 +164,3 @@ void headerJSON(FILE *stream, struct per_transfer *per)
   }
   fputs("\n}", stream);
 }
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
index 59db5540f337116563771ca8ff3e2b9f53d6af77..301da6bd77b1fcd16bda24152ffa152a6d2f8f15 100644 (file)
 
 #include "memdebug.h"
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4706) /* assignment within conditional expression */
-#endif
 static void showem(CURL *easy, unsigned int type)
 {
   struct curl_header *header = NULL;
   struct curl_header *prev = NULL;
 
-  while((header = curl_easy_nextheader(easy, type, 0, prev))) {
+  /* !checksrc! disable EQUALSNULL 1 */
+  while((header = curl_easy_nextheader(easy, type, 0, prev)) != NULL) {
     printf(" %s == %s (%u/%u)\n", header->name, header->value,
            (int)header->index, (int)header->amount);
     prev = header;
   }
 }
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
 
 static size_t write_cb(char *data, size_t n, size_t l, void *userp)
 {