]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: fix `-Wunreachable-code` in !websockets !unity builds
authorViktor Szakats <commit@vsz.me>
Wed, 29 Oct 2025 12:31:23 +0000 (13:31 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 29 Oct 2025 15:17:34 +0000 (16:17 +0100)
Also requires non-unity build. Possibly more non-default options are
necessary to reproduce. Seen with llvm/clang.

```
lib/http.c:1856:15: error: code will never be executed [-Werror,-Wunreachable-code]
 1856 |     httpreq = HTTPREQ_GET;
      |               ^~~~~~~~~~~
1 error generated.
```

Closes #19275

lib/http.c

index 0b55796dc529a5d5f7dca89767617deb305c15b1..b8a4edef61066617a6677cc88fa6838e0e133c07 100644 (file)
@@ -1852,9 +1852,12 @@ void Curl_http_method(struct Curl_easy *data,
 {
   Curl_HttpReq httpreq = (Curl_HttpReq)data->state.httpreq;
   const char *request;
+#ifndef CURL_DISABLE_WEBSOCKETS
   if(data->conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
     httpreq = HTTPREQ_GET;
-  else if((data->conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
+  else
+#endif
+  if((data->conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
      data->state.upload)
     httpreq = HTTPREQ_PUT;