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

Nikos Mavrogiannopoulos nmav at gnutls.org
Thu Feb 7 19:06:35 CET 2013


On 02/07/2013 03:10 PM, Jaak Ristioja wrote:

> The current solution probably works for most x86 setups, but not for
> all. The compiler warning is completely reasonable, as it points out
> something which might not work properly on some platforms.
> I suspect this behavior can't be corrected without breaking the ABI/API.
> I think stuff with actual (void *) pointers still works if the
> respective callbacks are properly set.


Hello,
 I by change to the ABI you mean adding a new function, that's not a
high cost.

However, my main concern is whether there is an actual system where the
current approach causes a problem in order to justify any action (at
least from my part, if you submit a patch for that, that's another story).

> I guess one of the simplest solutions would be to define only one new
> function like the following:
> 
>   int gnutls_set_transport_berkeley(gnutls_session_t session, int sd);
> 
> Something like this would prevent unportable int<->ptr conversions (or
> only warnings for users compiling against your library, if you decide to
> use such conversions inside GnuTLS anyway). Inside the library you can


Why you need to use such conversions? I'd add a union for that, and
possibly a type indicator.

> Of course the semantics for the callback functions also need to be
> changed. Namely that the callback functions should only be called when a
> custom transport is set. If a berkeley transport is set with
> gnutls_set_transport_berkeley, then the callbacks (which take a
> gnutls_transport_ptr_t a.k.a void * argument) are not called.


As you described before the typical cases are 3, I would just describe
the behavior when improperly mixing the transport function as undefined :)

regards,
Nikos



More information about the Gnutls-devel mailing list