Skip to content

build: sync up picky warnings with curl, fix fallouts - #1588

Closed
vszakats wants to merge 10 commits into
libssh2:masterfrom
vszakats:cm-warnover
Closed

vszakats wants to merge 10 commits into
libssh2:masterfrom
vszakats:cm-warnover

Conversation

@vszakats

@vszakats vszakats commented Apr 26, 2025 •

Copy link
Copy Markdown
Member
  • cmake: sync -ftree-vrp behavior with autotools.
  • build: enable -Wjump-misses-init for GCC 4.5+.
    Credits-to: Marcel Raad
  • packet: fix -Wjump-misses-init warnings.
    src/packet.c: In function ‘_libssh2_packet_add’:
    src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
    src/packet.c:920:31: note: ‘want_reply’ declared here
    src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
    src/packet.c:919:26: note: ‘len’ declared here
    src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
    src/packet.c:1121:31: note: ‘want_reply’ declared here
    src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
    src/packet.c:1120:26: note: ‘len’ declared here
    src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
    src/packet.c:1119:26: note: ‘channel’ declared here
    
  • build: enable gcc-12/13+, clang-10+ picky warnings
  • acinclude.m4: sync formatting/comments with curl.
  • autotools: fix -Wtrampolines picky warning for gcc 4.x versions.
    Follow-up to 854cfa8 build: prepare builds for clang-cl, add cmake ossfuzz support #1524
  • cmake: enable -Wall for MSVC when PICKY_COMPILER=ON.
  • MSVC: fix -Wall warnings.
    Seen on VS2015. Not seen on VS2022. Unknown for other versions.
    tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t'
    tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%.*s' requires an argument of type 'int', but variadic argument 2 has type 'std::size_t'
    
  • mbedtls: stop silencing warnings in 3rd-party header.
    Follow-up to a3aa6b4 cmake: misc improvements, add LIBSSH2_USE_PKGCONFIG option #1525
  • cmake: stop deleting -W<n> from CMAKE_C_FLAGS (MSVC)
    1. CMAKE_C_FLAGS may apply to other projects, and deleting/altering it
      may be unexpected.
    2. We pass -W4/-Wall internally now, which do override custom
      -W<n> options as tested with VS2008 and newer VS generators.

w/o ws https://github.com/libssh2/libssh2/pull/1588/files?w=1

@vszakats

This comment was marked as resolved.

@vszakats
vszakats force-pushed the cm-warnover branch 3 times, most recently from 477c4ab to 4721527 Compare April 27, 2025 07:22
@vszakats vszakats changed the title build: sync up picky warnings with curl build: sync up picky warnings with curl, fix fallouts Apr 28, 2025
vszakats added 10 commits May 7, 2025 01:18
```
src/packet.c: In function ‘_libssh2_packet_add’:
src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  671 |         goto libssh2_packet_add_jump_point5;
      |         ^~~~
src/packet.c:934:1: note: label ‘libssh2_packet_add_jump_point5’ defined here
  934 | libssh2_packet_add_jump_point5:
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/packet.c:920:31: note: ‘want_reply’ declared here
  920 |                 unsigned char want_reply = 0;
      |                               ^~~~~~~~~~
src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  671 |         goto libssh2_packet_add_jump_point5;
      |         ^~~~
src/packet.c:934:1: note: label ‘libssh2_packet_add_jump_point5’ defined here
  934 | libssh2_packet_add_jump_point5:
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/packet.c:919:26: note: ‘len’ declared here
  919 |                 uint32_t len = 0;
      |                          ^~~
src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  669 |         goto libssh2_packet_add_jump_point4;
      |         ^~~~
src/packet.c:1198:1: note: label ‘libssh2_packet_add_jump_point4’ defined here
 1198 | libssh2_packet_add_jump_point4:
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/packet.c:1121:31: note: ‘want_reply’ declared here
 1121 |                 unsigned char want_reply = 1;
      |                               ^~~~~~~~~~
src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  669 |         goto libssh2_packet_add_jump_point4;
      |         ^~~~
src/packet.c:1198:1: note: label ‘libssh2_packet_add_jump_point4’ defined here
 1198 | libssh2_packet_add_jump_point4:
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/packet.c:1120:26: note: ‘len’ declared here
 1120 |                 uint32_t len = _libssh2_ntohu32(data + 5);
      |                          ^~~
src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  669 |         goto libssh2_packet_add_jump_point4;
      |         ^~~~
src/packet.c:1198:1: note: label ‘libssh2_packet_add_jump_point4’ defined here
 1198 | libssh2_packet_add_jump_point4:
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/packet.c:1119:26: note: ‘channel’ declared here
 1119 |                 uint32_t channel = _libssh2_ntohu32(data + 1);
      |                          ^~~~~~~
```
VS2015:
```
tests\test_simple.c(60): error C2220: warning treated as error - no 'object' file generated
tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t'
tests\test_simple.c(60): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
tests\test_simple.c(60): note: the sizes of types 'std::size_t' and 'int' might differ on other platforms
tests\test_simple.c(60): note: consider using '%zd' in the format string
tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%.*s' requires an argument of type 'int', but variadic argument 2 has type 'std::size_t'
tests\test_simple.c(60): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
tests\test_simple.c(60): note: this argument is used as a precision
tests\test_simple.c(60): note: the sizes of types 'std::size_t' and 'int' might differ on other platforms
```
1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it
   may be unexpected.

2. We pass `-W4`/`-Wall` internally now, which do override custom
   `-W<n>` options in all supported MSVC versions.
   (as tested with Visual Studio generators)
@vszakats vszakats closed this in 72982d1 May 7, 2025
@vszakats
vszakats deleted the cm-warnover branch May 7, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant