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")
master
leitner 20 years ago
parent e62f4901c8
commit 6196f771cd

@ -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

@ -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;

@ -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;

@ -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);

@ -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;

@ -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);

@ -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));
}

@ -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;

@ -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;

@ -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;

@ -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 (;;) {

@ -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[]) {

Loading…
Cancel
Save