remove even more warnings

64-bit cleanliness issue with auto-NULL-appending macros
master
leitner 20 years ago
parent 6196f771cd
commit eeffc36387

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

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

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

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

@ -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<len;++blen) {
register int r;

@ -4,7 +4,7 @@
int buffer_get_token_pred(buffer* b,char* x,unsigned long int len,
string_predicate p) {
int blen;
unsigned int blen;
for (blen=0;blen<len;++blen) {
register int r;

@ -2,7 +2,7 @@
#include "buffer.h"
int buffer_getn(buffer* b,char* x,unsigned long int len) {
int blen;
unsigned int blen;
for(blen=0;blen<len;++blen) {
register int r;

@ -2,7 +2,7 @@
#include "buffer.h"
int buffer_putalign(buffer* b,const char* buf,unsigned long int len) {
int tmp;
unsigned int tmp;
while (len>(tmp=b->a-b->p)) {
byte_copy(b->x+b->p, tmp, buf);
b->p+=tmp;

@ -36,9 +36,9 @@ void errmsg_writesys(int fd,const char* message,va_list list) {
{
int j;
for (j=0; j<i+2; ++j)
write(2,x[j].iov_base,x[j].iov_len);
write(fd,x[j].iov_base,x[j].iov_len);
}
#else
writev(2,x,i+2);
writev(fd,x,i+2);
#endif
}

@ -6,7 +6,7 @@
#include "ip6.h"
#include "dns.h"
static stralloc data = {0};
static stralloc data;
static int init(char ip[256])
{
@ -58,7 +58,7 @@ static int init(char ip[256])
return 0;
}
static int ok = 0;
static int ok;
static unsigned int uses;
static struct taia deadline;
static char ip[256]; /* defined if ok */

@ -9,14 +9,14 @@
#include <winsock2.h>
#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)
{

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

@ -117,7 +117,7 @@ static int thisudp(struct dns_transmit *d)
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) {
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]);
@ -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);

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

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

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

@ -2,6 +2,7 @@
#include "byte.h"
#include "case.h"
#define _GNU_SOURCE
#define __deprecated__
#include <time.h>
#include <stdlib.h>

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

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

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

Loading…
Cancel
Save