Subject: | Compiler warnings |
gcc-7.2.1 reports these two warnings when building with perl-5.26.1:
gcc -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORT
IFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-
switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-
annobin-cc1 -m64 -mtune=generic -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGE
FILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -DVERSION=\"2.025\" -DXS_VERSION=\"2.025\" -fPIC "-I/usr/lib64/perl5/CORE" -DHAS_GAI_STRERROR -DI_NETINET_IP Socket.c
In file included from /usr/lib64/perl5/CORE/perl.h:28:0,
from Socket.xs:3:
/usr/lib64/perl5/CORE/config.h:2884:0: warning: "HAS_GAI_STRERROR" redefined
#define HAS_GAI_STRERROR /**/
<command-line>:0:0: note: this is the location of the previous definition
Socket.xs: In function 'XS_Socket_pack_sockaddr_un':
Socket.xs:829:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'STRLEN {aka long unsigned int}' [-Wformat=]
warn("Path length (%d) is longer than maximum supported length"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Socket.xs:829:11: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
The HAS_GAI_STRERROR redefinition could be solved by not supplying it explicitly. It looks like Perl already knows if it's available.
The format warnings could be fixed by changing "%d" formatter into "%lld". Recent C standard recognizes "%zu" for size_t type, but I think that Perl sticks to older C standard.