From eeffc363876c6cb2a8a049bef6ff541215f64736 Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 12 May 2005 06:52:29 +0000 Subject: [PATCH] remove even more warnings 64-bit cleanliness issue with auto-NULL-appending macros --- CHANGES | 2 ++ GNUmakefile | 2 +- array/array_allocate.c | 2 +- buffer.h | 4 ++-- buffer/buffer_get_token.c | 2 +- buffer/buffer_get_token_pred.c | 2 +- buffer/buffer_getn.c | 2 +- buffer/buffer_putalign.c | 2 +- buffer/errmsg_writesys.c | 4 ++-- dns/dns_rcip.c | 4 ++-- dns/dns_rcrw.c | 10 +++++----- dns/dns_resolve.c | 2 +- dns/dns_transmit.c | 30 +++++++++++++++--------------- errmsg.h | 12 ++++++------ fmt/fmt_fill.c | 2 +- fmt/fmt_pad.c | 2 +- scan/scan_httpdate.c | 1 + socket/scan_ip6.c | 4 ++-- stralloc.h | 4 ++-- unix/iopause.c | 2 +- 20 files changed, 49 insertions(+), 46 deletions(-) diff --git a/CHANGES b/CHANGES index b90dc50..56e8381 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ 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") + remove even more warnings + 64-bit cleanliness issue with auto-NULL-appending macros 0.22: uh, the scope_id detection #defined the wrong constant. libowfat diff --git a/GNUmakefile b/GNUmakefile index b60fdca..0e38fff 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -15,7 +15,7 @@ buffer.a mmap.a taia.a tai.a dns.a case.a mult.a array.a io.a textcode.a all: t $(LIBS) libowfat.a libsocket CC=gcc -CFLAGS=-pipe -W -Wall -O2 -fomit-frame-pointer +CFLAGS=-pipe -W -Wall -O2 -g #-fomit-frame-pointer #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall # CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 diff --git a/array/array_allocate.c b/array/array_allocate.c index b84f0f9..b76f223 100644 --- a/array/array_allocate.c +++ b/array/array_allocate.c @@ -56,7 +56,7 @@ void* array_allocate(array* x,uint64 membersize,int64 pos) { /* second case of overflow: pos*membersize too large */ if (__unlikely(!umult64(membersize,pos+1,&wanted))) return 0; - if (__unlikely(wanted >= x->allocated)) { + if (__unlikely(wanted >= (uint64)x->allocated)) { /* round up a little */ if (membersize<8) wanted=(wanted+127)&(-128ll); /* round up to multiple of 128 */ diff --git a/buffer.h b/buffer.h index 4c16393..cf12cf9 100644 --- a/buffer.h +++ b/buffer.h @@ -32,8 +32,8 @@ int buffer_putsflush(buffer* b,const char* x); int buffer_putm_internal(buffer*b,...); int buffer_putm_internal_flush(buffer*b,...); -#define buffer_putm(b,...) buffer_putm_internal(b,__VA_ARGS__,0) -#define buffer_putmflush(b,...) buffer_putm_internal_flush(b,__VA_ARGS__,0) +#define buffer_putm(b,...) buffer_putm_internal(b,__VA_ARGS__,(char*)0) +#define buffer_putmflush(b,...) buffer_putm_internal_flush(b,__VA_ARGS__,(char*)0) int buffer_putspace(buffer* b); int buffer_putnlflush(buffer* b); /* put \n and flush */ diff --git a/buffer/buffer_get_token.c b/buffer/buffer_get_token.c index 8dea559..795f0a5 100644 --- a/buffer/buffer_get_token.c +++ b/buffer/buffer_get_token.c @@ -3,7 +3,7 @@ #include "scan.h" int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen) { - int blen; + unsigned long int blen; for (blen=0;blen(tmp=b->a-b->p)) { byte_copy(b->x+b->p, tmp, buf); b->p+=tmp; diff --git a/buffer/errmsg_writesys.c b/buffer/errmsg_writesys.c index 82f8713..ddcdf04 100644 --- a/buffer/errmsg_writesys.c +++ b/buffer/errmsg_writesys.c @@ -36,9 +36,9 @@ void errmsg_writesys(int fd,const char* message,va_list list) { { int j; for (j=0; j #endif -static stralloc data = {0}; +static stralloc data; static int init(stralloc *rules) { char host[256]; const char *x; int i; - int j; + unsigned long j; int k; if (!stralloc_copys(rules,"")) return -1; @@ -75,7 +75,7 @@ static int init(stralloc *rules) if (byte_equal("search ",7,data.s + i) || byte_equal("search\t",7,data.s + i) || byte_equal("domain ",7,data.s + i) || byte_equal("domain\t",7,data.s + i)) { if (!stralloc_copys(rules,"?:")) return -1; i += 7; - while (i < j) { + while ((unsigned long)i < j) { k = byte_chr(data.s + i,j - i,' '); k = byte_chr(data.s + i,k,'\t'); if (!k) { ++i; continue; } @@ -107,10 +107,10 @@ static int init(stralloc *rules) return 0; } -static int ok = 0; +static int ok; static unsigned int uses; static struct taia deadline; -static stralloc rules = {0}; /* defined if ok */ +static stralloc rules; /* defined if ok */ int dns_resolvconfrewrite(stralloc *out) { diff --git a/dns/dns_resolve.c b/dns/dns_resolve.c index 82b5bbb..cfbbd5e 100644 --- a/dns/dns_resolve.c +++ b/dns/dns_resolve.c @@ -4,7 +4,7 @@ #include "dns.h" #include "ip6.h" -struct dns_transmit dns_resolve_tx = {0}; +struct dns_transmit dns_resolve_tx; int dns_resolve(const char *q,const char qtype[2]) { diff --git a/dns/dns_transmit.c b/dns/dns_transmit.c index ae0066f..9a8c015 100644 --- a/dns/dns_transmit.c +++ b/dns/dns_transmit.c @@ -111,22 +111,22 @@ static int thisudp(struct dns_transmit *d) if (byte_diff(ip,16,V6any)) { d->query[2] = dns_random(256); d->query[3] = dns_random(256); - - d->s1 = 1 + socket_udp6(); - if (!d->s1) { dns_transmit_free(d); return -1; } + + d->s1 = 1 + socket_udp6(); + if (!d->s1) { dns_transmit_free(d); return -1; } if (randombind(d) == -1) { dns_transmit_free(d); return -1; } - if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) - if (send(d->s1 - 1,d->query + 2,d->querylen - 2,0) == d->querylen - 2) { - struct taia now; - taia_now(&now); - taia_uint(&d->deadline,timeouts[d->udploop]); - taia_add(&d->deadline,&d->deadline,&now); - d->tcpstate = 0; - return 0; - } - - socketfree(d); + if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) + if (send(d->s1 - 1,d->query + 2,d->querylen - 2,0) == (long)d->querylen - 2) { + struct taia now; + taia_now(&now); + taia_uint(&d->deadline,timeouts[d->udploop]); + taia_add(&d->deadline,&d->deadline,&now); + d->tcpstate = 0; + return 0; + } + + socketfree(d); } } @@ -270,7 +270,7 @@ have sent query to curserver on UDP socket s if (errno == ECONNREFUSED) if (d->udploop == 2) return 0; return nextudp(d); } - if (r + 1 > sizeof udpbuf) return 0; + if ((unsigned long)r + 1 > sizeof udpbuf) return 0; if (irrelevant(d,udpbuf,r)) return 0; if (serverwantstcp(udpbuf,r)) return firsttcp(d); diff --git a/errmsg.h b/errmsg.h index 066e9d9..d095e5a 100644 --- a/errmsg.h +++ b/errmsg.h @@ -24,11 +24,11 @@ void errmsg_warnsys(const char* message, ...); void errmsg_info(const char* message, ...); void errmsg_infosys(const char* message, ...); -#define carp(...) errmsg_warn(__VA_ARGS__,0) -#define carpsys(...) errmsg_warnsys(__VA_ARGS__,0) -#define die(n,...) do { errmsg_warn(__VA_ARGS__,0); exit(n); } while (0) -#define diesys(n,...) do { errmsg_warnsys(__VA_ARGS__,0); exit(n); } while (0) -#define msg(...) errmsg_info(__VA_ARGS__,0); -#define msgsys(...) errmsg_infosys(__VA_ARGS__,0); +#define carp(...) errmsg_warn(__VA_ARGS__,(char*)0) +#define carpsys(...) errmsg_warnsys(__VA_ARGS__,(char*)0) +#define die(n,...) do { errmsg_warn(__VA_ARGS__,(char*)0); exit(n); } while (0) +#define diesys(n,...) do { errmsg_warnsys(__VA_ARGS__,(char*)0); exit(n); } while (0) +#define msg(...) errmsg_info(__VA_ARGS__,(char*)0); +#define msgsys(...) errmsg_infosys(__VA_ARGS__,(char*)0); #endif diff --git a/fmt/fmt_fill.c b/fmt/fmt_fill.c index b5fe767..48d31f7 100644 --- a/fmt/fmt_fill.c +++ b/fmt/fmt_fill.c @@ -9,7 +9,7 @@ unsigned long fmt_fill(char* dest,unsigned long srclen,unsigned long padlen,unsi char* olddest=dest; char* max=dest+maxlen; if (dest==0) { - int sum=srclen>padlen?srclen:padlen; + unsigned long sum=srclen>padlen?srclen:padlen; return sum>maxlen?maxlen:sum; } dest+=srclen; diff --git a/fmt/fmt_pad.c b/fmt/fmt_pad.c index 2463d90..b54a6b7 100644 --- a/fmt/fmt_pad.c +++ b/fmt/fmt_pad.c @@ -10,7 +10,7 @@ unsigned long fmt_pad(char* dest,const char* src,unsigned long srclen,unsigned l char* max=dest+maxlen; todo=padlen-srclen; if (dest==0) { - int sum=srclen>padlen?srclen:padlen; + unsigned long sum=srclen>padlen?srclen:padlen; return sum>maxlen?maxlen:sum; } for (; todo>0; --todo) { diff --git a/scan/scan_httpdate.c b/scan/scan_httpdate.c index 9a7abd9..1857740 100644 --- a/scan/scan_httpdate.c +++ b/scan/scan_httpdate.c @@ -2,6 +2,7 @@ #include "byte.h" #include "case.h" #define _GNU_SOURCE +#define __deprecated__ #include #include diff --git a/socket/scan_ip6.c b/socket/scan_ip6.c index ad81284..b71afba 100644 --- a/socket/scan_ip6.c +++ b/socket/scan_ip6.c @@ -17,8 +17,8 @@ unsigned int scan_ip6(const char *s,char ip[16]) unsigned long u; char suffix[16]; - int prefixlen=0; - int suffixlen=0; + unsigned int prefixlen=0; + unsigned int suffixlen=0; if ((i=scan_ip4(s,ip+12))) { for (len=0; len<12; ++len) ip[len]=V4mappedprefix[len]; diff --git a/stralloc.h b/stralloc.h index 283b4fc..0eba946 100644 --- a/stralloc.h +++ b/stralloc.h @@ -68,8 +68,8 @@ void stralloc_zero(stralloc* sa); /* like stralloc_cats but can cat more than one string at once */ int stralloc_catm_internal(stralloc* sa,...); -#define stralloc_catm(sa,...) stralloc_catm_internal(sa,__VA_ARGS__,0) -#define stralloc_copym(sa,...) (stralloc_zero(sa) && stralloc_catm_internal(sa,__VA_ARGS__,0)) +#define stralloc_catm(sa,...) stralloc_catm_internal(sa,__VA_ARGS__,(char*)0) +#define stralloc_copym(sa,...) (stralloc_zero(sa) && stralloc_catm_internal(sa,__VA_ARGS__,(char*)0)) /* stralloc_cat is analogous to stralloc_copy */ int stralloc_cat(stralloc* sa,stralloc* in); diff --git a/unix/iopause.c b/unix/iopause.c index 0ae7533..2ffdd00 100644 --- a/unix/iopause.c +++ b/unix/iopause.c @@ -11,7 +11,7 @@ void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *s struct taia t; int millisecs; double d; - int i; + unsigned int i; if (taia_less(deadline,stamp)) millisecs = 0;