summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rw-r--r--src/c/Makefile.am1
-rw-r--r--src/c/Makefile.in1
-rw-r--r--src/c/cgi.c2
-rw-r--r--src/c/fastcgi.c20
-rw-r--r--src/c/http.c13
-rw-r--r--src/c/request.c13
-rw-r--r--src/c/urweb.c78
9 files changed, 50 insertions, 82 deletions
diff --git a/Makefile.am b/Makefile.am
index a37b79ea..078ebc68 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,7 +69,7 @@ install-exec-local:
cp include/*.h $(INCLUDE)/
mkdir -p $(SITELISP)
cp src/elisp/*.el $(SITELISP)/
- ldconfig
+ -ldconfig
package:
hg archive -t tgz -X tests /tmp/urweb.tgz
diff --git a/Makefile.in b/Makefile.in
index a567a125..6dfc00ab 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -758,7 +758,7 @@ install-exec-local:
cp include/*.h $(INCLUDE)/
mkdir -p $(SITELISP)
cp src/elisp/*.el $(SITELISP)/
- ldconfig
+ -ldconfig
package:
hg archive -t tgz -X tests /tmp/urweb.tgz
diff --git a/src/c/Makefile.am b/src/c/Makefile.am
index 5e28cd0b..91b48df5 100644
--- a/src/c/Makefile.am
+++ b/src/c/Makefile.am
@@ -6,3 +6,4 @@ liburweb_cgi_la_SOURCES = cgi.c
liburweb_fastcgi_la_SOURCES = fastcgi.c
AM_CPPFLAGS = -I../../include
+AM_CFLAGS = -Wimplicit -Wall -Werror
diff --git a/src/c/Makefile.in b/src/c/Makefile.in
index f8638f74..cdcd0226 100644
--- a/src/c/Makefile.in
+++ b/src/c/Makefile.in
@@ -221,6 +221,7 @@ liburweb_http_la_SOURCES = http.c
liburweb_cgi_la_SOURCES = cgi.c
liburweb_fastcgi_la_SOURCES = fastcgi.c
AM_CPPFLAGS = -I../../include
+AM_CFLAGS = -Wimplicit -Wall -Werror
all: all-am
.SUFFIXES:
diff --git a/src/c/cgi.c b/src/c/cgi.c
index 91b22f06..98ad7479 100644
--- a/src/c/cgi.c
+++ b/src/c/cgi.c
@@ -28,7 +28,7 @@ static char *get_header(void *data, const char *h) {
*s++ = *h == '-' ? '_' : toupper(*h);
*s = 0;
- if (r = getenv(uppercased))
+ if ((r = getenv(uppercased)))
return r;
else if (!strcasecmp(saved_h, "Content-length")
|| !strcasecmp(saved_h, "Content-type"))
diff --git a/src/c/fastcgi.c b/src/c/fastcgi.c
index 21f59c09..24617f89 100644
--- a/src/c/fastcgi.c
+++ b/src/c/fastcgi.c
@@ -139,7 +139,7 @@ static void write_stderr(FCGI_Output *o, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
- len = vsnprintf(o->r.contentData, 65535, fmt, ap);
+ len = vsnprintf((char *)o->r.contentData, 65535, fmt, ap);
if (len < 0)
fprintf(stderr, "vsnprintf() failed in write_stderr().\n");
else if (fastcgi_send(o, FCGI_STDERR, len))
@@ -157,7 +157,7 @@ static void log_error(void *data, const char *fmt, ...) {
va_start(ap, fmt);
if (o) {
- int len = vsnprintf(o->r.contentData, 65535, fmt, ap);
+ int len = vsnprintf((char *)o->r.contentData, 65535, fmt, ap);
if (len < 0)
fprintf(stderr, "vsnprintf() failed in log_error().\n");
else if (fastcgi_send(o, FCGI_STDERR, len))
@@ -191,7 +191,7 @@ typedef struct {
static char *get_header(void *data, const char *h) {
headers *hs = (headers *)data;
size_t len = strlen(h);
- char *s, *r;
+ char *s;
const char *saved_h = h;
if (len > hs->uppercased_len) {
@@ -206,7 +206,7 @@ static char *get_header(void *data, const char *h) {
if (!strcasecmp(saved_h, "Content-length")
|| !strcasecmp(saved_h, "Content-type")) {
- if (s = search_nvps(hs->nvps, hs->uppercased + 5))
+ if ((s = search_nvps(hs->nvps, hs->uppercased + 5)))
return s;
}
@@ -300,7 +300,6 @@ int fastcgi_send_normal(int sock, const void *buf, ssize_t len) {
}
static void *worker(void *data) {
- int me = *(int *)data;
FCGI_Input *in = fastcgi_input();
FCGI_Output *out = fastcgi_output();
uw_context ctx = uw_request_new_context(&uw_application, out, log_error, log_debug);
@@ -310,7 +309,6 @@ static void *worker(void *data) {
char *body = malloc(0);
size_t path_size = 0;
char *path_buf = malloc(0);
- int tries = 0;
hs.uppercased = malloc(0);
hs.uppercased_len = 0;
@@ -385,7 +383,7 @@ static void *worker(void *data) {
hs.nvps[used_nvps].name[0] = 0;
- if (s = get_header(&hs, "Content-Length")) {
+ if ((s = get_header(&hs, "Content-Length"))) {
body_len = atoi(s);
if (body_len < 0) {
write_stderr(out, "Invalid Content-Length\n");
@@ -400,7 +398,6 @@ static void *worker(void *data) {
}
for (body_read = 0; body_read < body_len; ) {
- char *buf;
int this_len;
if (!(r = fastcgi_recv(in))) {
@@ -441,7 +438,7 @@ static void *worker(void *data) {
goto done;
}
- if (path_info = search_nvps(hs.nvps, "PATH_INFO")) {
+ if ((path_info = search_nvps(hs.nvps, "PATH_INFO"))) {
int len1 = strlen(path), len2 = strlen(path_info);
int len = len1 + len2 + 1;
@@ -497,7 +494,7 @@ static loggers ls = {&uw_application, NULL, log_error, log_debug};
int main(int argc, char *argv[]) {
// The skeleton for this function comes from Beej's sockets tutorial.
struct sockaddr_in their_addr; // connector's address information
- int sin_size, yes = 1;
+ socklen_t sin_size;
int nthreads = 1, i, *names, opt;
char *fwsa = getenv("FCGI_WEB_SERVER_ADDRS"), *nthreads_s = getenv("URWEB_NUM_THREADS");
@@ -549,7 +546,6 @@ int main(int argc, char *argv[]) {
{
pthread_t thread;
- int name;
if (pthread_create(&thread, NULL, client_pruner, &ls)) {
fprintf(stderr, "Error creating pruner thread\n");
@@ -583,7 +579,7 @@ int main(int argc, char *argv[]) {
return 1;
}
- for (ips = fwsa; sep = strchr(ips, ','); ips = sep+1) {
+ for (ips = fwsa; (sep = strchr(ips, ',')); ips = sep+1) {
if (!strncmp(ips, host, sep - ips)) {
matched = 1;
break;
diff --git a/src/c/http.c b/src/c/http.c
index 3ba00a6d..7a8110dc 100644
--- a/src/c/http.c
+++ b/src/c/http.c
@@ -25,7 +25,7 @@ static char *get_header(void *data, const char *h) {
int len = strlen(h);
char *p;
- while (p = strchr(s, ':')) {
+ while ((p = strchr(s, ':'))) {
if (p - s == len && !strncasecmp(s, h, len)) {
return p + 2;
} else {
@@ -169,10 +169,10 @@ static void *worker(void *data) {
}
path = s;
- if (s = strchr(path, ' '))
+ if ((s = strchr(path, ' ')))
*s = 0;
- if (s = strchr(path, '?')) {
+ if ((s = strchr(path, '?'))) {
*s = 0;
query_string = s+1;
}
@@ -180,7 +180,7 @@ static void *worker(void *data) {
query_string = NULL;
s = headers;
- while (s2 = strchr(s, '\r')) {
+ while ((s2 = strchr(s, '\r'))) {
s = s2;
if (s[1] == 0)
@@ -228,8 +228,8 @@ int main(int argc, char *argv[]) {
int sockfd; // listen on sock_fd
struct sockaddr_in my_addr;
struct sockaddr_in their_addr; // connector's address information
- int sin_size, yes = 1;
- int uw_port = 8080, nthreads = 1, i, *names, opt;
+ socklen_t sin_size;
+ int yes = 1, uw_port = 8080, nthreads = 1, i, *names, opt;
signal(SIGINT, sigint);
signal(SIGPIPE, SIG_IGN);
@@ -306,7 +306,6 @@ int main(int argc, char *argv[]) {
{
pthread_t thread;
- int name;
if (pthread_create(&thread, NULL, client_pruner, &ls)) {
fprintf(stderr, "Error creating pruner thread\n");
diff --git a/src/c/request.c b/src/c/request.c
index 247ae92c..61117485 100644
--- a/src/c/request.c
+++ b/src/c/request.c
@@ -122,11 +122,10 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
int (*send)(int sockfd, const void *buf, size_t len),
int (*close)(int fd)) {
int retries_left = MAX_RETRIES;
- char *s;
failure_kind fk;
- int is_post = 0, do_normal_send = 1;
+ int is_post = 0;
char *boundary = NULL;
- size_t boundary_len;
+ size_t boundary_len = 0;
char *inputs;
const char *prefix = uw_get_url_prefix(ctx);
@@ -226,7 +225,7 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
after_sub_headers[2] = 0;
after_sub_headers += 4;
- for (header = part; after_header = strstr(header, "\r\n"); header = after_header + 2) {
+ for (header = part; (after_header = strstr(header, "\r\n")); header = after_header + 2) {
char *colon, *after_colon;
*after_header = 0;
@@ -246,7 +245,7 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
return FAILED;
}
- for (colon += 11; after_colon = strchr(colon, '='); colon = after_colon) {
+ for (colon += 11; (after_colon = strchr(colon, '=')); colon = after_colon) {
char *data;
after_colon[0] = 0;
if (after_colon[1] != '"') {
@@ -304,12 +303,12 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
while (*inputs) {
name = inputs;
- if (inputs = strchr(inputs, '&'))
+ if ((inputs = strchr(inputs, '&')))
*inputs++ = 0;
else
inputs = strchr(name, 0);
- if (value = strchr(name, '=')) {
+ if ((value = strchr(name, '='))) {
*value++ = 0;
if (uw_set_input(ctx, name, value)) {
log_error(logger_data, "%s\n", uw_error_message(ctx));
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 28b73715..c97ce5f8 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -83,11 +83,12 @@ static int buf_check(buf *b, size_t extra) {
next = 1;
for (; next < desired; next *= 2);
- if (next > b->max)
+ if (next > b->max) {
if (desired <= b->max)
next = desired;
else
return 1;
+ }
new_heap = realloc(b->start, next);
b->front = new_heap + (b->front - b->start);
@@ -519,6 +520,8 @@ int uw_set_app(uw_context ctx, uw_app *app) {
ctx->inputs = realloc(ctx->inputs, ctx->sz_inputs * sizeof(input));
memset(ctx->inputs, 0, ctx->sz_inputs * sizeof(input));
}
+
+ return 0;
}
void uw_set_client_data(uw_context ctx, void *data) {
@@ -557,8 +560,6 @@ void uw_free(uw_context ctx) {
}
void uw_reset_keep_error_message(uw_context ctx) {
- size_t i;
-
buf_reset(&ctx->outHeaders);
buf_reset(&ctx->script);
ctx->script.start[0] = 0;
@@ -643,11 +644,12 @@ void uw_push_cleanup(uw_context ctx, void (*func)(void *), void *arg) {
else
newLen = len * 2;
- if (newLen > uw_cleanup_max)
+ if (newLen > uw_cleanup_max) {
if (len+1 <= uw_cleanup_max)
newLen = uw_cleanup_max;
else
uw_error(ctx, FATAL, "Exceeded limit on number of cleanup handlers");
+ }
ctx->cleanup = realloc(ctx->cleanup, newLen * sizeof(cleanup));
ctx->cleanup_front = ctx->cleanup + len;
@@ -764,6 +766,9 @@ static void adjust_input(input *x, input *old_start, input *new_start, size_t le
adjust_pointer(&x->data.entry.fields, old_start, new_start, len);
adjust_pointer(&x->data.entry.next, old_start, new_start, len);
adjust_pointer(&x->data.entry.parent, old_start, new_start, len);
+ break;
+ default:
+ break;
}
}
@@ -778,7 +783,6 @@ static input *check_input_space(uw_context ctx, size_t len) {
uw_error(ctx, FATAL, "Exceeded limit on number of subinputs");
input *new_subinputs = realloc(ctx->subinputs, sizeof(input) * (ctx->used_subinputs + len));
- size_t offset = new_subinputs - ctx->subinputs;
if (ctx->subinputs != new_subinputs) {
for (i = 0; i < ctx->used_subinputs; ++i)
@@ -979,34 +983,6 @@ int uw_set_file_input(uw_context ctx, const char *name, uw_Basis_file f) {
void *uw_malloc(uw_context ctx, size_t len);
-static void parents(input *inp) {
- printf("Stack: %p\n", inp);
- while (inp) {
- switch (inp->kind) {
- case NORMAL:
- printf("Normal(%p)\n", inp);
- break;
- case FIL:
- printf("File(%p)\n", inp);
- break;
- case SUBFORM:
- printf("Subform; fields = %p\n", inp->data.subform.fields);
- inp = inp->data.subform.parent;
- break;
- case SUBFORMS:
- printf("Subforms; entries = %p\n", inp->data.subforms.entries);
- inp = inp->data.subforms.parent;
- break;
- case ENTRY:
- printf("Entry; fields = %p; next = %p\n", inp->data.entry.fields, inp->data.entry.next);
- inp = inp->data.entry.parent;
- break;
- default:
- inp = NULL;
- }
- }
-}
-
uw_Basis_file uw_get_file_input(uw_context ctx, int n) {
if (n < 0)
uw_error(ctx, FATAL, "Negative file input index %d", n);
@@ -1159,11 +1135,12 @@ static void buf_check_ctx(uw_context ctx, const char *kind, buf *b, size_t extra
next = 1;
for (; next < desired; next *= 2);
- if (next > b->max)
+ if (next > b->max) {
if (desired <= b->max)
next = desired;
else
uw_error(ctx, FATAL, "Memory limit exceeded (%s)", kind);
+ }
new_heap = realloc(b->start, next);
b->front = new_heap + (b->front - b->start);
@@ -1222,10 +1199,10 @@ void uw_end_region(uw_context ctx) {
}
void uw_memstats(uw_context ctx) {
- printf("Headers: %d/%d\n", buf_used(&ctx->outHeaders), buf_avail(&ctx->outHeaders));
- printf("Script: %d/%d\n", buf_used(&ctx->script), buf_avail(&ctx->script));
- printf("Page: %d/%d\n", buf_used(&ctx->page), buf_avail(&ctx->page));
- printf("Heap: %d/%d\n", buf_used(&ctx->heap), buf_avail(&ctx->heap));
+ printf("Headers: %lu/%lu\n", (unsigned long)buf_used(&ctx->outHeaders), (unsigned long)buf_avail(&ctx->outHeaders));
+ printf("Script: %lu/%lu\n", (unsigned long)buf_used(&ctx->script), (unsigned long)buf_avail(&ctx->script));
+ printf("Page: %lu/%lu\n", (unsigned long)buf_used(&ctx->page), (unsigned long)buf_avail(&ctx->page));
+ printf("Heap: %lu/%lu\n", (unsigned long)buf_used(&ctx->heap), (unsigned long)buf_avail(&ctx->heap));
}
int uw_send(uw_context ctx, int sock) {
@@ -1547,10 +1524,6 @@ char *uw_Basis_attrifyFloat(uw_context ctx, uw_Basis_float n) {
return result;
}
-static int isCont(unsigned char ch) {
- return ch / 64 == 2;
-}
-
char *uw_Basis_attrifyString(uw_context ctx, uw_Basis_string s) {
int len = strlen(s);
char *result, *p;
@@ -1893,8 +1866,8 @@ uw_Basis_bool uw_Basis_unurlifyBool(uw_context ctx, char **s) {
uw_Basis_string uw_Basis_unurlifyString(uw_context ctx, char **s) {
char *new_s = uw_unurlify_advance(*s);
- char *r, *s1, *s2;
- int len, n;
+ char *r;
+ int len;
len = strlen(*s);
uw_check_heap(ctx, len + 1);
@@ -1912,8 +1885,8 @@ uw_Basis_unit uw_Basis_unurlifyUnit(uw_context ctx, char **s) {
uw_Basis_string uw_Basis_unurlifyString_fromClient(uw_context ctx, char **s) {
char *new_s = uw_unurlify_advance(*s);
- char *r, *s1, *s2;
- int len, n;
+ char *r;
+ int len;
len = strlen(*s);
uw_check_heap(ctx, len + 1);
@@ -2765,7 +2738,7 @@ uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) {
int len = strlen(c);
char *p = ctx->outHeaders.start;
- while (p = strstr(p, "\nSet-Cookie: ")) {
+ while ((p = strstr(p, "\nSet-Cookie: "))) {
char *p2;
p += 13;
p2 = strchr(p, '=');
@@ -2786,12 +2759,12 @@ uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) {
}
}
- if (p = uw_Basis_requestHeader(ctx, "Cookie")) {
+ if ((p = uw_Basis_requestHeader(ctx, "Cookie"))) {
char *p2;
while (1) {
if (!strncmp(p, c, len) && p[len] == '=') {
- if (p2 = strchr(p, ';')) {
+ if ((p2 = strchr(p, ';'))) {
size_t n = p2 - (p + len);
char *r = uw_malloc(ctx, n);
memcpy(r, p + 1 + len, n-1);
@@ -2799,7 +2772,7 @@ uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) {
return r;
} else
return p + 1 + len;
- } else if (p = strchr(p, ';'))
+ } else if ((p = strchr(p, ';')))
p += 2;
else
return NULL;
@@ -3194,7 +3167,7 @@ __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, u
uw_write_header(ctx, mimeType);
uw_write_header(ctx, "\r\nContent-Length: ");
ctx_buf_check(ctx, "headers", &ctx->outHeaders, INTS_MAX);
- sprintf(ctx->outHeaders.front, "%d%n", b.size, &len);
+ sprintf(ctx->outHeaders.front, "%lu%n", (unsigned long)b.size, &len);
ctx->outHeaders.front += len;
uw_write_header(ctx, "\r\n");
@@ -3210,7 +3183,6 @@ __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, u
__attribute__((noreturn)) void uw_redirect(uw_context ctx, uw_Basis_string url) {
cleanup *cl;
- int len;
char *s;
ctx->returning_indirectly = 1;
@@ -3225,7 +3197,7 @@ __attribute__((noreturn)) void uw_redirect(uw_context ctx, uw_Basis_string url)
s = strchr(ctx->page.start, '\n');
if (s) {
char *s2;
- for (++s; s2 = strchr(s, '\n'); s = s2+1) {
+ for (++s; (s2 = strchr(s, '\n')); s = s2+1) {
*s2 = 0;
if (!strncmp(s, "Set-Cookie: ", 12)) {
uw_write_header(ctx, s);