From 0b30b66db112cc63c8648c6a3dab59c40be97534 Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 25 Nov 2004 21:52:35 +0000 Subject: [PATCH] remove warnings in tests --- array.h | 4 ++-- test/array.c | 2 +- test/b64decode.c | 2 +- test/b64encode.c | 2 +- test/buffer_1.c | 3 ++- test/buffer_fromsa.c | 1 + test/byte_copy.c | 1 + test/cescape.c | 3 ++- test/client.c | 2 ++ test/dllink.c | 3 ++- test/dnsip.c | 4 +++- test/fdpassing.c | 3 ++- test/fmt_httpdate.c | 3 ++- test/fmt_human.c | 3 ++- test/fmt_long.c | 3 ++- test/fmt_longlong.c | 4 +++- test/httpd.c | 12 +++++------- test/io3.c | 5 +++-- test/io4.c | 4 +++- test/io5.c | 3 ++- test/iob.c | 3 ++- test/readhttp.c | 1 + test/scan.c | 2 +- test/scan_long.c | 3 ++- test/server.c | 2 ++ test/stralloc_buffer.c | 3 ++- test/stralloc_chomp.c | 2 +- test/textcode.c | 2 ++ test/unurl.c | 5 +++-- test/urlencode.c | 3 ++- test/uudecode.c | 10 ++++++---- test/vd.c | 7 +++++-- 32 files changed, 71 insertions(+), 39 deletions(-) diff --git a/array.h b/array.h index 9241524..658d7e5 100644 --- a/array.h +++ b/array.h @@ -1,5 +1,5 @@ -#ifndef _ARRAY_H -#define _ARRAY_H +#ifndef ARRAY_H +#define ARRAY_H #include "uint64.h" #include diff --git a/test/array.c b/test/array.c index 1797f25..3aa3de1 100644 --- a/test/array.c +++ b/test/array.c @@ -2,7 +2,7 @@ #include "array.h" #include "byte.h" -main() { +int main() { static array x,y; array_cats(&x,"fnord"); array_cats(&y,"foobar"); diff --git a/test/b64decode.c b/test/b64decode.c index 04afe28..a3bee12 100644 --- a/test/b64decode.c +++ b/test/b64decode.c @@ -11,7 +11,7 @@ void b64encode(const char* c) { buffer_put(buffer_1,buf,dlen); } -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int i; for (i=1; i void cescape(const char* c) { char* buf=alloca(strlen(c)*5+1); @@ -9,7 +10,7 @@ void cescape(const char* c) { buffer_putnlflush(buffer_1); } -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int i; for (i=1; i void panic(const char* s) { int i=str_len(s); @@ -102,4 +103,5 @@ usage: } } } + return 0; } diff --git a/test/dllink.c b/test/dllink.c index 8bf4ed3..bf7fe88 100644 --- a/test/dllink.c +++ b/test/dllink.c @@ -6,7 +6,7 @@ #include #include "case.h" -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int s=socket_tcp4(); char line[1024]; char buf[4096]; @@ -48,4 +48,5 @@ main(int argc,char* argv[]) { } } buffer_flush(buffer_1); + return 0; } diff --git a/test/dnsip.c b/test/dnsip.c index 6f01900..11e47d5 100644 --- a/test/dnsip.c +++ b/test/dnsip.c @@ -9,7 +9,9 @@ int main(int argc,char* argv[]) { static stralloc fqdn; static stralloc out; char str[IP4_FMT]; - int i; + unsigned int i; + + (void)argc; dns_random_init(seed); if (*argv) ++argv; diff --git a/test/fdpassing.c b/test/fdpassing.c index ccceede..de0b6de 100644 --- a/test/fdpassing.c +++ b/test/fdpassing.c @@ -1,6 +1,7 @@ #include #include "io.h" #include "buffer.h" +#include void child(int64 fd) { int64 x=io_receivefd(fd); @@ -21,7 +22,7 @@ void father(int64 fd) { io_passfd(fd,x); } -main() { +int main() { int64 sp[2]; if (io_socketpair(sp)==-1) return 1; switch (fork()) { diff --git a/test/fmt_httpdate.c b/test/fmt_httpdate.c index af7e575..ce31dea 100644 --- a/test/fmt_httpdate.c +++ b/test/fmt_httpdate.c @@ -3,7 +3,7 @@ #include #include -main() { +int main() { char buf[100]; time_t s,t; buffer_put(buffer_1,buf,fmt_httpdate(buf,time(&s))); @@ -14,4 +14,5 @@ main() { buffer_puts(buffer_1," vs. "); buffer_putulong(buffer_1,t); buffer_putnlflush(buffer_1); + return 0; } diff --git a/test/fmt_human.c b/test/fmt_human.c index 6bcca8f..abfa406 100644 --- a/test/fmt_human.c +++ b/test/fmt_human.c @@ -1,10 +1,11 @@ #include #include -main() { +int main() { char buf[1024]; buffer_put(buffer_1,buf,fmt_human(buf,1)); buffer_putnlflush(buffer_1); buffer_put(buffer_1,buf,fmt_human(buf,1400)); buffer_putnlflush(buffer_1); buffer_put(buffer_1,buf,fmt_human(buf,2300000)); buffer_putnlflush(buffer_1); buffer_put(buffer_1,buf,fmt_human(buf,(unsigned long long)(-1ll))); buffer_putnlflush(buffer_1); + return 0; } diff --git a/test/fmt_long.c b/test/fmt_long.c index 4addb95..46f40fb 100644 --- a/test/fmt_long.c +++ b/test/fmt_long.c @@ -2,7 +2,7 @@ #include #include -main() { +int main() { char buf[1024]; assert(fmt_long(0,12345)==5); @@ -11,4 +11,5 @@ main() { assert(str_equal(buf,"12345")); assert(fmt_long(buf,-12345)==6); buf[6]=0; assert(str_equal(buf,"-12345")); + return 0; } diff --git a/test/fmt_longlong.c b/test/fmt_longlong.c index 357d3dd..796f0fa 100644 --- a/test/fmt_longlong.c +++ b/test/fmt_longlong.c @@ -1,8 +1,9 @@ #include #include #include +#include -main() { +int main() { char buf[1024]; long long l; @@ -24,4 +25,5 @@ main() { assert(fmt_longlong(buf,-1234567890)==11); buf[11]=0; assert(str_equal(buf,"-1234567890")); assert(scan_longlong(buf,&l)==11); assert(l==-1234567890); + return 0; } diff --git a/test/httpd.c b/test/httpd.c index 766d2d2..c48c7b4 100644 --- a/test/httpd.c +++ b/test/httpd.c @@ -49,7 +49,6 @@ int header_complete(struct http_data* r) { } void httperror(struct http_data* r,const char* title,const char* message) { - int i; char* c; c=r->hdrbuf=(char*)malloc(strlen(message)+strlen(title)+200); if (!c) { @@ -100,7 +99,7 @@ static struct mimeentry { const char* name, *type; } mimetab[] = { { "xbm", "image/x-xbitmap" }, { "xpm", "image/x-xpixmap" }, { "xwd", "image/x-xwindowdump" }, - { 0 } }; + { 0,0 } }; const char* mimetype(const char* filename) { int i,e=str_rchr(filename,'.'); @@ -127,7 +126,6 @@ const char* http_header(struct http_data* r,const char* h) { } void httpresponse(struct http_data* h,int64 s) { - int i; char* c; const char* m; array_cat0(&h->r); @@ -153,7 +151,7 @@ e404: io_close(fd); goto e404; } - if (m=http_header(h,"Connection")) { + if ((m=http_header(h,"Connection"))) { if (str_equal(m,"keep-alive")) h->keepalive=1; else @@ -183,8 +181,7 @@ e404: io_wantwrite(s); } -main() { - static array a; +int main() { int s=socket_tcp6(); uint32 scope_id; char ip[16]; @@ -267,7 +264,7 @@ emerge: } else if (array_bytes(&h->r)>8192) { httperror(h,"500 request too long","You sent too much headers"); goto emerge; - } else if (l=header_complete(h)) + } else if ((l=header_complete(h))) httpresponse(h,i); } } @@ -289,4 +286,5 @@ emerge: } } } + return 0; } diff --git a/test/io3.c b/test/io3.c index 1343b8e..d3eab0c 100644 --- a/test/io3.c +++ b/test/io3.c @@ -2,10 +2,10 @@ #include "buffer.h" #include "io.h" -main() { +int main() { int64 pfd[2]; char buf[20480]; - int i; + unsigned int i; if (!io_pipe(pfd)) return 111; io_nonblock(pfd[1]); if (!io_fd(pfd[1])) return 111; @@ -36,4 +36,5 @@ main() { buffer_putnlflush(buffer_2); } } + return 0; } diff --git a/test/io4.c b/test/io4.c index 62fa6fc..f672555 100644 --- a/test/io4.c +++ b/test/io4.c @@ -1,7 +1,8 @@ #include "io.h" #include "buffer.h" +#include -main() { +int main() { char buf[2048]; int64 pfd[2]; tai6464 t; @@ -24,4 +25,5 @@ main() { buffer_putnlflush(buffer_2); return 111; } + return 0; } diff --git a/test/io5.c b/test/io5.c index 4f101a1..b0bd83e 100644 --- a/test/io5.c +++ b/test/io5.c @@ -4,7 +4,7 @@ #include "ip6.h" #include -main() { +int main() { int s=socket_tcp6(); uint32 scope_id; char ip[16]; @@ -108,4 +108,5 @@ main() { } } } + return 0; } diff --git a/test/iob.c b/test/iob.c index e33dc90..c2dc9ac 100644 --- a/test/iob.c +++ b/test/iob.c @@ -2,7 +2,7 @@ #include "iob.h" #include "buffer.h" -main() { +int main() { int64 fd; io_batch* b; assert(io_readfile(&fd,"GNUmakefile")); @@ -13,4 +13,5 @@ main() { buffer_puts(buffer_2,"iob_send returned "); buffer_putlong(buffer_2,iob_send(1,b)); buffer_putsflush(buffer_2,".\n"); + return 0; } diff --git a/test/readhttp.c b/test/readhttp.c index d59bf62..1dff650 100644 --- a/test/readhttp.c +++ b/test/readhttp.c @@ -23,4 +23,5 @@ int main() { buffer_putsflush(buffer_1,".\n\n"); buffer_putsa(buffer_1,&sa); buffer_flush(buffer_1); + return 0; } diff --git a/test/scan.c b/test/scan.c index be92efe..ead109e 100644 --- a/test/scan.c +++ b/test/scan.c @@ -4,7 +4,6 @@ int main() { unsigned long l; - char buf[100]; assert(scan_ulong("12345",&l)==5 && l==12345); assert(scan_ulong("-12345",&l)==0); assert(scan_ulong("4294967295",&l)==10 && l==4294967295ul); @@ -14,4 +13,5 @@ int main() { assert(scan_ulong("5294967295",&l)==9 && l==529496729); assert(scan_ulong("4295067295",&l)==9 && l==429506729); } + return 0; } diff --git a/test/scan_long.c b/test/scan_long.c index 5f598d5..f13bf5c 100644 --- a/test/scan_long.c +++ b/test/scan_long.c @@ -3,7 +3,7 @@ #include #include -main() { +int main() { char buf[1024]; unsigned long long int i; if (sizeof(unsigned long) != 4) @@ -19,4 +19,5 @@ main() { else assert(i<=0xffffffffull); } + return 0; } diff --git a/test/server.c b/test/server.c index af9d81b..b3fb5cf 100644 --- a/test/server.c +++ b/test/server.c @@ -13,6 +13,7 @@ static inline __write1(const char* s) { write(1,s,str_len(s)); } static inline __write2(const char* s) { write(2,s,str_len(s)); } #endif +#include void panic(const char* s) { int i=str_len(s); @@ -110,4 +111,5 @@ usage: } } } + return 0; } diff --git a/test/stralloc_buffer.c b/test/stralloc_buffer.c index 6b0dbb5..dda6dd3 100644 --- a/test/stralloc_buffer.c +++ b/test/stralloc_buffer.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "buffer.h" -main() { +int main() { static stralloc sa; /* static makes sure sa is initialized and empty; * use stralloc_init to initialize and stralloc_copys(&sa,"") to empty */ @@ -9,4 +9,5 @@ main() { buffer_putsa(buffer_1,&sa); buffer_putnlflush(buffer_1); } + return 0; } diff --git a/test/stralloc_chomp.c b/test/stralloc_chomp.c index 34ba476..890ca5e 100644 --- a/test/stralloc_chomp.c +++ b/test/stralloc_chomp.c @@ -2,7 +2,7 @@ #include "stralloc.h" #include "buffer.h" -main() { +int main() { static stralloc sa; stralloc_copys(&sa,"foo\r\n"); assert(sa.len==5); diff --git a/test/textcode.c b/test/textcode.c index 4152f80..8b3467d 100644 --- a/test/textcode.c +++ b/test/textcode.c @@ -1,6 +1,7 @@ #include "array.h" #include "textcode.h" #include +#include array a; @@ -18,4 +19,5 @@ int main() { assert(!array_failed(&a)); write(1,array_start(&a),array_bytes(&a)); write(1,"\n",1); array_trunc(&a); + return 0; } diff --git a/test/unurl.c b/test/unurl.c index 260315c..dea940b 100644 --- a/test/unurl.c +++ b/test/unurl.c @@ -2,10 +2,11 @@ #include "buffer.h" #include "textcode.h" #include "havealloca.h" +#include void unurl(const char* s) { char* buf; - unsigned int len; + unsigned long len; buf=alloca(strlen(s)+1); if (s[scan_urlencoded(s,buf,&len)]) { buffer_putsflush(buffer_2,"parse error!\n"); @@ -25,7 +26,7 @@ void unurl(const char* s) { } } -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int i; for (i=1; i void urlencode(const char* c) { char* buf=alloca(strlen(c)*3+1); @@ -9,7 +10,7 @@ void urlencode(const char* c) { buffer_putnlflush(buffer_1); } -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int i; for (i=1; i #include -main(int argc,char* argv[]) { +int main(int argc,char* argv[]) { int s=socket_tcp4(); char line[1024]; char buf[4096]; @@ -12,6 +12,8 @@ main(int argc,char* argv[]) { int header=1; struct iovec x[2]; buffer filein; + + (void)argc; buffer_init(&filein,read,s,buf,sizeof buf); if (socket_connect4(s,"\x7f\x00\x00\x01",4000)) { perror("connect"); @@ -19,7 +21,7 @@ main(int argc,char* argv[]) { } { char* c; - if (c=strrchr(argv[0],'/')) + if ((c=strrchr(argv[0],'/'))) x[0].iov_base=c+1; else x[0].iov_base=argv[0]; @@ -45,4 +47,5 @@ main(int argc,char* argv[]) { } } buffer_flush(buffer_1); + return 0; }