Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two incompatible types warnings in example code #405

Merged
merged 2 commits into from
Apr 11, 2024

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
21 checks passed
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix warnings in server.c / client.c Windows build
2 participants