]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: enable `-Wall` for MSVC when `PICKY_COMPILER=ON`
authorViktor Szakats <commit@vsz.me>
Mon, 14 Apr 2025 10:56:30 +0000 (12:56 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 16 Apr 2025 12:34:12 +0000 (14:34 +0200)
Enable it for `_MSC_VER <= 1943`.

Omit it for not yet CI-tested MSVC versions, to avoid hitting unfixed
warnings emitted by future toolchain releases. It means we need
to explicitly opt-in to newer MSVC versions while fixing any new issues.

The newly enabled warnings did not reveal new issues. It hints that we
catch those with clang/gcc. Yet, these warnings may be useful for local
development done with MSVC.

Also:
- disable and document warnings that don't seem useful, unactionable,
  or unfixable.
- disable and document warnings found in Windows SDK headers.
- tidy up a few comments, also to avoid
  `-Wdocumentation-unknown-command`, part of llvm/clang `-Wall`.
  ```
  lib\dynhds.h(159,29): error : unknown command tag name [-Werror,-Wdocumentation-unknown-command]
  lib\ftp.c(337,15): error : unknown command tag name [-Werror,-Wdocumentation-unknown-command]
  ```
  (This patch did not end up enabling `-Wall` for clang-cl.)

Closes #17050

CMake/PickyWarnings.cmake
lib/dynhds.h
lib/ftp.c

index e86e184bfa60059abe09dab881f2d4438892bb3d..2785c7d24bfb18861a8e6959964c712e75d8ff14 100644 (file)
@@ -280,6 +280,24 @@ if(PICKY_COMPILER)
         list(APPEND _picky "-Wno-conversion")  # Avoid false positives
       endif()
     endif()
+  elseif(MSVC AND MSVC_VERSION LESS_EQUAL 1943)  # Skip for untested/unreleased newer versions
+    list(APPEND _picky "-Wall")
+    list(APPEND _picky "-wd4061")  # enumerator 'A' in switch of enum 'B' is not explicitly handled by a case label
+    list(APPEND _picky "-wd4191")  # 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)(void)'
+    list(APPEND _picky "-wd4255")  # no function prototype given: converting '()' to '(void)' (in winuser.h)
+    list(APPEND _picky "-wd4464")  # relative include path contains '..'
+    list(APPEND _picky "-wd4548")  # expression before comma has no effect; expected expression with side-effect (in FD_SET())
+    list(APPEND _picky "-wd4574")  # 'M' is defined to be '0': did you mean to use '#if M'? (in ws2tcpip.h)
+    list(APPEND _picky "-wd4668")  # 'M' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' (in winbase.h)
+    list(APPEND _picky "-wd4710")  # 'snprintf': function not inlined
+    list(APPEND _picky "-wd4711")  # function 'A' selected for automatic inline expansion
+    list(APPEND _picky "-wd4746")  # volatile access of '<expression>' is subject to /volatile:<iso|ms> setting;
+                                   #   consider using __iso_volatile_load/store intrinsic functions (ARM64)
+    list(APPEND _picky "-wd4774")  # 'snprintf': format string expected in argument 3 is not a string literal
+    list(APPEND _picky "-wd4820")  # 'A': 'N' bytes padding added after data member 'B'
+    if(MSVC_VERSION GREATER_EQUAL 1900)
+      list(APPEND _picky "-wd5045")  # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
+    endif()
   endif()
 endif()
 
index fb162a30debb7383aba7c95a5d3aac7798f5c006..191acdd1c2b72854421e85f43f83b5da7391f1c8 100644 (file)
@@ -156,14 +156,14 @@ CURLcode Curl_dynhds_cadd(struct dynhds *dynhds,
 
 /**
  * Add a single header from an HTTP/1.1 formatted line at the end. Line
- * may contain a delimiting \r\n or just \n. Any characters after
+ * may contain a delimiting CRLF or just LF. Any characters after
  * that will be ignored.
  */
 CURLcode Curl_dynhds_h1_cadd_line(struct dynhds *dynhds, const char *line);
 
 /**
  * Add a single header from an HTTP/1.1 formatted line at the end. Line
- * may contain a delimiting \r\n or just \n. Any characters after
+ * may contain a delimiting CRLF or just LF. Any characters after
  * that will be ignored.
  */
 CURLcode Curl_dynhds_h1_add_line(struct dynhds *dynhds,
index 393db0b4c82d940145ecf140a510ed145be09f81..f7d756a2a97be6e1cf8584a4cb9bdc97c91079a7 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -330,8 +330,7 @@ static void freedirs(struct ftp_conn *ftpc)
 }
 
 #ifdef CURL_PREFER_LF_LINEENDS
-/***********************************************************************
- *
+/*
  * Lineend Conversions
  * On ASCII transfers, e.g. directory listings, we might get lines
  * ending in '\r\n' and we prefer just '\n'.