Skip to content

Conversation

@cpu
Copy link
Member

@cpu cpu commented Mar 30, 2024

Resolves #235

client.c

The rustls_verify_server_cert_callback type is defined as returning uint32_t.

In client.c we were mistakenly typing the verify callback as returning enum rustls_result when it should be uint32_t. This commit makes the required adjustment, silencing the warning.

server.c

On Linux, man 2 setsockopt shows the optval argument as being const void *. On Windows, setsockopt's optval argument is const char*. This mismatch produces an incompatible types warning when building the server.c example on Windows.

The solution is straight-forward. Explicitly cast optval to const char*. On Windows this is the correct type. On Linux it will be implicitly converted to const void * and everyone is happy.

cpu added 2 commits March 30, 2024 17:06
The `rustls_verify_server_cert_callback` type is defined as returning
uint32_t. This uint32_t return is translated by the calling code in
rustls-ffi to a `rustls_result`.

In client.c we were mistakenly typing the `verify` callback as returnign
`enum rustls_result` when it should be `uint32_t`. This commit makes the
required adjustment, silencing the warning.
On Linux, `man 2 setsockopt` shows the `optval` argument as being `const
void *`. On Windows, `setsockopt`'s `optval` argument is `const char*`.
This mismatch produces an incompatible types warning when building the
`server.c` example on Windows.

The solution is straight-forward. Explicitly cast `optval` to `const
char*`. On Windows this is the correct type. On Linux it will be
implicitly converted to `const void *` and everyone is happy.
Copy link
Collaborator

@jsha jsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

@cpu cpu merged commit cbbef17 into rustls:main Apr 11, 2024
@cpu cpu deleted the cpu-fix-warns branch April 11, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants