quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit 1879e14e79aca6f676d48e58500eb755f341e78b
parent 3ff3e5ea6e1a3d85c6282a833a07424fcac3acc3
Author: Laslo Hunhold <dev@frign.de>
Date:   Mon,  5 Mar 2018 00:30:53 +0100

Be extra pedantic again and remove all warnings

Since now config.def.h has been reduced we don't have any more unused
variables and thus the manual fiddling with error-levels is no longer
necessary.
To get a completely clean result though we have to still cast some
variables here and there.

Diffstat:
Mconfig.mk | 2+-
Mhttp.c | 10+++++-----
Mmain.c | 3++-
Mresp.c | 5+++--
4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/config.mk b/config.mk @@ -9,7 +9,7 @@ MANPREFIX = $(PREFIX)/share/man # flags CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -CFLAGS = -std=c99 -pedantic -Wno-unused-variable -Wno-implicit-function-declaration -Wall -Os +CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os LDFLAGS = -s # compiler and linker diff --git a/http.c b/http.c @@ -346,7 +346,7 @@ http_send_response(int fd, struct request *r) /* if we have a vhost prefix, prepend it to the target */ if (s.vhost[i].prefix) { - if (snprintf(realtarget, sizeof(realtarget), "%s%s", + if ((size_t)snprintf(realtarget, sizeof(realtarget), "%s%s", s.vhost[i].prefix, realtarget) >= sizeof(realtarget)) { return http_send_status(fd, S_REQUEST_TOO_LARGE); } @@ -363,8 +363,8 @@ http_send_response(int fd, struct request *r) } /* swap out target prefix */ - if (snprintf(tmptarget, sizeof(tmptarget), "%s%s", s.map[i].to, - realtarget + len) >= sizeof(tmptarget)) { + if ((size_t)snprintf(tmptarget, sizeof(tmptarget), "%s%s", + s.map[i].to, realtarget + len) >= sizeof(tmptarget)) { return http_send_status(fd, S_REQUEST_TOO_LARGE); } memcpy(realtarget, tmptarget, sizeof(realtarget)); @@ -441,8 +441,8 @@ http_send_response(int fd, struct request *r) if (S_ISDIR(st.st_mode)) { /* append docindex to target */ - if (snprintf(realtarget, sizeof(realtarget), "%s%s", - r->target, s.docindex) >= sizeof(realtarget)) { + if ((size_t)snprintf(realtarget, sizeof(realtarget), "%s%s", + r->target, s.docindex) >= sizeof(realtarget)) { return http_send_status(fd, S_REQUEST_TOO_LARGE); } diff --git a/main.c b/main.c @@ -109,8 +109,9 @@ main(int argc, char *argv[]) struct rlimit rlim; struct sockaddr_storage in_sa; pid_t cpid, wpid, spid; + size_t i; socklen_t in_sa_len; - int i, insock, status = 0, infd; + int insock, status = 0, infd; const char *err; char *tok; diff --git a/resp.c b/resp.c @@ -75,7 +75,7 @@ resp_dir(int fd, char *name, struct request *r) } /* listing */ - for (i = 0; i < dirlen; i++) { + for (i = 0; i < (size_t)dirlen; i++) { /* skip hidden files, "." and ".." */ if (e[i]->d_name[0] == '.') { continue; @@ -165,7 +165,8 @@ resp_file(int fd, char *name, struct request *r, struct stat *st, char *mime, /* write data until upper bound is hit */ remaining = upper - lower + 1; - while ((bread = fread(buf, 1, MIN(sizeof(buf), remaining), fp))) { + while ((bread = fread(buf, 1, MIN(sizeof(buf), + (size_t)remaining), fp))) { if (bread < 0) { return S_INTERNAL_SERVER_ERROR; }