From ad1ba782664c6bdbd43154a661e59246c2278e17 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:33:21 +0200 Subject: [PATCH 01/15] In proxy_connection(), make sure content_length is defined even if no Content-Lenght header is found. --- http.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git http.c http.c index 7a3783b..592bc6c 100644 --- http.c +++ http.c @@ -413,7 +413,7 @@ punt2: { char* cl=http_header(ctx_for_sockfd,"Content-Length"); - unsigned long long content_length; + unsigned long long content_length=0; if (cl) { char c; if ((c=cl[scan_ulonglong(cl,&content_length)])!='\r' && c!='\n') content_length=0; -- 1.6.3.1 From 0767a1f251624ab98103fc271000c22eca174b7e Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 12:44:45 +0200 Subject: [PATCH 02/15] Variable i isn't read afterwards, but using j instead seems to make sense. --- http.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git http.c http.c index 592bc6c..9b2c959 100644 --- http.c +++ http.c @@ -546,7 +546,7 @@ int proxy_write_header(int sockfd,struct http_data* h) { "\x00\x01\x00\x00\x00\x00\x00\x00" /* FCGI_BeginRequestBody */ "\x01\x04\x00\x01\x00\x00\x00\x00" /* fcgirecord: FCGI_PARAMS */ ); - i=24; + j=24; #if 0 {FCGI_PARAMS, 1, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "} -- 1.6.3.1 From 90a7501b19edb929a27c18e125a6898661a10d42 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:48:03 +0200 Subject: [PATCH 03/15] In buffer_putlogstr(), don't initialize l to strlen(s), it's overwritten right away anyway. --- http.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git http.c http.c index 9b2c959..2db9aee 100644 --- http.c +++ http.c @@ -224,7 +224,7 @@ int add_proxy(const char* c) { } int buffer_putlogstr(buffer* b,const char* s) { - unsigned long l=str_len(s); + unsigned long l; char* x; for (l=0; s[l] && s[l]!='\r' && s[l]!='\n'; ++l) ; if (!l) return 0; -- 1.6.3.1 From 11b94a53b219088b4a0adf437bbad82b5ec58e23 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 12:58:34 +0200 Subject: [PATCH 04/15] Don't assign the same value twice. --- matchiprange.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git matchiprange.c matchiprange.c index bd98a2c..e6e03c1 100644 --- matchiprange.c +++ matchiprange.c @@ -108,7 +108,6 @@ kaputt: if (whined != lineno-1) { char linenoasc[10]; linenoasc[fmt_ulong(linenoasc,lineno)]=0; - whined=lineno; carp("parse error on line ",linenoasc); } whined=lineno; -- 1.6.3.1 From 0b3b516a999f05ef7d4688c3c8aa28dcab37f632 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 12:53:11 +0200 Subject: [PATCH 05/15] Remove write-only variable timestamp. --- referrer.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git referrer.c referrer.c index 945d144..b58033f 100644 --- referrer.c +++ referrer.c @@ -75,7 +75,6 @@ void sortbycount(struct node** N) { int main() { char line[8192]; char* dat; - char* timestamp; while (fgets(line,sizeof(line),stdin)) { int tslen; /* chomp */ @@ -104,10 +103,8 @@ int main() { if (tslen) { dat=line+tslen+1; line[tslen]=0; - timestamp=line; } else { dat=line; - timestamp=""; } /* element two is the unique key */ { -- 1.6.3.1 From 7bd981feb7d6d75db86b47ca3f59ac60f3f7fd93 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:02:27 +0200 Subject: [PATCH 06/15] Remove write-only variable b. --- rellink.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git rellink.c rellink.c index e759bf1..44be931 100644 --- rellink.c +++ rellink.c @@ -84,10 +84,10 @@ static char* mmap_read_stat(const char* filename,struct stat* ss) { } static int stralloc_istag(stralloc* sa,const char* in) { - char* a,* b; + char* a; int l; l=strlen(in); - a=sa->s; b=sa->s+sa->len; + a=sa->s; if (sa->len Date: Sat, 30 May 2009 13:45:27 +0200 Subject: [PATCH 07/15] Remove write-only variable res. --- mime.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git mime.c mime.c index 45959f6..5fc8156 100644 --- mime.c +++ mime.c @@ -121,12 +121,10 @@ static struct mimeentry { const char* name, *type; }* mimetypes; static struct pool* mimepool; static void parse_mime_types(const char* filename) { - int res; size_t maplen; const char* map=mmap_read(filename,&maplen); unsigned int allocated=0,used=0; struct mimeentry* nmt=0; - res=0; if (map) { const char* mimetype; const char* extension; -- 1.6.3.1 From b0630341e1470ba81aead8574d2a23d1bed1b346 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:53:33 +0200 Subject: [PATCH 08/15] Remove write-only variable plusx. --- http.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git http.c http.c index 2db9aee..17a9adc 100644 --- http.c +++ http.c @@ -2131,7 +2131,6 @@ void forkslave(int fd,buffer* in,int savedir) { msg="vfork failed!"; else if (r==0) { /* child */ - int plusx=0; pid_t pid; close(savedir); code=0; @@ -2145,7 +2144,6 @@ void forkslave(int fd,buffer* in,int savedir) { j+=fmt_str(temp+j,"index.html"); temp[j]=0; cginame=temp; - plusx=1; } if (io_passfd(fd,sock[0])==0) { char* argv[]={cginame,0}; -- 1.6.3.1 From 4abd217c70643a545eb03c436ed02eab097b0e12 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:54:40 +0200 Subject: [PATCH 09/15] Remove write-only variable x. --- mime.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git mime.c mime.c index 5fc8156..1042a2f 100644 --- mime.c +++ mime.c @@ -52,10 +52,8 @@ static void afree(struct arena* a,void* x) { static void free_arena(struct arena* a) { for (; a; a=a->next) { unsigned int i; - struct arena* x; for (i=0; in; ++i) free(a->ptrs[i]); - x=a->next; } } -- 1.6.3.1 From 17075d0f2b8cae235149eaf74525ee2c9fc8f321 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 12:49:19 +0200 Subject: [PATCH 10/15] Mark a strange else block. --- common.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git common.c common.c index 682b7b2..b7f10b0 100644 --- common.c +++ common.c @@ -67,6 +67,11 @@ int canonpath(char* s) { ++i; continue; } else + /* + * XXX: This looks strange. If the loop continues, + * c will be overwritten right away, otherwise it + * will not be touched again. + */ c=':'; } if (!(s[j]=s[i])) break; ++j; -- 1.6.3.1 From 88ba2b47088fd026f3404f4d91605ad97fd26243 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 13:19:41 +0200 Subject: [PATCH 11/15] Mark a possible problem in smb_handle_QueryDiskInfo() --- smb.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git smb.c smb.c index 095641e..25bc0a8 100644 --- smb.c +++ smb.c @@ -1188,6 +1188,7 @@ static int smb_handle_QueryDiskInfo(unsigned char* c,size_t len,struct smb_respo uint16_pack(buf+7,k>>i); if (i<9+15) { uint16_pack(buf+5,1<<9); + /* XXX: undefined result in case of i < 9. */ uint16_pack(buf+3,1<<(i-9)); } else { uint16_pack(buf+5,1<<15); -- 1.6.3.1 From 36b2c0759348ba31c16a0c28bd655241a3762a69 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 30 May 2009 16:49:24 +0200 Subject: [PATCH 12/15] Fix spelling. --- README.cgi | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git README.cgi README.cgi index 6a967a0..a0477b0 100644 --- README.cgi +++ README.cgi @@ -15,6 +15,6 @@ You can also tell gatling to consider all executable files CGI programs: Then, even index.html will be run as CGI if it is executable, allowing for example a dynamically generated homepage on http://example.com/ without index.html having to do a lame redirect. In this mode, gatling -will to a primitive check and only run CGIs that have the ELF magic +will do a primitive check and only run CGIs that have the ELF magic (i.e. look like an ELF binary) or the Shebang (#!, i.e. look like a shell/perl/whatever script). -- 1.6.3.1 From 03e5a2638d1e4e576ed5637d363801f207db2f74 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 31 May 2009 18:58:15 +0200 Subject: [PATCH 13/15] Fix spelling. --- README.httpbench | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git README.httpbench README.httpbench index 3bdba26..632c752 100644 --- README.httpbench +++ README.httpbench @@ -31,7 +31,7 @@ The first line is for informational purposes. Lines starting with "sample" give two timings, first the latency for opening the TCP connection (which should be pretty small unless the web server has problems calling accept() as fast as incoming connections -arive). The second is the average latency for writing the HTTP request +arrive). The second is the average latency for writing the HTTP request and reading the answer. The timings are in µs. Lines starting with "clat" give the normal TCP connect() latency. Since -- 1.6.3.1 From 0597a7adc9f956a7500b7c603765c8e0b1ebe4b8 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 31 May 2009 19:20:15 +0200 Subject: [PATCH 14/15] Fix default port description. If the user isn't root, gatling doesn't actually try to bind to port 80 or 21, even if the system would allow it. --- README.ftp | 5 +++-- README.http | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git README.ftp README.ftp index b7c3c2e..ec3e67f 100644 --- README.ftp +++ README.ftp @@ -6,8 +6,9 @@ worse for FTP than it is for HTTP. I'm not going to waste my time on this for now. Please ask itojun himself to prove how "easy" or even "trivial" it is to do this, as he always claims it is. -Like HTTP will try to bind to port 80 and 8000, FTP will try binding to -port 21 and 2121. To specify the FTP port, use -f -p [port]. Example: +Like HTTP will bind to port 80 when run as root, and port 8000 otherwise, +FTP will try binding to port 21 or 2121. To specify the FTP port, use +-f -p [port]. Example: gatling -p 81 -f -p 2100 diff --git README.http README.http index ad0d416..ba7e433 100644 --- README.http +++ README.http @@ -1,6 +1,6 @@ gatling is a non-forking HTTP server. -It tries to listen to port 80, and if that fails, it tries to listen to -port 8000. You can specify the port with -p, i.e. +The default listening port is 80 when run as root, port 8000 otherwise. +You can specify the port with -p, i.e. gatling -p 81 -- 1.6.3.1 From 4bb268f7edda46fec4ed78f1f3eca43a646abe9c Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 31 May 2009 18:25:28 +0200 Subject: [PATCH 15/15] Change clearstats() to clearstats(void) so it's clear that it doesn't take arguments. --- dl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git dl.c dl.c index 97bdd1d..cb020b9 100644 --- dl.c +++ dl.c @@ -49,7 +49,7 @@ void alarm_handler(int dummy) { exit(1); } -static void clearstats(); +static void clearstats(void); static void carp(const char* routine) { clearstats(); @@ -164,7 +164,7 @@ void printstats(unsigned long long nextchunk,int fd) { } } -static void clearstats() { +static void clearstats(void) { if (statsprinted) buffer_putsflush(buffer_2,"\r\e[K"); } -- 1.6.3.1