diff --git a/CHANGES b/CHANGES index fbdeb04..b90dc50 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,11 @@ optimize fmt_base64 (Dan Gundlach) gcc 4 cleanups (mostly unsigned char* vs char*) fix scan_xlong, scan_xlonglong and scan_8long + remove a few gcc 4 warnings + work around freebsd 5.4 brokenness (if you don't have IPv6 in the + kernel, socket(PF_INET6,SOCK_STREAM,0) returns EPROTONOSUPPORT + instead of EPFNOSUPPORT, which basically says "yeah, I know IPv6, + but TCP? never heard of it") 0.22: uh, the scope_id detection #defined the wrong constant. libowfat diff --git a/buffer/buffer_get.c b/buffer/buffer_get.c index 07290f4..6f35cba 100644 --- a/buffer/buffer_get.c +++ b/buffer/buffer_get.c @@ -3,9 +3,9 @@ int buffer_get(buffer* b,char* x,unsigned long int len) { int blen; - if ((blen=buffer_feed(b))>=len) + if ((blen=buffer_feed(b))<0) return blen; + if ((unsigned long int) blen>=len) blen=len; - if (blen<=0) return blen; byte_copy(x,blen,b->x+b->p); b->p+=blen; return blen; diff --git a/dns/dns_rcip.c b/dns/dns_rcip.c index a127d4a..406b0b6 100644 --- a/dns/dns_rcip.c +++ b/dns/dns_rcip.c @@ -10,8 +10,8 @@ static stralloc data = {0}; static int init(char ip[256]) { - int i; - int j; + unsigned long int i; + unsigned long int j; int iplen = 0; char *x; @@ -30,7 +30,7 @@ static int init(char ip[256]) if (!iplen) { i = openreadclose("/etc/resolv.conf",&data,64); - if (i == -1) return -1; + if (i == (unsigned long int)-1) return -1; if (i) { if (!stralloc_append(&data,"\n")) return -1; i = 0; diff --git a/socket/socket_accept4.c b/socket/socket_accept4.c index 322a86e..7eeec84 100644 --- a/socket/socket_accept4.c +++ b/socket/socket_accept4.c @@ -11,7 +11,7 @@ int socket_accept4(int s,char *ip,uint16 *port) { struct sockaddr_in si; socklen_t len = sizeof si; int fd; - if ((fd=accept(s,(struct sockaddr*) &si,&len))==-1) + if ((fd=accept(s,(void*) &si,&len))==-1) return winsock2errno(-1); *(uint32*)ip = *(uint32*)&si.sin_addr; uint16_unpack_big((char *) &si.sin_port,port); diff --git a/socket/socket_connect6.c b/socket/socket_connect6.c index 274e0ab..8be6d01 100644 --- a/socket/socket_connect6.c +++ b/socket/socket_connect6.c @@ -36,7 +36,7 @@ int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id) #endif byte_copy((char *) &sa.sin6_addr,16,ip); - return winsock2errno(connect(s,(struct sockaddr *) &sa,sizeof sa)); + return winsock2errno(connect(s,(void*) &sa,sizeof sa)); #else errno=EPROTONOSUPPORT; return -1; diff --git a/socket/socket_local6.c b/socket/socket_local6.c index 17e4192..a3a1719 100644 --- a/socket/socket_local6.c +++ b/socket/socket_local6.c @@ -22,10 +22,10 @@ int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id) #endif socklen_t len = sizeof si; - if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return winsock2errno(-1); + if (getsockname(s,(void*) &si,&len) == -1) return winsock2errno(-1); #ifdef LIBC_HAS_IP6 if (si.sin6_family==AF_INET) { - struct sockaddr_in *si4=(struct sockaddr_in*)&si; + struct sockaddr_in *si4=(void*)&si; if (ip) { byte_copy(ip,12,V4mappedprefix); byte_copy(ip+12,4,(char *) &si4->sin_addr); diff --git a/socket/socket_send4.c b/socket/socket_send4.c index f18362d..69be15e 100644 --- a/socket/socket_send4.c +++ b/socket/socket_send4.c @@ -15,5 +15,5 @@ int socket_send4(int s,const char *buf,unsigned int len,const char ip[4],uint16 si.sin_family = AF_INET; uint16_pack_big((char*) &si.sin_port,port); *((uint32*)&si.sin_addr) = *((uint32*)ip); - return winsock2errno(sendto(s,buf,len,0,(struct sockaddr *) &si,sizeof si)); + return winsock2errno(sendto(s,buf,len,0,(void*) &si,sizeof si)); } diff --git a/socket/socket_send6.c b/socket/socket_send6.c index a6da300..475d62f 100644 --- a/socket/socket_send6.c +++ b/socket/socket_send6.c @@ -41,7 +41,7 @@ int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 #else si.sin6_scope_id=0; #endif - return winsock2errno(sendto(s,buf,len,0,(struct sockaddr *) &si,sizeof si)); + return winsock2errno(sendto(s,buf,len,0,(void*) &si,sizeof si)); #else errno=EPROTONOSUPPORT; return -1; diff --git a/socket/socket_tcp6.c b/socket/socket_tcp6.c index 37a460d..46a78df 100644 --- a/socket/socket_tcp6.c +++ b/socket/socket_tcp6.c @@ -14,6 +14,9 @@ #ifndef EPFNOSUPPORT #define EPFNOSUPPORT EAFNOSUPPORT #endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT EAFNOSUPPORT +#endif int socket_tcp6(void) { @@ -24,7 +27,7 @@ int socket_tcp6(void) if (noipv6) goto compat; s = winsock2errno(socket(PF_INET6,SOCK_STREAM,0)); if (s == -1) { - if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT) { + if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT || errno == EPROTONOSUPPORT) { compat: s=socket(AF_INET,SOCK_STREAM,0); noipv6=1; diff --git a/socket/socket_udp6.c b/socket/socket_udp6.c index 9df778d..fb70170 100644 --- a/socket/socket_udp6.c +++ b/socket/socket_udp6.c @@ -14,6 +14,9 @@ #ifndef EPFNOSUPPORT #define EPFNOSUPPORT EAFNOSUPPORT #endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT EAFNOSUPPORT +#endif int socket_udp6(void) { @@ -24,7 +27,7 @@ int socket_udp6(void) if (noipv6) goto compat; s = winsock2errno(socket(PF_INET6,SOCK_DGRAM,0)); if (s == -1) { - if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT) { + if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT || errno == EPROTONOSUPPORT) { compat: s=winsock2errno(socket(AF_INET,SOCK_DGRAM,0)); noipv6=1; diff --git a/str/str_diffn.c b/str/str_diffn.c index 7a6ef3f..5f9e5e7 100644 --- a/str/str_diffn.c +++ b/str/str_diffn.c @@ -8,7 +8,7 @@ int str_diffn(const char* a, const char* b, unsigned long limit) { register const unsigned char* s=(const unsigned char*)a; register const unsigned char* t=(const unsigned char*)b; - register const char* u=t+limit; + register const unsigned char* u=t+limit; register int j; j=0; for (;;) { diff --git a/test/uudecode.c b/test/uudecode.c index d65dcc2..45f5a7e 100644 --- a/test/uudecode.c +++ b/test/uudecode.c @@ -69,13 +69,14 @@ static const uint32_t crc_table[256] = { 0x2d02ef8dL }; -unsigned int crc32(unsigned int crc, const char* buf, unsigned int len) { - crc = crc ^ 0xffffffffL; +uint32_t crc32(uint32_t crc, const char* buf, unsigned int len) { + const unsigned char* b=(const unsigned char*)buf; + crc = crc ^ 0xfffffffful; while (len) { - crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); - --len; + crc = (crc >> 8) ^ crc_table[(crc & 0xff) ^ *b]; + ++b; --len; } - return crc ^ 0xffffffffL; + return crc ^ 0xfffffffful; } int main(int argc,char* argv[]) {