From: Yang Luo Date: Tue, 26 Jul 2016 02:33:50 +0000 (+0800) Subject: Fix some compile warnings. X-Git-Tag: libpcap-1.8.1~148^2~6 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/5f9dbe5d71afd98380ef98b13391bdcc087b67d3 Fix some compile warnings. --- diff --git a/Win32/Prj/wpcap.vcxproj b/Win32/Prj/wpcap.vcxproj index 6aa90767..7a5113f0 100644 --- a/Win32/Prj/wpcap.vcxproj +++ b/Win32/Prj/wpcap.vcxproj @@ -96,7 +96,7 @@ true Level3 ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - NDEBUG;YY_NEVER_INTERACTIVE;yylval=pcap_lval;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) .\Release\ .\Release\ .\Release\ @@ -123,7 +123,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue Level3 ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - NDEBUG;YY_NEVER_INTERACTIVE;yylval=pcap_lval;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) .\Release\ .\Release\ .\Release\ @@ -151,7 +151,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue EditAndContinue ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - _DEBUG;YY_NEVER_INTERACTIVE;yylval=pcap_lval;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + _DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) .\Debug\ .\Debug\ .\Debug\ @@ -179,7 +179,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.yLevel3 ProgramDatabase ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - _DEBUG;YY_NEVER_INTERACTIVE;yylval=pcap_lval;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + _DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) .\Debug\ .\Debug\ .\Debug\ diff --git a/pcap-int.h b/pcap-int.h index 2726b91c..007e470a 100644 --- a/pcap-int.h +++ b/pcap-int.h @@ -365,12 +365,18 @@ struct oneshot_userdata { int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); #ifndef HAVE_STRLCPY -#define strlcpy(x, y, z) \ + #if !defined(_WIN32) + #define strlcpy(x, y, z) \ (strncpy((x), (y), (z)), \ ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ (void) strlen((y))) + #else + #define strlcpy(x, y, z) \ + (strncpy_s((x), PCAP_ERRBUF_SIZE, (y), (z)), \ + ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ + (void) strlen((y))) + #endif #endif - #include /* diff --git a/sockutils.c b/sockutils.c index 2466da7a..8ac89ec4 100644 --- a/sockutils.c +++ b/sockutils.c @@ -341,7 +341,7 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, #endif /* WARNING: if the address is a mcast one, I should place the proper Win32 code here */ - if (bind(sock, addrinfo->ai_addr, addrinfo->ai_addrlen) != 0) + if (bind(sock, addrinfo->ai_addr, (int) addrinfo->ai_addrlen) != 0) { sock_geterror("bind(): ", errbuf, errbuflen); return -1; @@ -376,7 +376,7 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, while (tempaddrinfo) { - if (connect(sock, tempaddrinfo->ai_addr, tempaddrinfo->ai_addrlen) == -1) + if (connect(sock, tempaddrinfo->ai_addr, (int) tempaddrinfo->ai_addrlen) == -1) { size_t msglen; char TmpBuffer[100];