summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2011-12-18 03:22:36 +0100
committerDenys Vlasenko2011-12-18 03:22:36 +0100
commitf85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4 (patch)
tree140546e7347ada375c1a1c1dcbc08770e8e17e36
parentee0f444f11504e47fc0f3ab6bc2bf95defb6e6ae (diff)
downloadbusybox-f85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4.zip
busybox-f85bd1a7a7e712c4dd2dfd86daa9ab01a708b7b4.tar.gz
httpd: remove redundant NULL assignment and save one strrchr. -8 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/httpd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index f52785b..cda7cc7 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1284,7 +1284,7 @@ static void send_cgi_and_exit(
{
struct fd_pair fromCgi; /* CGI -> httpd pipe */
struct fd_pair toCgi; /* httpd -> CGI pipe */
- char *script;
+ char *script, *last_slash;
int pid;
/* Make a copy. NB: caller guarantees:
@@ -1298,15 +1298,18 @@ static void send_cgi_and_exit(
*/
/* Check for [dirs/]script.cgi/PATH_INFO */
- script = (char*)url;
+ last_slash = script = (char*)url;
while ((script = strchr(script + 1, '/')) != NULL) {
+ int dir;
*script = '\0';
- if (!is_directory(url + 1, 1, NULL)) {
+ dir = is_directory(url + 1, /*followlinks:*/ 1, NULL);
+ *script = '/';
+ if (!dir) {
/* not directory, found script.cgi/PATH_INFO */
- *script = '/';
break;
}
- *script = '/'; /* is directory, find next '/' */
+ /* is directory, find next '/' */
+ last_slash = script;
}
setenv1("PATH_INFO", script); /* set to /PATH_INFO or "" */
setenv1("REQUEST_METHOD", request);
@@ -1387,7 +1390,7 @@ static void send_cgi_and_exit(
log_and_exit();
}
- if (!pid) {
+ if (pid == 0) {
/* Child process */
char *argv[3];
@@ -1403,7 +1406,7 @@ static void send_cgi_and_exit(
/* dup2(1, 2); */
/* Chdiring to script's dir */
- script = strrchr(url, '/');
+ script = last_slash;
if (script != url) { /* paranoia */
*script = '\0';
if (chdir(url + 1) != 0) {
@@ -1992,7 +1995,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
/* NB: urlcopy ptr is never changed after this */
/* Extract url args if present */
- g_query = NULL;
+ /* g_query = NULL; - already is */
tptr = strchr(urlcopy, '?');
if (tptr) {
*tptr++ = '\0';