[gnutls-devel] Casting from int to (void *)

Jaak Ristioja jaak.ristioja at cyber.ee
Tue Feb 5 17:23:31 CET 2013


According to the documentation GnuTLS functions like
gnutls_transport_set_ptr can also be used for berkeley style sockets
descriptors, but unfortunately converting between int and void * types
is not always good thing to do:



Compilers like GCC and Clang also complain about casting the (int)
socket descriptors to void * types.

Perhaps it were better to provide a gnutls_transport_set_berkeley
function which would accept berkeley-style (int) socket descriptors
instead. The idea is that if gnutls_transport_set_ptr or
gnutls_transport_set_ptr2 is used the push and pull callbacks must also
be set, but if gnutls_transport_set_berkeley is used, the callbacks are
not used.

Afaik using intptr_t could also be an option, but in that case one has
to verify that all values of type int fit into intptr_t.

Best regards,

More information about the Gnutls-devel mailing list