Skip to content

Clear the compiler warnings on Linux and Windows - #32

Merged
xcomart merged 2 commits into
masterfrom
fix/compiler-warnings
Aug 3, 2026
Merged

Clear the compiler warnings on Linux and Windows#32
xcomart merged 2 commits into
masterfrom
fix/compiler-warnings

Conversation

@xcomart

@xcomart xcomart commented Aug 3, 2026

Copy link
Copy Markdown
Owner

gcc reported two warnings, MSVC fourteen. None of them were noise.

Latent bug

The HTTP connection pool keys itself on "host:port" in a buffer as wide as the host field alone, so gcc warned that the port could be truncated away — two hosts differing only past that point would then share one connection pool. The host width and the key width are now named constants, and the key is the wider of the two.

Type mismatch

CMUTIL_SocketConnectIPCInternal passed a struct sockaddr_in* where a CMUTIL_SocketAddr* (struct sockaddr_storage*) was expected. Both point at the same object so the code worked, but the declared types disagreed; it now passes the storage it meant to.

Narrowing conversions

Call Takes Was passed
select() int nfds SOCKET + 1 — a 64-bit handle on Windows, where the argument is ignored outright
connect(), bind() socklen_t size_t
CMUTIL_Socket::Write uint32_t size_t / strlen()
CMUTIL_ByteBuffer::AddBytes uint32_t strlen()

Unused

crypto_test declared an EVP_CIPHER it never used.

Verification

Linux clean rebuild is now warning-free; 15/15 ctest and 21/21 samples pass. The Windows half is what this PR's CI run is for — the MSVC warnings were read out of the previous master run's log.

🤖 Generated with Claude Code

xcomart and others added 2 commits August 3, 2026 12:23
gcc had two, MSVC fourteen, and none of them were noise:

- The HTTP connection pool keys itself on "host:port" in a buffer as wide
  as the host field alone, so gcc warned that the port could be truncated
  away. Two hosts differing only past that point would then share one pool.
  The host width and the key width are now named and the key is the wider
  of the two.
- CMUTIL_SocketConnectIPCInternal passed a struct sockaddr_in* where a
  CMUTIL_SocketAddr* was expected. Same address either way, so the code
  worked, but the declared types disagreed - it now passes the storage it
  meant to.
- select() takes an int nfds, and a SOCKET is a 64 bit handle on Windows
  where that argument is ignored outright; connect() and bind() take a
  socklen_t, not a size_t; Socket::Write and ByteBuffer::AddBytes take a
  uint32_t, not a size_t. All now say so.
- crypto_test declared an EVP_CIPHER it never used.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CMUTIL_PrivateKeyCreateFromPEM takes a const uint8_t*, which clang on
macOS flagged for the empty string literal handed to it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@xcomart
xcomart merged commit 4d4d753 into master Aug 3, 2026
3 checks passed
@xcomart
xcomart deleted the fix/compiler-warnings branch August 3, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant