From c874604f12a609325ffc183e6ced21fd552ea934 Mon Sep 17 00:00:00 2001 From: leitner Date: Sat, 23 Apr 2005 15:50:16 +0000 Subject: [PATCH] gcc 4 cleanups (mostly unsigned char* vs char*) --- CHANGES | 1 + GNUmakefile | 4 +++- Makefile | 2 +- buffer.h | 36 ++++++++++++++--------------- buffer/buffer_fromsa.c | 3 +++ buffer/buffer_get.3 | 2 +- buffer/buffer_get.c | 2 +- buffer/buffer_get_new_token_sa.c | 2 +- buffer/buffer_get_token.3 | 4 ++-- buffer/buffer_get_token.c | 2 +- buffer/buffer_get_token_pred.3 | 4 ++-- buffer/buffer_get_token_pred.c | 2 +- buffer/buffer_get_token_sa.3 | 2 +- buffer/buffer_get_token_sa.c | 2 +- buffer/buffer_getc.3 | 2 +- buffer/buffer_getc.c | 2 +- buffer/buffer_getline.3 | 2 +- buffer/buffer_getline.c | 2 +- buffer/buffer_getn.3 | 2 +- buffer/buffer_getn.c | 2 +- buffer/buffer_init.3 | 2 +- buffer/buffer_init.c | 2 +- buffer/buffer_init_free.3 | 2 +- buffer/buffer_init_free.c | 2 +- buffer/buffer_put.3 | 2 +- buffer/buffer_put.c | 4 ++-- buffer/buffer_put8long.c | 2 +- buffer/buffer_putalign.3 | 2 +- buffer/buffer_putalign.c | 2 +- buffer/buffer_putflush.3 | 2 +- buffer/buffer_putflush.c | 2 +- buffer/buffer_putlong.c | 2 +- buffer/buffer_putlonglong.c | 2 +- buffer/buffer_putm_internal.c | 2 +- buffer/buffer_putm_internal_flush.c | 2 +- buffer/buffer_puts.3 | 2 +- buffer/buffer_puts.c | 2 +- buffer/buffer_putsalign.3 | 2 +- buffer/buffer_putsalign.c | 2 +- buffer/buffer_putsflush.3 | 2 +- buffer/buffer_putsflush.c | 2 +- buffer/buffer_putxlong.c | 2 +- buffer/buffer_stubborn.c | 2 +- buffer/buffer_stubborn2.c | 2 +- io/io_passfd.c | 2 +- io/iob_send.c | 9 ++++---- io/iob_write.c | 9 ++++---- ip6.h | 6 ++--- str/str_diff.c | 4 ++-- str/str_diffn.c | 4 ++-- str/str_len.c | 1 + stralloc.h | 14 +++++------ stralloc/stralloc_append.3 | 2 +- stralloc/stralloc_append.c | 2 +- stralloc/stralloc_catb.3 | 2 +- stralloc/stralloc_catb.c | 2 +- stralloc/stralloc_catm.3 | 2 +- stralloc/stralloc_cats.3 | 2 +- stralloc/stralloc_cats.c | 2 +- stralloc/stralloc_copyb.3 | 2 +- stralloc/stralloc_copyb.c | 2 +- stralloc/stralloc_copys.3 | 2 +- stralloc/stralloc_copys.c | 2 +- stralloc/stralloc_diff.c | 2 +- stralloc/stralloc_diffs.3 | 2 +- stralloc/stralloc_diffs.c | 4 ++-- stralloc/stralloc_starts.3 | 2 +- stralloc/stralloc_starts.c | 2 +- t.c | 9 +++++++- 69 files changed, 119 insertions(+), 103 deletions(-) diff --git a/CHANGES b/CHANGES index a398fa0..62099e6 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ also recognize EPFNOSUPPORT as EAFNOSUPPORT (groan) fix a few man pages optimize fmt_base64 (Dan Gundlach) + gcc 4 cleanups (mostly unsigned char* vs char*) 0.22: uh, the scope_id detection #defined the wrong constant. libowfat diff --git a/GNUmakefile b/GNUmakefile index 0940d87..088c8e1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -15,9 +15,11 @@ 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 -Wall -O2 -fomit-frame-pointer +CFLAGS=-pipe -W -Wall -O2 -fomit-frame-pointer #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall +CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 + # startrip ifneq ($(DEBUG),) CFLAGS=-pipe -Wall -g diff --git a/Makefile b/Makefile index 1b67b74..b77a41f 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,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 -Wall -O2 -fomit-frame-pointer +CFLAGS=-pipe -W -Wall -O2 -fomit-frame-pointer #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall array_allocate.o: array/array_allocate.c safemult.h uint16.h \ diff --git a/buffer.h b/buffer.h index eb99429..4c16393 100644 --- a/buffer.h +++ b/buffer.h @@ -2,7 +2,7 @@ #define BUFFER_H typedef struct buffer { - unsigned char *x; /* actual buffer space */ + char *x; /* actual buffer space */ unsigned long int p; /* current position */ unsigned long int n; /* current size of string in buffer */ unsigned long int a; /* allocated buffer size */ @@ -17,18 +17,18 @@ typedef struct buffer { #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 -void buffer_init(buffer* b,int (*op)(),int fd,unsigned char* y,unsigned long int ylen); -void buffer_init_free(buffer* b,int (*op)(),int fd,unsigned char* y,unsigned long int ylen); +void buffer_init(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen); +void buffer_init_free(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen); int buffer_mmapread(buffer* b,const char* filename); void buffer_close(buffer* b); int buffer_flush(buffer* b); -int buffer_put(buffer* b,const unsigned char* x,unsigned long int len); -int buffer_putalign(buffer* b,const unsigned char* x,unsigned long int len); -int buffer_putflush(buffer* b,const unsigned char* x,unsigned long int len); -int buffer_puts(buffer* b,const unsigned char* x); -int buffer_putsalign(buffer* b,const unsigned char* x); -int buffer_putsflush(buffer* b,const unsigned char* x); +int buffer_put(buffer* b,const char* x,unsigned long int len); +int buffer_putalign(buffer* b,const char* x,unsigned long int len); +int buffer_putflush(buffer* b,const char* x,unsigned long int len); +int buffer_puts(buffer* b,const char* x); +int buffer_putsalign(buffer* b,const char* x); +int buffer_putsflush(buffer* b,const char* x); int buffer_putm_internal(buffer*b,...); int buffer_putm_internal_flush(buffer*b,...); @@ -44,24 +44,24 @@ int buffer_putnlflush(buffer* b); /* put \n and flush */ : buffer_put((s),&(c),1) \ ) -int buffer_get(buffer* b,unsigned char* x,unsigned long int len); +int buffer_get(buffer* b,char* x,unsigned long int len); int buffer_feed(buffer* b); -int buffer_getc(buffer* b,unsigned char* x); -int buffer_getn(buffer* b,unsigned char* x,unsigned long int len); +int buffer_getc(buffer* b,char* x); +int buffer_getn(buffer* b,char* x,unsigned long int len); /* read bytes until the destination buffer is full (len bytes), end of * file is reached or the read char is in charset (setlen bytes). An * empty line when looking for \n will write '\n' to x and return 0. If * EOF is reached, \0 is written to the buffer */ -int buffer_get_token(buffer* b,unsigned char* x,unsigned long int len,const unsigned char* charset,unsigned long int setlen); -int buffer_getline(buffer* b,unsigned char* x,unsigned long int len); +int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen); +int buffer_getline(buffer* b,char* x,unsigned long int len); /* this predicate is given the string as currently read from the buffer * and is supposed to return 1 if the token is complete, 0 if not. */ -typedef int (*string_predicate)(const unsigned char* x,unsigned long int len); +typedef int (*string_predicate)(const char* x,unsigned long int len); /* like buffer_get_token but the token ends when your predicate says so */ -int buffer_get_token_pred(buffer* b,unsigned char* x,unsigned long int len,string_predicate p); +int buffer_get_token_pred(buffer* b,char* x,unsigned long int len,string_predicate p); char *buffer_peek(buffer* b); void buffer_seek(buffer* b,unsigned long int len); @@ -112,12 +112,12 @@ int buffer_putsaflush(buffer* b,stralloc* sa); * data is available. */ /* read token from buffer to stralloc */ -int buffer_get_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen); +int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); /* read line from buffer to stralloc */ int buffer_getline_sa(buffer* b,stralloc* sa); /* same as buffer_get_token_sa but empty sa first */ -int buffer_get_new_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen); +int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); /* same as buffer_getline_sa but empty sa first */ int buffer_getnewline_sa(buffer* b,stralloc* sa); diff --git a/buffer/buffer_fromsa.c b/buffer/buffer_fromsa.c index 6c57e43..e57c198 100644 --- a/buffer/buffer_fromsa.c +++ b/buffer/buffer_fromsa.c @@ -2,6 +2,9 @@ #include "buffer.h" static int dummyreadwrite(int fd,char* buf,unsigned long int len) { + (void)fd; + (void)buf; + (void)len; return 0; } diff --git a/buffer/buffer_get.3 b/buffer/buffer_get.3 index 1d1de45..eef6864 100644 --- a/buffer/buffer_get.3 +++ b/buffer/buffer_get.3 @@ -4,7 +4,7 @@ buffer_get \- read binary data from buffer .SH SYNTAX .B #include -int \fBbuffer_get\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_get\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION Normally buffer_get copies data to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] from the beginning of a string stored in diff --git a/buffer/buffer_get.c b/buffer/buffer_get.c index 788f3fd..07290f4 100644 --- a/buffer/buffer_get.c +++ b/buffer/buffer_get.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_get(buffer* b,unsigned char* x,unsigned long int len) { +int buffer_get(buffer* b,char* x,unsigned long int len) { int blen; if ((blen=buffer_feed(b))>=len) blen=len; diff --git a/buffer/buffer_get_new_token_sa.c b/buffer/buffer_get_new_token_sa.c index 51cb3f5..8d7302c 100644 --- a/buffer/buffer_get_new_token_sa.c +++ b/buffer/buffer_get_new_token_sa.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "buffer.h" -int buffer_get_new_token_sa(buffer* b,stralloc* sa,const unsigned char* charset,unsigned long int setlen) { +int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen) { stralloc_zero(sa); return buffer_get_token_sa(b,sa,charset,setlen); } diff --git a/buffer/buffer_get_token.3 b/buffer/buffer_get_token.3 index 0755bb0..41e75fa 100644 --- a/buffer/buffer_get_token.3 +++ b/buffer/buffer_get_token.3 @@ -4,8 +4,8 @@ buffer_get_token \- read token from buffer .SH SYNTAX .B #include -int \fBbuffer_get_token\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR, - const unsigned char* \fIcharset\fR,unsigned long int \fIsetlen\fR); +int \fBbuffer_get_token\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR, + const char* \fIcharset\fR,unsigned long int \fIsetlen\fR); .SH DESCRIPTION buffer_get_token copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or one of diff --git a/buffer/buffer_get_token.c b/buffer/buffer_get_token.c index 9d2391b..8dea559 100644 --- a/buffer/buffer_get_token.c +++ b/buffer/buffer_get_token.c @@ -2,7 +2,7 @@ #include "buffer.h" #include "scan.h" -int buffer_get_token(buffer* b,unsigned char* x,unsigned long int len,const unsigned char* charset,unsigned long int setlen) { +int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen) { int blen; for (blen=0;blen -int \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR, - int (*\fIpredicate\fR)(const unsigned char* \fIs\fR,unsigned long int \fIlen\fR)); +int \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR, + int (*\fIpredicate\fR)(const char* \fIs\fR,unsigned long int \fIlen\fR)); .SH DESCRIPTION buffer_get_token_pred copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been diff --git a/buffer/buffer_get_token_pred.c b/buffer/buffer_get_token_pred.c index 057100f..bd02db8 100644 --- a/buffer/buffer_get_token_pred.c +++ b/buffer/buffer_get_token_pred.c @@ -2,7 +2,7 @@ #include "buffer.h" #include "scan.h" -int buffer_get_token_pred(buffer* b,unsigned char* x,unsigned long int len, +int buffer_get_token_pred(buffer* b,char* x,unsigned long int len, string_predicate p) { int blen; diff --git a/buffer/buffer_get_token_sa.3 b/buffer/buffer_get_token_sa.3 index dc52e4d..209a16e 100644 --- a/buffer/buffer_get_token_sa.3 +++ b/buffer/buffer_get_token_sa.3 @@ -7,7 +7,7 @@ buffer_get_token_sa \- read token from buffer .B #include int \fBbuffer_get_token_sa\fP(buffer* \fIb\fR,stralloc* \fIsa\fR, - const unsigned char* \fIcharset\fR,unsigned long int \fIsetlen\fR); + const char* \fIcharset\fR,unsigned long int \fIsetlen\fR); .SH DESCRIPTION buffer_get_token_sa appends data from the \fIb\fR to \fIsa\fR until one of the delimiters in \fIcharset\fR is found, NOT overwriting the diff --git a/buffer/buffer_get_token_sa.c b/buffer/buffer_get_token_sa.c index 7150ed4..972ae61 100644 --- a/buffer/buffer_get_token_sa.c +++ b/buffer/buffer_get_token_sa.c @@ -4,7 +4,7 @@ #include int buffer_get_token_sa(buffer* b,stralloc* sa, - const unsigned char* charset, + const char* charset, unsigned long int setlen) { for (;;) { char x; diff --git a/buffer/buffer_getc.3 b/buffer/buffer_getc.3 index b299507..3ebc3b7 100644 --- a/buffer/buffer_getc.3 +++ b/buffer/buffer_getc.3 @@ -4,7 +4,7 @@ buffer_getc \- read one char from buffer .SH SYNTAX .B #include -int \fBbuffer_getc\fP(buffer* \fIb\fR,unsigned char* \fIx\fR); +int \fBbuffer_getc\fP(buffer* \fIb\fR,char* \fIx\fR); .SH DESCRIPTION buffer_getc(b,x) is similar to buffer_get(b,x,1). .SH "SEE ALSO" diff --git a/buffer/buffer_getc.c b/buffer/buffer_getc.c index 85d4413..b507c2a 100644 --- a/buffer/buffer_getc.c +++ b/buffer/buffer_getc.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_getc(buffer* b,unsigned char* x) { +int buffer_getc(buffer* b,char* x) { if (b->p==b->n) { register int blen; if ((blen=buffer_feed(b))<=0) return blen; diff --git a/buffer/buffer_getline.3 b/buffer/buffer_getline.3 index 995f01e..1660b68 100644 --- a/buffer/buffer_getline.3 +++ b/buffer/buffer_getline.3 @@ -4,7 +4,7 @@ buffer_getline \- read line from buffer .SH SYNTAX .B #include -int \fBbuffer_getline\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_getline\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION buffer_getline copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or a diff --git a/buffer/buffer_getline.c b/buffer/buffer_getline.c index 675c184..5f8b60a 100644 --- a/buffer/buffer_getline.c +++ b/buffer/buffer_getline.c @@ -1,5 +1,5 @@ #include -int buffer_getline(buffer* b,unsigned char* x,unsigned long int len) { +int buffer_getline(buffer* b,char* x,unsigned long int len) { return buffer_get_token(b,x,len,"\n",1); } diff --git a/buffer/buffer_getn.3 b/buffer/buffer_getn.3 index 3851396..127b5c7 100644 --- a/buffer/buffer_getn.3 +++ b/buffer/buffer_getn.3 @@ -4,7 +4,7 @@ buffer_getn \- read binary data from buffer .SH SYNTAX .B #include -int \fBbuffer_getn\fP(buffer* \fIb\fR,unsigned char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_getn\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION buffer_getn copies data to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] from the buffer, calling buffer_feed as needed, and diff --git a/buffer/buffer_getn.c b/buffer/buffer_getn.c index 78affde..69e19fc 100644 --- a/buffer/buffer_getn.c +++ b/buffer/buffer_getn.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_getn(buffer* b,unsigned char* x,unsigned long int len) { +int buffer_getn(buffer* b,char* x,unsigned long int len) { int blen; for(blen=0;blenop=op; b->fd=fd; b->x=y; diff --git a/buffer/buffer_init_free.3 b/buffer/buffer_init_free.3 index 1ceb2fb..502b46f 100644 --- a/buffer/buffer_init_free.3 +++ b/buffer/buffer_init_free.3 @@ -6,7 +6,7 @@ buffer_init_free \- initialize buffer structure void \fBbuffer_init_free\fR(buffer &\fIb\fR, int (*\fIop\fR)(int,char*,unsigned int), - int \fIfd\fR, unsigned char* \fIy\fR, unsigned long int \fIylen\fR); + int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR); .SH DESCRIPTION buffer_init_free is like buffer_init except that the memory (\fIy\fR is marked to be freed by buffer_close(). diff --git a/buffer/buffer_init_free.c b/buffer/buffer_init_free.c index 4fe851e..73fc662 100644 --- a/buffer/buffer_init_free.c +++ b/buffer/buffer_init_free.c @@ -1,7 +1,7 @@ #include "buffer.h" void buffer_init_free(buffer* b,int (*op)(),int fd, - unsigned char* y,unsigned long int ylen) { + char* y,unsigned long int ylen) { buffer_init(b,op,fd,y,ylen); b->todo=FREE; } diff --git a/buffer/buffer_put.3 b/buffer/buffer_put.3 index 89db53e..59557d8 100644 --- a/buffer/buffer_put.3 +++ b/buffer/buffer_put.3 @@ -4,7 +4,7 @@ buffer_put \- write binary data to buffer .SH SYNTAX .B #include -int \fBbuffer_put\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_put\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION buffer_put writes \fIlen\fR bytes from \fIx\fR to \fIb\fR. diff --git a/buffer/buffer_put.c b/buffer/buffer_put.c index 953ae5e..7c1b637 100644 --- a/buffer/buffer_put.c +++ b/buffer/buffer_put.c @@ -1,9 +1,9 @@ #include "byte.h" #include "buffer.h" -extern int buffer_stubborn(int (*op)(),int fd,const unsigned char* buf, unsigned long int len); +extern int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len); -int buffer_put(buffer* b,const unsigned char* buf,unsigned long int len) { +int buffer_put(buffer* b,const char* buf,unsigned long int len) { if (len>b->a-b->p) { /* doesn't fit */ if (buffer_flush(b)==-1) return -1; if (len>b->a) { diff --git a/buffer/buffer_put8long.c b/buffer/buffer_put8long.c index b987b04..8ee0a7b 100644 --- a/buffer/buffer_put8long.c +++ b/buffer/buffer_put8long.c @@ -2,7 +2,7 @@ #include "fmt.h" int buffer_put8long(buffer *b,unsigned long l) { - unsigned char buf[FMT_8LONG]; + char buf[FMT_8LONG]; return buffer_put(b,buf,fmt_8long(buf,l)); } diff --git a/buffer/buffer_putalign.3 b/buffer/buffer_putalign.3 index 928e637..3f849cf 100644 --- a/buffer/buffer_putalign.3 +++ b/buffer/buffer_putalign.3 @@ -4,7 +4,7 @@ buffer_putalign \- write binary data to buffer .SH SYNTAX .B #include -int \fBbuffer_putalign\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_putalign\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION buffer_putalign is similar to buffer_put. diff --git a/buffer/buffer_putalign.c b/buffer/buffer_putalign.c index ab11b11..435b820 100644 --- a/buffer/buffer_putalign.c +++ b/buffer/buffer_putalign.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_putalign(buffer* b,const unsigned char* buf,unsigned long int len) { +int buffer_putalign(buffer* b,const char* buf,unsigned long int len) { int tmp; while (len>(tmp=b->a-b->p)) { byte_copy(b->x+b->p, tmp, buf); diff --git a/buffer/buffer_putflush.3 b/buffer/buffer_putflush.3 index 9c0673e..48e4122 100644 --- a/buffer/buffer_putflush.3 +++ b/buffer/buffer_putflush.3 @@ -5,7 +5,7 @@ buffer_putflush \- write binary data to buffer and flush .B #include int \fBbuffer_putflush\fP(buffer* \fIb\fR, - const unsigned char* \fIx\fR,unsigned long int \fIlen\fR); + const char* \fIx\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION buffer_putflush is similar to calling buffer_put(\fIb\fR,\fIx\fR,\fIlen\fR) and then buffer_flush(\fIb\fR). diff --git a/buffer/buffer_putflush.c b/buffer/buffer_putflush.c index b47742f..f26960d 100644 --- a/buffer/buffer_putflush.c +++ b/buffer/buffer_putflush.c @@ -1,6 +1,6 @@ #include "buffer.h" -int buffer_putflush(buffer* b,const unsigned char* x,unsigned long int len) { +int buffer_putflush(buffer* b,const char* x,unsigned long int len) { if (buffer_put(b,x,len)<0) return -1; if (buffer_flush(b)<0) return -1; return 0; diff --git a/buffer/buffer_putlong.c b/buffer/buffer_putlong.c index 0806f31..c622f34 100644 --- a/buffer/buffer_putlong.c +++ b/buffer/buffer_putlong.c @@ -2,7 +2,7 @@ #include "fmt.h" int buffer_putlong(buffer *b,signed long l) { - unsigned char buf[FMT_LONG]; + char buf[FMT_LONG]; return buffer_put(b,buf,fmt_long(buf,l)); } diff --git a/buffer/buffer_putlonglong.c b/buffer/buffer_putlonglong.c index a4ee4b3..efbcbfe 100644 --- a/buffer/buffer_putlonglong.c +++ b/buffer/buffer_putlonglong.c @@ -2,7 +2,7 @@ #include "fmt.h" int buffer_putlonglong(buffer *b,signed long long l) { - unsigned char buf[FMT_LONG]; + char buf[FMT_LONG]; return buffer_put(b,buf,fmt_longlong(buf,l)); } diff --git a/buffer/buffer_putm_internal.c b/buffer/buffer_putm_internal.c index 6212b4d..1370600 100644 --- a/buffer/buffer_putm_internal.c +++ b/buffer/buffer_putm_internal.c @@ -6,7 +6,7 @@ int buffer_putm_internal(buffer* b, ...) { va_list a; const char* s; va_start(a,b); - while ((s=va_arg(a,const unsigned char*))) + while ((s=va_arg(a,const char*))) if (buffer_puts(b,s)==-1) { r=-1; break; diff --git a/buffer/buffer_putm_internal_flush.c b/buffer/buffer_putm_internal_flush.c index f007c4c..a5afbcb 100644 --- a/buffer/buffer_putm_internal_flush.c +++ b/buffer/buffer_putm_internal_flush.c @@ -6,7 +6,7 @@ int buffer_putm_internal_flush(buffer* b, ...) { va_list a; const char* s; va_start(a,b); - while ((s=va_arg(a,const unsigned char*))) + while ((s=va_arg(a,const char*))) if (buffer_puts(b,s)==-1) { r=-1; break; diff --git a/buffer/buffer_puts.3 b/buffer/buffer_puts.3 index 196e673..72a16c5 100644 --- a/buffer/buffer_puts.3 +++ b/buffer/buffer_puts.3 @@ -4,7 +4,7 @@ buffer_puts \- write ASCIIZ string to buffer .SH SYNTAX .B #include -int \fBbuffer_puts\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR); +int \fBbuffer_puts\fP(buffer* \fIb\fR,const char* \fIx\fR); .SH DESCRIPTION buffer_puts is like buffer_put with \fIlen\fR determined as the number of bytes before the first \\0 in \fIx\fR. diff --git a/buffer/buffer_puts.c b/buffer/buffer_puts.c index fe13221..e53f675 100644 --- a/buffer/buffer_puts.c +++ b/buffer/buffer_puts.c @@ -1,6 +1,6 @@ #include "str.h" #include "buffer.h" -int buffer_puts(buffer* b,const unsigned char* x) { +int buffer_puts(buffer* b,const char* x) { return buffer_put(b,x,str_len(x)); } diff --git a/buffer/buffer_putsalign.3 b/buffer/buffer_putsalign.3 index e0d02cd..49912d8 100644 --- a/buffer/buffer_putsalign.3 +++ b/buffer/buffer_putsalign.3 @@ -4,7 +4,7 @@ buffer_putsalign \- write ASCIIZ string to buffer .SH SYNTAX .B #include -int \fBbuffer_putsalign\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR); +int \fBbuffer_putsalign\fP(buffer* \fIb\fR,const char* \fIx\fR); .SH DESCRIPTION buffer_putsalign is like buffer_putalign with \fIlen\fR determined as the number of bytes before the first \\0 in \fIx\fR. diff --git a/buffer/buffer_putsalign.c b/buffer/buffer_putsalign.c index 2853483..2693e5c 100644 --- a/buffer/buffer_putsalign.c +++ b/buffer/buffer_putsalign.c @@ -1,6 +1,6 @@ #include "str.h" #include "buffer.h" -int buffer_putsalign(buffer* b,const unsigned char* x) { +int buffer_putsalign(buffer* b,const char* x) { return buffer_putalign(b,x,str_len(x)); } diff --git a/buffer/buffer_putsflush.3 b/buffer/buffer_putsflush.3 index 3e2b533..ad5199d 100644 --- a/buffer/buffer_putsflush.3 +++ b/buffer/buffer_putsflush.3 @@ -4,7 +4,7 @@ buffer_putsflush \- write ASCIIZ string to buffer and flush .SH SYNTAX .B #include -int \fBbuffer_putsflush\fP(buffer* \fIb\fR,const unsigned char* \fIx\fR); +int \fBbuffer_putsflush\fP(buffer* \fIb\fR,const char* \fIx\fR); .SH DESCRIPTION buffer_putsflush is like buffer_putflush with \fIlen\fR determined as the number of bytes before the first \\0 in \fIx\fR. diff --git a/buffer/buffer_putsflush.c b/buffer/buffer_putsflush.c index e0185d3..e01762d 100644 --- a/buffer/buffer_putsflush.c +++ b/buffer/buffer_putsflush.c @@ -1,6 +1,6 @@ #include "str.h" #include "buffer.h" -int buffer_putsflush(buffer* b,const unsigned char* x) { +int buffer_putsflush(buffer* b,const char* x) { return buffer_putflush(b,x,str_len(x)); } diff --git a/buffer/buffer_putxlong.c b/buffer/buffer_putxlong.c index 22ee6eb..7938646 100644 --- a/buffer/buffer_putxlong.c +++ b/buffer/buffer_putxlong.c @@ -2,7 +2,7 @@ #include "fmt.h" int buffer_putxlong(buffer *b,unsigned long l) { - unsigned char buf[FMT_XLONG]; + char buf[FMT_XLONG]; return buffer_put(b,buf,fmt_xlong(buf,l)); } diff --git a/buffer/buffer_stubborn.c b/buffer/buffer_stubborn.c index c206608..2ddcbdf 100644 --- a/buffer/buffer_stubborn.c +++ b/buffer/buffer_stubborn.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -int buffer_stubborn(int (*op)(),int fd,const unsigned char* buf, unsigned long int len) { +int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len) { int w; while (len) { if ((w=op(fd,buf,len))<0) { diff --git a/buffer/buffer_stubborn2.c b/buffer/buffer_stubborn2.c index a54e089..0064503 100644 --- a/buffer/buffer_stubborn2.c +++ b/buffer/buffer_stubborn2.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -int buffer_stubborn_read(int (*op)(),int fd,const unsigned char* buf, unsigned long int len) { +int buffer_stubborn_read(int (*op)(),int fd,const char* buf, unsigned long int len) { int w; for (;;) { if ((w=op(fd,buf,len))<0) diff --git a/io/io_passfd.c b/io/io_passfd.c index 8d66081..fcfa99c 100644 --- a/io/io_passfd.c +++ b/io/io_passfd.c @@ -22,7 +22,7 @@ union fdmsg { }; int io_passfd(int64 sock,int64 fd) { - struct msghdr msg = {0}; + struct msghdr msg; struct iovec iov; #ifdef CMSG_LEN struct cmsghdr *cmsg; diff --git a/io/iob_send.c b/io/iob_send.c index 94faca0..8a0b9e4 100644 --- a/io/iob_send.c +++ b/io/iob_send.c @@ -13,7 +13,8 @@ int64 iob_send(int64 s,io_batch* b) { iob_entry* e,* last; struct iovec* v; - int64 total,sent; + uint64 total; + int64 sent; long i; long headers; #ifdef HAVE_BSDSENDFILE @@ -101,8 +102,8 @@ eagain: if (sent>0) total+=sent; else - return total?total:sent; - if (sent==b->bytesleft) { + return total?total:(uint64)sent; + if ((uint64)sent==b->bytesleft) { #ifdef TCP_CORK if (b->bufs && b->files) { static int zero=0; @@ -112,7 +113,7 @@ eagain: iob_reset(b); break; } else if (sent>0) { - int64 rest=sent; + uint64 rest=sent; b->bytesleft-=rest; for (i=0; e+i0 && sent>e[i].n) sent=e[i].n; /* can't happen */ - thatsit=(sent != e[i].n); + if (sent>0 && (uint64)sent>e[i].n) sent=e[i].n; /* can't happen */ + thatsit=((uint64)sent != e[i].n); if (sent<=0) - return total?total:sent; + return total?total:(uint64)sent; e[i].offset+=sent; e[i].n-=sent; total+=sent; diff --git a/ip6.h b/ip6.h index c71615c..2104d37 100644 --- a/ip6.h +++ b/ip6.h @@ -25,9 +25,9 @@ unsigned int fmt_ip6_flat(char *dest,const char *); #define IP6_FMT 40 -extern const unsigned char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */ -extern const unsigned char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */ -extern const unsigned char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */ +extern const char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */ +extern const char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */ +extern const char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */ #define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix)) diff --git a/str/str_diff.c b/str/str_diff.c index fe74e80..36d016d 100644 --- a/str/str_diff.c +++ b/str/str_diff.c @@ -6,8 +6,8 @@ * When the strings are different, str_diff does not read bytes past the * first difference. */ int str_diff(const char* a, const char* b) { - register const char* s=a; - register const char* t=b; + register const unsigned char* s=(const unsigned char*)a; + register const unsigned char* t=(const unsigned char*)b; register int j; j=0; for (;;) { diff --git a/str/str_diffn.c b/str/str_diffn.c index 2de963a..7a6ef3f 100644 --- a/str/str_diffn.c +++ b/str/str_diffn.c @@ -6,8 +6,8 @@ * When the strings are different, str_diff does not read bytes past the * first difference. */ int str_diffn(const char* a, const char* b, unsigned long limit) { - register const char* s=a; - register const char* t=b; + 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 int j; j=0; diff --git a/str/str_len.c b/str/str_len.c index 75d9ea3..a6b8c8d 100644 --- a/str/str_len.c +++ b/str/str_len.c @@ -1,3 +1,4 @@ +#undef __dietlibc__ #include "str.h" unsigned long str_len(const char* in) { diff --git a/stralloc.h b/stralloc.h index 3fe8eff..283b4fc 100644 --- a/stralloc.h +++ b/stralloc.h @@ -42,12 +42,12 @@ int stralloc_readyplus(stralloc* sa,unsigned long int len); /* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into * sa, allocating space if necessary, and returns 1. If it runs out of * memory, stralloc_copyb leaves sa alone and returns 0. */ -int stralloc_copyb(stralloc* sa,const unsigned char* buf,unsigned long int len); +int stralloc_copyb(stralloc* sa,const char* buf,unsigned long int len); /* stralloc_copys copies a \0-terminated string from buf into sa, * without the \0. It is the same as * stralloc_copyb(&sa,buf,str_len(buf)). */ -int stralloc_copys(stralloc* sa,const unsigned char* buf); +int stralloc_copys(stralloc* sa,const char* buf); /* stralloc_copy copies the string stored in sa2 into sa. It is the same * as stralloc_copyb(&sa,sa2.s,sa2.len). sa2 must already be allocated. */ @@ -58,10 +58,10 @@ int stralloc_copy(stralloc* sa,const stralloc* sa2); * returns 1. If sa is unallocated, stralloc_catb is the same as * stralloc_copyb. If it runs out of memory, stralloc_catb leaves sa * alone and returns 0. */ -int stralloc_catb(stralloc* sa,const unsigned char* in,unsigned long int len); +int stralloc_catb(stralloc* sa,const char* in,unsigned long int len); /* stralloc_cats is analogous to stralloc_copys */ -int stralloc_cats(stralloc* sa,const unsigned char* in); +int stralloc_cats(stralloc* sa,const char* in); void stralloc_zero(stralloc* sa); @@ -76,12 +76,12 @@ int stralloc_cat(stralloc* sa,stralloc* in); /* stralloc_append adds one byte in[0] to the end of the string stored * in sa. It is the same as stralloc_catb(&sa,in,1). */ -int stralloc_append(stralloc* sa,const unsigned char* in); /* beware: this takes a pointer to 1 char */ +int stralloc_append(stralloc* sa,const char* in); /* beware: this takes a pointer to 1 char */ /* stralloc_starts returns 1 if the \0-terminated string in "in", without * the terminating \0, is a prefix of the string stored in sa. Otherwise * it returns 0. sa must already be allocated. */ -int stralloc_starts(stralloc* sa,const unsigned char* in) __pure__; +int stralloc_starts(stralloc* sa,const char* in) __pure__; /* stralloc_diff returns negative, 0, or positive, depending on whether * a is lexicographically smaller than, equal to, or greater than the @@ -91,7 +91,7 @@ int stralloc_diff(const stralloc* a,const stralloc* b) __pure__; /* stralloc_diffs returns negative, 0, or positive, depending on whether * a is lexicographically smaller than, equal to, or greater than the * string b[0], b[1], ..., b[n]=='\0'. */ -int stralloc_diffs(const stralloc* a,const unsigned char* b) __pure__; +int stralloc_diffs(const stralloc* a,const char* b) __pure__; #define stralloc_equal(a,b) (!stralloc_diff((a),(b))) #define stralloc_equals(a,b) (!stralloc_diffs((a),(b))) diff --git a/stralloc/stralloc_append.3 b/stralloc/stralloc_append.3 index 6719fbc..bcc7bf6 100644 --- a/stralloc/stralloc_append.3 +++ b/stralloc/stralloc_append.3 @@ -4,7 +4,7 @@ stralloc_append \- append a character to a stralloc .SH SYNTAX .B #include -int \fBstralloc_append\fP(stralloc* \fIsa\fR,const unsigned char* \fIin\fR); +int \fBstralloc_append\fP(stralloc* \fIsa\fR,const char* \fIin\fR); .SH DESCRIPTION stralloc_append appends the byte from *\fIbuf\fR to the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_append.c b/stralloc/stralloc_append.c index 42156ec..70c06c8 100644 --- a/stralloc/stralloc_append.c +++ b/stralloc/stralloc_append.c @@ -2,7 +2,7 @@ /* stralloc_append adds one byte in[0] to the end of the string stored * in sa. It is the same as stralloc_catb(&sa,in,1). */ -int stralloc_append(stralloc *sa,const unsigned char *in) { +int stralloc_append(stralloc *sa,const char *in) { if (stralloc_readyplus(sa,1)) { sa->s[sa->len]=*in; ++sa->len; diff --git a/stralloc/stralloc_catb.3 b/stralloc/stralloc_catb.3 index 351aa52..1fc7bbf 100644 --- a/stralloc/stralloc_catb.3 +++ b/stralloc/stralloc_catb.3 @@ -4,7 +4,7 @@ stralloc_catb \- append data to a stralloc .SH SYNTAX .B #include -int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR,unsigned long int \fIlen\fR); +int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION stralloc_catb adds the string \fIbuf\fR[0], \fIbuf\fR[1], ... \fIbuf\fR[\fIlen\fR-1] to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_catb.c b/stralloc/stralloc_catb.c index a7bda3c..368a9ba 100644 --- a/stralloc/stralloc_catb.c +++ b/stralloc/stralloc_catb.c @@ -6,7 +6,7 @@ * returns 1. If sa is unallocated, stralloc_catb is the same as * stralloc_copyb. If it runs out of memory, stralloc_catb leaves sa * alone and returns 0. */ -int stralloc_catb(stralloc *sa,const unsigned char *buf,unsigned long int len) { +int stralloc_catb(stralloc *sa,const char *buf,unsigned long int len) { if (stralloc_readyplus(sa,len)) { byte_copy(sa->s+sa->len,len,buf); sa->len+=len; diff --git a/stralloc/stralloc_catm.3 b/stralloc/stralloc_catm.3 index e069e64..cce5540 100644 --- a/stralloc/stralloc_catm.3 +++ b/stralloc/stralloc_catm.3 @@ -4,7 +4,7 @@ stralloc_catm \- append string(s) to a stralloc .SH SYNTAX .B #include -int \fBstralloc_catm\fP(stralloc* \fIsa\fR,const unsigned char* \fIs\fR, ...); +int \fBstralloc_catm\fP(stralloc* \fIsa\fR,const char* \fIs\fR, ...); .SH DESCRIPTION stralloc_catm appends \\0-terminated strings from \fIs\fR... to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_cats.3 b/stralloc/stralloc_cats.3 index 4d94216..c99d59e 100644 --- a/stralloc/stralloc_cats.3 +++ b/stralloc/stralloc_cats.3 @@ -4,7 +4,7 @@ stralloc_cats \- append data to a stralloc .SH SYNTAX .B #include -int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR); +int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); .SH DESCRIPTION stralloc_cats appends a \\0-terminated string from \fIbuf\fR to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_cats.c b/stralloc/stralloc_cats.c index 01f54a9..483f099 100644 --- a/stralloc/stralloc_cats.c +++ b/stralloc/stralloc_cats.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "str.h" -extern int stralloc_cats(stralloc *sa,const unsigned char *buf) { +extern int stralloc_cats(stralloc *sa,const char *buf) { return stralloc_catb(sa,buf,str_len(buf)); } diff --git a/stralloc/stralloc_copyb.3 b/stralloc/stralloc_copyb.3 index eea3d5b..c5ba390 100644 --- a/stralloc/stralloc_copyb.3 +++ b/stralloc/stralloc_copyb.3 @@ -4,7 +4,7 @@ stralloc_copyb \- copy data into a stralloc .SH SYNTAX .B #include -int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR,unsigned long int \fIlen\fR); +int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR); .SH DESCRIPTION stralloc_copyb makes sure that \fIsa\fR has enough space allocated to hold \fIlen\fR bytes. Then it copies the first \fIlen\fR bytes from diff --git a/stralloc/stralloc_copyb.c b/stralloc/stralloc_copyb.c index ec9267a..70e4a71 100644 --- a/stralloc/stralloc_copyb.c +++ b/stralloc/stralloc_copyb.c @@ -4,7 +4,7 @@ /* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into * sa, allocating space if necessary, and returns 1. If it runs out of * memory, stralloc_copyb leaves sa alone and returns 0. */ -int stralloc_copyb(stralloc *sa,const unsigned char *buf,unsigned long int len) { +int stralloc_copyb(stralloc *sa,const char *buf,unsigned long int len) { if (stralloc_ready(sa,len)) { sa->len=len; byte_copy(sa->s,len,buf); diff --git a/stralloc/stralloc_copys.3 b/stralloc/stralloc_copys.3 index 80e8672..3cd577f 100644 --- a/stralloc/stralloc_copys.3 +++ b/stralloc/stralloc_copys.3 @@ -4,7 +4,7 @@ stralloc_copys \- copy data into a stralloc .SH SYNTAX .B #include -int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const unsigned char* \fIbuf\fR); +int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR); .SH DESCRIPTION stralloc_copys copies a \\0-terminated string from \fIbuf\fR into \fIsa\fR, without the \\0. It is the same as diff --git a/stralloc/stralloc_copys.c b/stralloc/stralloc_copys.c index d03c3d4..80360ea 100644 --- a/stralloc/stralloc_copys.c +++ b/stralloc/stralloc_copys.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "str.h" -extern int stralloc_copys(stralloc *sa,const unsigned char *buf) { +extern int stralloc_copys(stralloc *sa,const char *buf) { return stralloc_copyb(sa,buf,str_len(buf)); } diff --git a/stralloc/stralloc_diff.c b/stralloc/stralloc_diff.c index 9e00378..fa95756 100644 --- a/stralloc/stralloc_diff.c +++ b/stralloc/stralloc_diff.c @@ -7,7 +7,7 @@ extern int stralloc_diff(const stralloc* a,const stralloc* b) { register int j; for (i=0;;++i) { if (i==a->len) return i==b->len?0:-1; if (i==b->len) return 1; - if ((j=(a->s[i]-b->s[i]))) return j; + if ((j=((unsigned char)(a->s[i])-(unsigned char)(b->s[i])))) return j; } return j; } diff --git a/stralloc/stralloc_diffs.3 b/stralloc/stralloc_diffs.3 index 1aa81d4..1f1cb84 100644 --- a/stralloc/stralloc_diffs.3 +++ b/stralloc/stralloc_diffs.3 @@ -4,7 +4,7 @@ stralloc_diffs \- check if string is prefix of stralloc .SH SYNTAX .B #include -int \fBstralloc_diffs\fP(stralloc* \fIa\fR,const unsigned char* \fIb\fR); +int \fBstralloc_diffs\fP(stralloc* \fIa\fR,const char* \fIb\fR); .SH DESCRIPTION stralloc_diffs returns negative, 0, or positive, depending on whether the \\0-terminated string in \fIa\fR, without diff --git a/stralloc/stralloc_diffs.c b/stralloc/stralloc_diffs.c index e5cac51..8a142f6 100644 --- a/stralloc/stralloc_diffs.c +++ b/stralloc/stralloc_diffs.c @@ -2,12 +2,12 @@ #include "byte.h" #include "str.h" -extern int stralloc_diffs(const stralloc* a,const unsigned char* b) { +extern int stralloc_diffs(const stralloc* a,const char* b) { register unsigned long int i; register int j; for (i=0;;++i) { if (i==a->len) return (!b[i])?0:-1; if (!b[i]) return 1; - if ((j=(a->s[i]-b[i]))) return j; + if ((j=((unsigned char)(a->s[i])-(unsigned char)(b[i])))) return j; } return j; } diff --git a/stralloc/stralloc_starts.3 b/stralloc/stralloc_starts.3 index c2a56e6..e0bef9f 100644 --- a/stralloc/stralloc_starts.3 +++ b/stralloc/stralloc_starts.3 @@ -4,7 +4,7 @@ stralloc_starts \- check if string is prefix of stralloc .SH SYNTAX .B #include -int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const unsigned char* \fIin\fR); +int \fBstralloc_starts\fP(stralloc* \fIsa\fR,const char* \fIin\fR); .SH DESCRIPTION stralloc_starts returns 1 if the \\0-terminated string in \fIin\fR, without the terminating \\0, is a prefix of the string stored in \fIsa\fR. Otherwise diff --git a/stralloc/stralloc_starts.c b/stralloc/stralloc_starts.c index 5896ac9..a1decc1 100644 --- a/stralloc/stralloc_starts.c +++ b/stralloc/stralloc_starts.c @@ -2,7 +2,7 @@ #include "byte.h" #include "str.h" -extern int stralloc_starts(stralloc *sa,const unsigned char *in) { +extern int stralloc_starts(stralloc *sa,const char *in) { register unsigned long int len=str_len(in); return (len<=sa->len && !byte_diff(sa->s,len,in)); } diff --git a/t.c b/t.c index cfd9796..edb26b2 100644 --- a/t.c +++ b/t.c @@ -26,6 +26,9 @@ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") int64 writecb(int64 fd,const void* buf,uint64 n) { + (void)fd; + (void)buf; + (void)n; #if 0 int r; int todo=n>=65536?65536:n; @@ -37,6 +40,8 @@ int64 writecb(int64 fd,const void* buf,uint64 n) { } int main(int argc,char* argv[]) { + (void)argc; + (void)argv; #if 0 io_batch* b=iob_new(1234); int64 fd=open("t.c",0); @@ -312,7 +317,7 @@ int main(int argc,char* argv[]) { rdtscl(c); printf("%lu %lu\n",b-a,c-b); #endif -#if 1 +#if 0 unsigned long size; char* buf=mmap_read(argv[1],&size); if (buf) { @@ -323,6 +328,8 @@ int main(int argc,char* argv[]) { write(1,tmp,x); } #endif + printf("%d %d\n",strcmp("foo","bar"),str_diff("foo","bar")); + printf("%d %d\n",strcmp("foo","üar"),str_diff("foo","üar")); return 0; }