[Help-gnutls] Re: gnutls_transport_ptr and int fd's

Rainer Gerhards rgerhards at gmail.com
Mon May 5 14:54:37 CEST 2008


Hi Simon,

thanks for your help. I changed the type, but, as you expected, that
didn't change anything.

Here is the relevant part from the build log:

make[2]: Entering directory `/home/rger/proj/rsyslog/runtime'
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.
-I..  -pthread -I../runtime -I..    -g -O2 -W -Wall -Wformat-security
-Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -g -MT
lmnsd_gtls_la-nsd_gtls.lo -MD -MP -MF .deps/lmnsd_gtls_la-nsd_gtls.Tpo
-c -o lmnsd_gtls_la-nsd_gtls.lo `test -f 'nsd_gtls.c' || echo
'./'`nsd_gtls.c
 gcc -DHAVE_CONFIG_H -I. -I.. -pthread -I../runtime -I.. -g -O2 -W -Wall
-Wformat-security -Wshadow -Wcast-align -Wpointer-arith
-Wmissing-format-attribute -g -MT lmnsd_gtls_la-nsd_gtls.lo -MD -MP
-MF .deps/lmnsd_gtls_la-nsd_gtls.Tpo -c nsd_gtls.c  -fPIC -DPIC
-o .libs/lmnsd_gtls_la-nsd_gtls.o
nsd_gtls.c: In function 'AcceptConnReq':
nsd_gtls.c:380: warning: cast to pointer from integer of different size
nsd_gtls.c: In function 'Rcv':
nsd_gtls.c:419: warning: unused variable 'gnuRet'
nsd_gtls.c: In function 'Connect':
nsd_gtls.c:512: warning: cast to pointer from integer of different size
mv -f .deps/lmnsd_gtls_la-nsd_gtls.Tpo .deps/lmnsd_gtls_la-nsd_gtls.Plo

[this is an autotools-generated Makefile]. The code compiled was this version:

http://git.adiscon.com/?p=rsyslog.git;a=blob;f=runtime/nsd_gtls.c;h=20de772a867f1c4605fc9c2a9f8ebbf6557620df;hb=tls

The warning in line 419 is expected and correct. The other two stem
back to GnuTLS.

I wonder if I am the only one seeing this warnings. Please let me
re-iterate that I am compiling with 1.6, because I need to life with
what usually is on the system (begin the syslogd I need to be very
careful on what I require). I compiled under Fedora 8 with GCC 4.1.2
20070925 (Red Hat 4.1.2-33).

Let me know if you could need any more information.

Thanks, Rainer


On Mon, May 5, 2008 at 1:34 PM, Simon Josefsson <simon at josefsson.org> wrote:
>
> "Rainer Gerhards" <rgerhards at gmail.com> writes:
>
>  > Thanks for the quick response .. and sorry for me replying just now. I
>  > somehow missed the message :)
>  >
>  > On Tue, Apr 29, 2008 at 11:38 PM, Simon Josefsson <simon at josefsson.org> wrote:
>  >> "Rainer Gerhards" <rgerhards at gmail.com> writes:
>  >>
>  >>  > Hi all,
>  >>  >
>  >>  > [working on Fedora 8 with GCC]
>  >>  >
>  >>  > I have a minor nit. The root cause is probably not in GnuTLS but in me
>  >>  > overlooking something...
>  >>  >
>  >>  > I supply the int fd I got from socket() to gnutls_transport_set_ptr().
>  >>  > However, when I do so, I receive the following GCC warning:
>  >>  >
>  >>  > cast to pointer from integer of different size
>  >>  >
>  >>  > This is annoying during the build process, but of course tolerable. I
>  >>  > would prefer to see this warning go away, but I do not like to reduce
>  >>  > GCCs warning level. Any advise would be appreciated.
>  >>
>  >>  Try to use a cast when calling the function, such as:
>  >>
>  >>   gnutls_transport_set_ptr (session, (gnutls_transport_ptr) sockfd);
>  >
>  > This is what I am doing. A snapshot of the actual code is here:
>  >
>  > http://git.adiscon.com/?p=rsyslog.git;a=blob;f=runtime/nsd_gtls.c;h=b1713240399448e042a27d22caf5a2f044fd65a1;hb=tls
>  >
>  > (e.g. in line 364).
>  >
>  > I replaced this with
>  >
>  > int ii = 6;
>  > gnutls_transport_set_ptr(pNew->sess, (gnutls_transport_ptr) ii);
>  >
>  > But I still get the same warning message. I am a bit puzzled,
>  > especially as this seems to be unusual...
>
>  Hm, could it be that you should add a trailing '_t'?  That's the new
>  type name.  However, there is a #define from the old name to the new
>  name in compat.h, which is always included, so I'm not sure it will
>  help.  It is the Right Thing though.
>
>  Which compiler flags do you use?  Maybe you could cut'n'paste the entire
>  command line that compiles the file and the warning messages.  Maybe
>  some earlier message helps understand this.
>
>  Generally, this casting is a bit ugly, and it can generate warnings.
>  Internally in gnutls, there is the GNUTLS_POINTER_TO_INT_CAST #define to
>  work around this, and similar stuff can also be found in glib.  I'm not
>  sure what the best solution is here.  Possibly we should have required
>  that the socket integer is passed to that function as a pointer instead
>  of as the value itself, but it is a bit late to fix that now.  Thoughts?
>
>  /Simon
>





More information about the Gnutls-help mailing list