svn commit: r336002 - in head: usr.bin/netstat usr.sbin/tcpdrop

Bruce Evans brde at optusnet.com.au
Thu Jul 5 18:12:37 UTC 2018


On Fri, 6 Jul 2018, Bruce Evans wrote:

> On Thu, 5 Jul 2018, Brooks Davis wrote:
>
>> Log:
>>  Work around lame warnings in ancient gcc on 32-bit platforms.
>> 
>>  Fixes r335979.
>
> These are correct warnings.
>
> Why not fix the bug instead of rorking around it?
>
>> Modified: head/usr.bin/netstat/inet.c
>> ==============================================================================
>> --- head/usr.bin/netstat/inet.c	Thu Jul  5 16:43:15 2018 
>> (r336001)
>> +++ head/usr.bin/netstat/inet.c	Thu Jul  5 17:02:10 2018 
>> (r336002)
>> @@ -159,12 +159,12 @@ sotoxsocket(struct socket *so, struct xsocket *xso)
>> 
>> 	bzero(xso, sizeof *xso);
>> 	xso->xso_len = sizeof *xso;
>> -	xso->xso_so = (kvaddr_t)so;
>> +	xso->xso_so = (kvaddr_t)(long)so;
>
> This (and kvaddr_t having the same 64-bit size for all arches) are 
> unportable.
> ...

Lots is still broken.  In just my kernel with few options:

X cc1: warnings being treated as errors
X ../../../kern/uipc_usrreq.c: In function 'unp_pcblist':
X ../../../kern/uipc_usrreq.c:1856: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/uipc_usrreq.c:1873: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/uipc_usrreq.c:1874: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/uipc_usrreq.c:1875: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/uipc_usrreq.c:1876: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X cc1: warnings being treated as errors
X ../../../netinet/in_pcb.c: In function 'in_pcbtoxinpcb':
X ../../../netinet/in_pcb.c:2909: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X cc1: warnings being treated as errors
X ../../../kern/kern_descrip.c: In function 'sysctl_kern_file':
X ../../../kern/kern_descrip.c:3365: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/kern_descrip.c:3366: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/kern_descrip.c:3367: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X --- in_pcb.o ---
X *** [in_pcb.o] Error code 1
X 
X make: stopped in /home/bde/syscn/i386/compile/Bsmp
X --- uipc_usrreq.o ---
X *** [uipc_usrreq.o] Error code 1
X 
X make: stopped in /home/bde/syscn/i386/compile/Bsmp
X --- kern_descrip.o ---
X *** [kern_descrip.o] Error code 1
X 
X make: stopped in /home/bde/syscn/i386/compile/Bsmp
X cc1: warnings being treated as errors
X ../../../kern/uipc_socket.c: In function 'sotoxsocket':
X ../../../kern/uipc_socket.c:3988: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X ../../../kern/uipc_socket.c:3993: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
X --- uipc_socket.o ---
X *** [uipc_socket.o] Error code 1
X 
X make: stopped in /home/bde/syscn/i386/compile/Bsmp

The warnings are especially correct since they were asked for by
[-Wpointer-to-int-cast].  I think this is implicit in -W or -Wall.  clang
doesn't even warn that it doesn't support this flag when the flag is
added explicitly.  It apparently silently ignores this flag, since it
accepts it but doesn't even warn for downcasts.

Bruce


More information about the svn-src-all mailing list