[Privoxy-devel] incompatible pointer type
Lee
ler762 at gmail.com
Wed Jan 9 18:55:25 UTC 2019
On 1/9/19, Fabian Keil <fk at fabiankeil.de> wrote:
> Lee <ler762 at gmail.com> wrote:
>
>> All pointers are the same size - correct?
>
> Correct.
>
>> I get a couple of warnings in jbsockets.c about incompatible pointer types
>> - eg:
>> jbsockets.c: In function ‘set_no_delay_flag’:
>> jbsockets.c:140:49: warning: passing argument 4 of ‘setsockopt’ from
>> incompatible pointer type [-Wincompatible-pointer-types]
>> if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int)))
>> ^
>> In file included from jbsockets.c:52:0:
>> /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:999:34: note:
>> expected ‘const char *’ but argument is of type ‘int *’
>> WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int
>> optname,const char *optval,int optlen);
>> ^~~~~~~~~~
>>
>> that boils down to Windows expects a 'char*' pointer & *nix expects a
>> 'int*' pointer.
>
> On ElectroBSD the prototype is:
>
> int
> setsockopt(int s, int level, int optname, const void *optval,
> socklen_t optlen);
Which means you're not going to get a compiler warning on ElectroBSD if you have
char* optval or int* optval? And either will work?
>> I can make the warnings go away by casting the 4th parameter to (char*)
>> - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int)))
>> + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&mi,
>> sizeof(int)))
>>
>> but a 'char*' pointer is the same size as an 'int*' pointer, so this
>> is just a cosmetic issue that can safely be ignored. Correct?
>
> Correct.
What's the expected expertise level of somebody looking at the code?
As in, is it worth adding a comment that with the mingw gcc headers
you're going to get a [-Wincompatible-pointer-types] warning from the
compiler here & it's a cosmetic issue that isn't worth the effort to
fix?
Thanks,
Lee
More information about the Privoxy-devel
mailing list