Skip to content

clang-cl warning in 'http/clients/ws-data.c' #13301

Description

@gvanem

I did this

Another clang-cl warning similar to this:

ws-data.c(195,7): warning: variable 'res' may be uninitialized when used here [-Wconditional-uninitialized]
  195 |   if(!res)
      |       ^~~
ws-data.c(171,3): note: variable 'res' is declared here
  171 |   CURLcode res;
      |   ^
1 warning generated.

Small fix:

--- a/http/clients/ws-data.c 2023-09-06 13:15:12
+++ b/http/clients/ws-data.c 2024-04-06 09:30:31
@@ -168,7 +168,7 @@

 static CURLcode data_echo(CURL *curl, size_t plen_min, size_t plen_max)
 {
-  CURLcode res;
+  CURLcode res = CURLE_OK; /* assume success */
   size_t len;
   char *send_buf;
   size_t i;
@@ -192,7 +192,7 @@
   }

 out:
-  if(!res)
+  if(res == CURLE_OK)
     websocket_close(curl);
   free(send_buf);
   return res;

But not sure since I failed to find a suitable test for it.
All I'm getting is Not a websocket transfer or HTTP/1.1 426 Upgrade Required from some Mongoose examples.

I expected the following

No warning.

curl/libcurl version

git master

operating system

Win-10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions