remove warnings in tests

master
leitner 20 years ago
parent ff026235d2
commit 0b30b66db1

@ -1,5 +1,5 @@
#ifndef _ARRAY_H #ifndef ARRAY_H
#define _ARRAY_H #define ARRAY_H
#include "uint64.h" #include "uint64.h"
#include <errno.h> #include <errno.h>

@ -2,7 +2,7 @@
#include "array.h" #include "array.h"
#include "byte.h" #include "byte.h"
main() { int main() {
static array x,y; static array x,y;
array_cats(&x,"fnord"); array_cats(&x,"fnord");
array_cats(&y,"foobar"); array_cats(&y,"foobar");

@ -11,7 +11,7 @@ void b64encode(const char* c) {
buffer_put(buffer_1,buf,dlen); buffer_put(buffer_1,buf,dlen);
} }
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int i; int i;
for (i=1; i<argc; ++i) { for (i=1; i<argc; ++i) {
b64encode(argv[i]); b64encode(argv[i]);

@ -13,7 +13,7 @@ void b64encode(const char* c) {
buffer_flush(buffer_1); buffer_flush(buffer_1);
} }
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int i; int i;
for (i=1; i<argc; ++i) { for (i=1; i<argc; ++i) {
b64encode(argv[i]); b64encode(argv[i]);

@ -1,6 +1,6 @@
#include "buffer.h" #include "buffer.h"
main() { int main() {
buffer_puts(buffer_1,"ulong: "); buffer_puts(buffer_1,"ulong: ");
buffer_putulong(buffer_1,23); buffer_putulong(buffer_1,23);
buffer_puts(buffer_1,"\nlong: "); buffer_puts(buffer_1,"\nlong: ");
@ -13,4 +13,5 @@ main() {
buffer_putsflush(buffer_1,"\n"); buffer_putsflush(buffer_1,"\n");
buffer_putsalign(buffer_1,"aligned\n"); buffer_putsalign(buffer_1,"aligned\n");
buffer_flush(buffer_1); buffer_flush(buffer_1);
return 0;
} }

@ -18,4 +18,5 @@ int main() {
buffer_putsflush(buffer_1,"\"\n"); buffer_putsflush(buffer_1,"\"\n");
stralloc_copys(&line,""); stralloc_copys(&line,"");
} }
return 0;
} }

@ -11,4 +11,5 @@ int main() {
byte_copy(buf+1,1000,buf); byte_copy(buf+1,1000,buf);
carp("both unaligned"); carp("both unaligned");
byte_copy(buf+1,1000,buf+3); byte_copy(buf+1,1000,buf+3);
return 0;
} }

@ -2,6 +2,7 @@
#include "buffer.h" #include "buffer.h"
#include "textcode.h" #include "textcode.h"
#include "havealloca.h" #include "havealloca.h"
#include <unistd.h>
void cescape(const char* c) { void cescape(const char* c) {
char* buf=alloca(strlen(c)*5+1); char* buf=alloca(strlen(c)*5+1);
@ -9,7 +10,7 @@ void cescape(const char* c) {
buffer_putnlflush(buffer_1); buffer_putnlflush(buffer_1);
} }
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int i; int i;
for (i=1; i<argc; ++i) { for (i=1; i<argc; ++i) {
cescape(argv[i]); cescape(argv[i]);

@ -13,6 +13,7 @@
static inline __write1(const char* s) { write(1,s,str_len(s)); } static inline __write1(const char* s) { write(1,s,str_len(s)); }
static inline __write2(const char* s) { write(2,s,str_len(s)); } static inline __write2(const char* s) { write(2,s,str_len(s)); }
#endif #endif
#include <stdlib.h>
void panic(const char* s) { void panic(const char* s) {
int i=str_len(s); int i=str_len(s);
@ -102,4 +103,5 @@ usage:
} }
} }
} }
return 0;
} }

@ -6,7 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include "case.h" #include "case.h"
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int s=socket_tcp4(); int s=socket_tcp4();
char line[1024]; char line[1024];
char buf[4096]; char buf[4096];
@ -48,4 +48,5 @@ main(int argc,char* argv[]) {
} }
} }
buffer_flush(buffer_1); buffer_flush(buffer_1);
return 0;
} }

@ -9,7 +9,9 @@ int main(int argc,char* argv[]) {
static stralloc fqdn; static stralloc fqdn;
static stralloc out; static stralloc out;
char str[IP4_FMT]; char str[IP4_FMT];
int i; unsigned int i;
(void)argc;
dns_random_init(seed); dns_random_init(seed);
if (*argv) ++argv; if (*argv) ++argv;

@ -1,6 +1,7 @@
#include <unistd.h> #include <unistd.h>
#include "io.h" #include "io.h"
#include "buffer.h" #include "buffer.h"
#include <stdlib.h>
void child(int64 fd) { void child(int64 fd) {
int64 x=io_receivefd(fd); int64 x=io_receivefd(fd);
@ -21,7 +22,7 @@ void father(int64 fd) {
io_passfd(fd,x); io_passfd(fd,x);
} }
main() { int main() {
int64 sp[2]; int64 sp[2];
if (io_socketpair(sp)==-1) return 1; if (io_socketpair(sp)==-1) return 1;
switch (fork()) { switch (fork()) {

@ -3,7 +3,7 @@
#include <buffer.h> #include <buffer.h>
#include <fmt.h> #include <fmt.h>
main() { int main() {
char buf[100]; char buf[100];
time_t s,t; time_t s,t;
buffer_put(buffer_1,buf,fmt_httpdate(buf,time(&s))); buffer_put(buffer_1,buf,fmt_httpdate(buf,time(&s)));
@ -14,4 +14,5 @@ main() {
buffer_puts(buffer_1," vs. "); buffer_puts(buffer_1," vs. ");
buffer_putulong(buffer_1,t); buffer_putulong(buffer_1,t);
buffer_putnlflush(buffer_1); buffer_putnlflush(buffer_1);
return 0;
} }

@ -1,10 +1,11 @@
#include <fmt.h> #include <fmt.h>
#include <buffer.h> #include <buffer.h>
main() { int main() {
char buf[1024]; char buf[1024];
buffer_put(buffer_1,buf,fmt_human(buf,1)); buffer_putnlflush(buffer_1); 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,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,2300000)); buffer_putnlflush(buffer_1);
buffer_put(buffer_1,buf,fmt_human(buf,(unsigned long long)(-1ll))); buffer_putnlflush(buffer_1); buffer_put(buffer_1,buf,fmt_human(buf,(unsigned long long)(-1ll))); buffer_putnlflush(buffer_1);
return 0;
} }

@ -2,7 +2,7 @@
#include <str.h> #include <str.h>
#include <assert.h> #include <assert.h>
main() { int main() {
char buf[1024]; char buf[1024];
assert(fmt_long(0,12345)==5); assert(fmt_long(0,12345)==5);
@ -11,4 +11,5 @@ main() {
assert(str_equal(buf,"12345")); assert(str_equal(buf,"12345"));
assert(fmt_long(buf,-12345)==6); buf[6]=0; assert(fmt_long(buf,-12345)==6); buf[6]=0;
assert(str_equal(buf,"-12345")); assert(str_equal(buf,"-12345"));
return 0;
} }

@ -1,8 +1,9 @@
#include <fmt.h> #include <fmt.h>
#include <str.h> #include <str.h>
#include <assert.h> #include <assert.h>
#include <scan.h>
main() { int main() {
char buf[1024]; char buf[1024];
long long l; long long l;
@ -24,4 +25,5 @@ main() {
assert(fmt_longlong(buf,-1234567890)==11); buf[11]=0; assert(fmt_longlong(buf,-1234567890)==11); buf[11]=0;
assert(str_equal(buf,"-1234567890")); assert(str_equal(buf,"-1234567890"));
assert(scan_longlong(buf,&l)==11); assert(l==-1234567890); assert(scan_longlong(buf,&l)==11); assert(l==-1234567890);
return 0;
} }

@ -49,7 +49,6 @@ int header_complete(struct http_data* r) {
} }
void httperror(struct http_data* r,const char* title,const char* message) { void httperror(struct http_data* r,const char* title,const char* message) {
int i;
char* c; char* c;
c=r->hdrbuf=(char*)malloc(strlen(message)+strlen(title)+200); c=r->hdrbuf=(char*)malloc(strlen(message)+strlen(title)+200);
if (!c) { if (!c) {
@ -100,7 +99,7 @@ static struct mimeentry { const char* name, *type; } mimetab[] = {
{ "xbm", "image/x-xbitmap" }, { "xbm", "image/x-xbitmap" },
{ "xpm", "image/x-xpixmap" }, { "xpm", "image/x-xpixmap" },
{ "xwd", "image/x-xwindowdump" }, { "xwd", "image/x-xwindowdump" },
{ 0 } }; { 0,0 } };
const char* mimetype(const char* filename) { const char* mimetype(const char* filename) {
int i,e=str_rchr(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) { void httpresponse(struct http_data* h,int64 s) {
int i;
char* c; char* c;
const char* m; const char* m;
array_cat0(&h->r); array_cat0(&h->r);
@ -153,7 +151,7 @@ e404:
io_close(fd); io_close(fd);
goto e404; goto e404;
} }
if (m=http_header(h,"Connection")) { if ((m=http_header(h,"Connection"))) {
if (str_equal(m,"keep-alive")) if (str_equal(m,"keep-alive"))
h->keepalive=1; h->keepalive=1;
else else
@ -183,8 +181,7 @@ e404:
io_wantwrite(s); io_wantwrite(s);
} }
main() { int main() {
static array a;
int s=socket_tcp6(); int s=socket_tcp6();
uint32 scope_id; uint32 scope_id;
char ip[16]; char ip[16];
@ -267,7 +264,7 @@ emerge:
} else if (array_bytes(&h->r)>8192) { } else if (array_bytes(&h->r)>8192) {
httperror(h,"500 request too long","You sent too much headers"); httperror(h,"500 request too long","You sent too much headers");
goto emerge; goto emerge;
} else if (l=header_complete(h)) } else if ((l=header_complete(h)))
httpresponse(h,i); httpresponse(h,i);
} }
} }
@ -289,4 +286,5 @@ emerge:
} }
} }
} }
return 0;
} }

@ -2,10 +2,10 @@
#include "buffer.h" #include "buffer.h"
#include "io.h" #include "io.h"
main() { int main() {
int64 pfd[2]; int64 pfd[2];
char buf[20480]; char buf[20480];
int i; unsigned int i;
if (!io_pipe(pfd)) return 111; if (!io_pipe(pfd)) return 111;
io_nonblock(pfd[1]); io_nonblock(pfd[1]);
if (!io_fd(pfd[1])) return 111; if (!io_fd(pfd[1])) return 111;
@ -36,4 +36,5 @@ main() {
buffer_putnlflush(buffer_2); buffer_putnlflush(buffer_2);
} }
} }
return 0;
} }

@ -1,7 +1,8 @@
#include "io.h" #include "io.h"
#include "buffer.h" #include "buffer.h"
#include <unistd.h>
main() { int main() {
char buf[2048]; char buf[2048];
int64 pfd[2]; int64 pfd[2];
tai6464 t; tai6464 t;
@ -24,4 +25,5 @@ main() {
buffer_putnlflush(buffer_2); buffer_putnlflush(buffer_2);
return 111; return 111;
} }
return 0;
} }

@ -4,7 +4,7 @@
#include "ip6.h" #include "ip6.h"
#include <errno.h> #include <errno.h>
main() { int main() {
int s=socket_tcp6(); int s=socket_tcp6();
uint32 scope_id; uint32 scope_id;
char ip[16]; char ip[16];
@ -108,4 +108,5 @@ main() {
} }
} }
} }
return 0;
} }

@ -2,7 +2,7 @@
#include "iob.h" #include "iob.h"
#include "buffer.h" #include "buffer.h"
main() { int main() {
int64 fd; int64 fd;
io_batch* b; io_batch* b;
assert(io_readfile(&fd,"GNUmakefile")); assert(io_readfile(&fd,"GNUmakefile"));
@ -13,4 +13,5 @@ main() {
buffer_puts(buffer_2,"iob_send returned "); buffer_puts(buffer_2,"iob_send returned ");
buffer_putlong(buffer_2,iob_send(1,b)); buffer_putlong(buffer_2,iob_send(1,b));
buffer_putsflush(buffer_2,".\n"); buffer_putsflush(buffer_2,".\n");
return 0;
} }

@ -23,4 +23,5 @@ int main() {
buffer_putsflush(buffer_1,".\n\n"); buffer_putsflush(buffer_1,".\n\n");
buffer_putsa(buffer_1,&sa); buffer_putsa(buffer_1,&sa);
buffer_flush(buffer_1); buffer_flush(buffer_1);
return 0;
} }

@ -4,7 +4,6 @@
int main() { int main() {
unsigned long l; unsigned long l;
char buf[100];
assert(scan_ulong("12345",&l)==5 && l==12345); assert(scan_ulong("12345",&l)==5 && l==12345);
assert(scan_ulong("-12345",&l)==0); assert(scan_ulong("-12345",&l)==0);
assert(scan_ulong("4294967295",&l)==10 && l==4294967295ul); 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("5294967295",&l)==9 && l==529496729);
assert(scan_ulong("4295067295",&l)==9 && l==429506729); assert(scan_ulong("4295067295",&l)==9 && l==429506729);
} }
return 0;
} }

@ -3,7 +3,7 @@
#include <buffer.h> #include <buffer.h>
#include <assert.h> #include <assert.h>
main() { int main() {
char buf[1024]; char buf[1024];
unsigned long long int i; unsigned long long int i;
if (sizeof(unsigned long) != 4) if (sizeof(unsigned long) != 4)
@ -19,4 +19,5 @@ main() {
else else
assert(i<=0xffffffffull); assert(i<=0xffffffffull);
} }
return 0;
} }

@ -13,6 +13,7 @@
static inline __write1(const char* s) { write(1,s,str_len(s)); } static inline __write1(const char* s) { write(1,s,str_len(s)); }
static inline __write2(const char* s) { write(2,s,str_len(s)); } static inline __write2(const char* s) { write(2,s,str_len(s)); }
#endif #endif
#include <stdlib.h>
void panic(const char* s) { void panic(const char* s) {
int i=str_len(s); int i=str_len(s);
@ -110,4 +111,5 @@ usage:
} }
} }
} }
return 0;
} }

@ -1,7 +1,7 @@
#include "stralloc.h" #include "stralloc.h"
#include "buffer.h" #include "buffer.h"
main() { int main() {
static stralloc sa; static stralloc sa;
/* static makes sure sa is initialized and empty; /* static makes sure sa is initialized and empty;
* use stralloc_init to initialize and stralloc_copys(&sa,"") to empty */ * use stralloc_init to initialize and stralloc_copys(&sa,"") to empty */
@ -9,4 +9,5 @@ main() {
buffer_putsa(buffer_1,&sa); buffer_putsa(buffer_1,&sa);
buffer_putnlflush(buffer_1); buffer_putnlflush(buffer_1);
} }
return 0;
} }

@ -2,7 +2,7 @@
#include "stralloc.h" #include "stralloc.h"
#include "buffer.h" #include "buffer.h"
main() { int main() {
static stralloc sa; static stralloc sa;
stralloc_copys(&sa,"foo\r\n"); stralloc_copys(&sa,"foo\r\n");
assert(sa.len==5); assert(sa.len==5);

@ -1,6 +1,7 @@
#include "array.h" #include "array.h"
#include "textcode.h" #include "textcode.h"
#include <assert.h> #include <assert.h>
#include <unistd.h>
array a; array a;
@ -18,4 +19,5 @@ int main() {
assert(!array_failed(&a)); assert(!array_failed(&a));
write(1,array_start(&a),array_bytes(&a)); write(1,"\n",1); write(1,array_start(&a),array_bytes(&a)); write(1,"\n",1);
array_trunc(&a); array_trunc(&a);
return 0;
} }

@ -2,10 +2,11 @@
#include "buffer.h" #include "buffer.h"
#include "textcode.h" #include "textcode.h"
#include "havealloca.h" #include "havealloca.h"
#include <unistd.h>
void unurl(const char* s) { void unurl(const char* s) {
char* buf; char* buf;
unsigned int len; unsigned long len;
buf=alloca(strlen(s)+1); buf=alloca(strlen(s)+1);
if (s[scan_urlencoded(s,buf,&len)]) { if (s[scan_urlencoded(s,buf,&len)]) {
buffer_putsflush(buffer_2,"parse error!\n"); 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; int i;
for (i=1; i<argc; ++i) for (i=1; i<argc; ++i)
unurl(argv[i]); unurl(argv[i]);

@ -2,6 +2,7 @@
#include "buffer.h" #include "buffer.h"
#include "textcode.h" #include "textcode.h"
#include "havealloca.h" #include "havealloca.h"
#include <unistd.h>
void urlencode(const char* c) { void urlencode(const char* c) {
char* buf=alloca(strlen(c)*3+1); char* buf=alloca(strlen(c)*3+1);
@ -9,7 +10,7 @@ void urlencode(const char* c) {
buffer_putnlflush(buffer_1); buffer_putnlflush(buffer_1);
} }
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int i; int i;
for (i=1; i<argc; ++i) { for (i=1; i<argc; ++i) {
urlencode(argv[i]); urlencode(argv[i]);

@ -11,6 +11,8 @@
#include "buffer.h" #include "buffer.h"
#include "open.h" #include "open.h"
#include "stralloc.h" #include "stralloc.h"
#include "scan.h"
#include "case.h"
static const uint32_t crc_table[256] = { static const uint32_t crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
@ -83,7 +85,6 @@ int main(int argc,char* argv[]) {
buffer fileout; buffer fileout;
int fd=0; int fd=0;
int ofd=-1; int ofd=-1;
int broken_encoder=0;
int found=0; int found=0;
char line[1000]; /* uuencoded lines can never be longer than 64 characters */ char line[1000]; /* uuencoded lines can never be longer than 64 characters */
int l; int l;
@ -106,7 +107,6 @@ int main(int argc,char* argv[]) {
} }
} }
buffer_init(&filein,read,fd,buf,sizeof buf); buffer_init(&filein,read,fd,buf,sizeof buf);
again:
/* skip to "^begin " */ /* skip to "^begin " */
for (;;) { for (;;) {
if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') { if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') {
@ -149,7 +149,6 @@ again:
mode=UUDECODE; mode=UUDECODE;
foundfilename: foundfilename:
if (line[l]=='"') { if (line[l]=='"') {
int m;
++l; ++l;
line[str_chr(line+l,'"')]=0; line[str_chr(line+l,'"')]=0;
} }
@ -287,7 +286,7 @@ invalidpart:
if (!(tmp=strstr(line," end="))) goto invalidpart; if (!(tmp=strstr(line," end="))) goto invalidpart;
c=tmp[5+scan_ulong(tmp+5,&endoffset)]; c=tmp[5+scan_ulong(tmp+5,&endoffset)];
if (c!=' ' && c!=0) goto invalidpart; if (c!=' ' && c!=0) goto invalidpart;
--offset; endoffset; --offset; --endoffset;
if (endoffset<offset || endoffset>totalsize) goto invalidpart; if (endoffset<offset || endoffset>totalsize) goto invalidpart;
lseek(ofd,offset,SEEK_SET); lseek(ofd,offset,SEEK_SET);
continue; continue;
@ -358,6 +357,9 @@ invalidpart:
switch (mimeenc) { switch (mimeenc) {
case BASE64: x=scan_base64(line,tmp,&scanned); break; case BASE64: x=scan_base64(line,tmp,&scanned); break;
case QP: x=scan_quotedprintable(line,tmp,&scanned); break; case QP: x=scan_quotedprintable(line,tmp,&scanned); break;
default:
buffer_putsflush(buffer_2,"MIME encoding NONE?!\n");
exit(0);
} }
if (line[x]) x=0; if (line[x]) x=0;
break; break;

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <sys/uio.h> #include <sys/uio.h>
main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int s=socket_tcp4(); int s=socket_tcp4();
char line[1024]; char line[1024];
char buf[4096]; char buf[4096];
@ -12,6 +12,8 @@ main(int argc,char* argv[]) {
int header=1; int header=1;
struct iovec x[2]; struct iovec x[2];
buffer filein; buffer filein;
(void)argc;
buffer_init(&filein,read,s,buf,sizeof buf); buffer_init(&filein,read,s,buf,sizeof buf);
if (socket_connect4(s,"\x7f\x00\x00\x01",4000)) { if (socket_connect4(s,"\x7f\x00\x00\x01",4000)) {
perror("connect"); perror("connect");
@ -19,7 +21,7 @@ main(int argc,char* argv[]) {
} }
{ {
char* c; char* c;
if (c=strrchr(argv[0],'/')) if ((c=strrchr(argv[0],'/')))
x[0].iov_base=c+1; x[0].iov_base=c+1;
else else
x[0].iov_base=argv[0]; x[0].iov_base=argv[0];
@ -45,4 +47,5 @@ main(int argc,char* argv[]) {
} }
} }
buffer_flush(buffer_1); buffer_flush(buffer_1);
return 0;
} }

Loading…
Cancel
Save