remove warnings in tests
This commit is contained in:
parent
ff026235d2
commit
0b30b66db1
4
array.h
4
array.h
@ -1,5 +1,5 @@
|
||||
#ifndef _ARRAY_H
|
||||
#define _ARRAY_H
|
||||
#ifndef ARRAY_H
|
||||
#define ARRAY_H
|
||||
|
||||
#include "uint64.h"
|
||||
#include <errno.h>
|
||||
|
@ -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");
|
||||
|
@ -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<argc; ++i) {
|
||||
b64encode(argv[i]);
|
||||
|
@ -13,7 +13,7 @@ void b64encode(const char* c) {
|
||||
buffer_flush(buffer_1);
|
||||
}
|
||||
|
||||
main(int argc,char* argv[]) {
|
||||
int main(int argc,char* argv[]) {
|
||||
int i;
|
||||
for (i=1; i<argc; ++i) {
|
||||
b64encode(argv[i]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "buffer.h"
|
||||
|
||||
main() {
|
||||
int main() {
|
||||
buffer_puts(buffer_1,"ulong: ");
|
||||
buffer_putulong(buffer_1,23);
|
||||
buffer_puts(buffer_1,"\nlong: ");
|
||||
@ -13,4 +13,5 @@ main() {
|
||||
buffer_putsflush(buffer_1,"\n");
|
||||
buffer_putsalign(buffer_1,"aligned\n");
|
||||
buffer_flush(buffer_1);
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,4 +18,5 @@ int main() {
|
||||
buffer_putsflush(buffer_1,"\"\n");
|
||||
stralloc_copys(&line,"");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,4 +11,5 @@ int main() {
|
||||
byte_copy(buf+1,1000,buf);
|
||||
carp("both unaligned");
|
||||
byte_copy(buf+1,1000,buf+3);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "buffer.h"
|
||||
#include "textcode.h"
|
||||
#include "havealloca.h"
|
||||
#include <unistd.h>
|
||||
|
||||
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<argc; ++i) {
|
||||
cescape(argv[i]);
|
||||
|
@ -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 <stdlib.h>
|
||||
|
||||
void panic(const char* s) {
|
||||
int i=str_len(s);
|
||||
@ -102,4 +103,5 @@ usage:
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <unistd.h>
|
||||
#include "io.h"
|
||||
#include "buffer.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
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()) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <buffer.h>
|
||||
#include <fmt.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include <fmt.h>
|
||||
#include <buffer.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <str.h>
|
||||
#include <assert.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <fmt.h>
|
||||
#include <str.h>
|
||||
#include <assert.h>
|
||||
#include <scan.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
12
test/httpd.c
12
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "io.h"
|
||||
#include "buffer.h"
|
||||
#include <unistd.h>
|
||||
|
||||
main() {
|
||||
int main() {
|
||||
char buf[2048];
|
||||
int64 pfd[2];
|
||||
tai6464 t;
|
||||
@ -24,4 +25,5 @@ main() {
|
||||
buffer_putnlflush(buffer_2);
|
||||
return 111;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "ip6.h"
|
||||
#include <errno.h>
|
||||
|
||||
main() {
|
||||
int main() {
|
||||
int s=socket_tcp6();
|
||||
uint32 scope_id;
|
||||
char ip[16];
|
||||
@ -108,4 +108,5 @@ main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ int main() {
|
||||
buffer_putsflush(buffer_1,".\n\n");
|
||||
buffer_putsa(buffer_1,&sa);
|
||||
buffer_flush(buffer_1);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <buffer.h>
|
||||
#include <assert.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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 <stdlib.h>
|
||||
|
||||
void panic(const char* s) {
|
||||
int i=str_len(s);
|
||||
@ -110,4 +111,5 @@ usage:
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "array.h"
|
||||
#include "textcode.h"
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -2,10 +2,11 @@
|
||||
#include "buffer.h"
|
||||
#include "textcode.h"
|
||||
#include "havealloca.h"
|
||||
#include <unistd.h>
|
||||
|
||||
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<argc; ++i)
|
||||
unurl(argv[i]);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "buffer.h"
|
||||
#include "textcode.h"
|
||||
#include "havealloca.h"
|
||||
#include <unistd.h>
|
||||
|
||||
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<argc; ++i) {
|
||||
urlencode(argv[i]);
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "buffer.h"
|
||||
#include "open.h"
|
||||
#include "stralloc.h"
|
||||
#include "scan.h"
|
||||
#include "case.h"
|
||||
|
||||
static const uint32_t crc_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
@ -83,7 +85,6 @@ int main(int argc,char* argv[]) {
|
||||
buffer fileout;
|
||||
int fd=0;
|
||||
int ofd=-1;
|
||||
int broken_encoder=0;
|
||||
int found=0;
|
||||
char line[1000]; /* uuencoded lines can never be longer than 64 characters */
|
||||
int l;
|
||||
@ -106,7 +107,6 @@ int main(int argc,char* argv[]) {
|
||||
}
|
||||
}
|
||||
buffer_init(&filein,read,fd,buf,sizeof buf);
|
||||
again:
|
||||
/* skip to "^begin " */
|
||||
for (;;) {
|
||||
if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') {
|
||||
@ -149,7 +149,6 @@ again:
|
||||
mode=UUDECODE;
|
||||
foundfilename:
|
||||
if (line[l]=='"') {
|
||||
int m;
|
||||
++l;
|
||||
line[str_chr(line+l,'"')]=0;
|
||||
}
|
||||
@ -287,7 +286,7 @@ invalidpart:
|
||||
if (!(tmp=strstr(line," end="))) goto invalidpart;
|
||||
c=tmp[5+scan_ulong(tmp+5,&endoffset)];
|
||||
if (c!=' ' && c!=0) goto invalidpart;
|
||||
--offset; endoffset;
|
||||
--offset; --endoffset;
|
||||
if (endoffset<offset || endoffset>totalsize) goto invalidpart;
|
||||
lseek(ofd,offset,SEEK_SET);
|
||||
continue;
|
||||
@ -358,6 +357,9 @@ invalidpart:
|
||||
switch (mimeenc) {
|
||||
case BASE64: x=scan_base64(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;
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user