]> arthur.barton.de Git - ngircd-alex.git/commitdiff
conn-ssl.c: work around gnutls API problems on 64 bit platforms
authorFlorian Westphal <fw@strlen.de>
Wed, 29 Oct 2008 22:51:39 +0000 (23:51 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 29 Oct 2008 22:51:39 +0000 (23:51 +0100)
Alexander Barton reported a compiler warning on 64-bit platforms:
cc1: warnings being treated as errors
conn-ssl.c: In function 'ConnSSL_Init_SSL':
conn-ssl.c:403: error: cast to pointer from integer of
different size

Unfortunately, I couldn't find a real solution; the GNUTLS
API expects 'gnutls_transport_ptr_t' (which is void*),
but the default push/pull functions (send/recv) expect an int.

The only alternative solution is to pass in an address to the
file descriptor, then add send/recv wrappers that expect a pointer.

What a mess[tm].

src/ngircd/conn-ssl.c

index 5a1000728a7b604753736c0be3f0f98cc02584fc..cd7abd4bd38dcf79d688e448a9acecb98234dad5 100644 (file)
@@ -400,7 +400,13 @@ ConnSSL_Init_SSL(CONNECTION *c)
                Log(LOG_ERR, "gnutls_set_default_priority: %s", gnutls_strerror(ret));
                ConnSSL_Free(c);
        }
-       gnutls_transport_set_ptr(c->ssl_state.gnutls_session, (gnutls_transport_ptr_t) c->sock);
+       /*
+        * The intermediate (long) cast is here to avoid a warning like:
+        * "cast to pointer from integer of different size" on 64-bit platforms.
+        * There doesn't seem to be an alternate GNUTLS API we could use instead, see e.g.
+        * http://www.mail-archive.com/help-gnutls@gnu.org/msg00286.html
+        */
+       gnutls_transport_set_ptr(c->ssl_state.gnutls_session, (gnutls_transport_ptr_t) (long) c->sock);
        ret = gnutls_credentials_set(c->ssl_state.gnutls_session, GNUTLS_CRD_CERTIFICATE, x509_cred);
        if (ret < 0) {
                Log(LOG_ERR, "gnutls_credentials_set: %s", gnutls_strerror(ret));