Skip to content

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

Closed
@gvanem

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.

Activity

added a commit that references this issue on Apr 6, 2024
jay

jay commented on Apr 6, 2024

@jay
Member

Please try #13304. I used your gmail in the author field of the commit, let me know if you want it changed to yahoo

gvanem

gvanem commented on Apr 7, 2024

@gvanem
ContributorAuthor

Work w/o warnings.

let me know if you want it changed to yahoo

Yes, please.

jay

jay commented on Apr 7, 2024

@jay
Member

Thanks

added a commit that references this issue on Apr 7, 2024
bagder

bagder commented on Apr 9, 2024

@bagder
Member

I'll update the mailmap for Gisle to prefer the yahoo address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @bagder@gvanem@jay

      Issue actions

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