rustls / rustls-ffi

Use Rustls from any language
Other
123 stars 31 forks source link

Fix two incompatible types warnings in example code #405

Closed cpu closed 2 months ago

cpu commented 3 months ago

Resolves https://github.com/rustls/rustls-ffi/issues/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.