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.
This commit is contained in:
Laslo Hunhold 2018-03-05 00:30:53 +01:00
parent 3ff3e5ea6e
commit 1879e14e79
4 changed files with 11 additions and 9 deletions

View file

@ -9,7 +9,7 @@ MANPREFIX = $(PREFIX)/share/man
# flags # flags
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE 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 LDFLAGS = -s
# compiler and linker # compiler and linker

10
http.c
View file

@ -346,7 +346,7 @@ http_send_response(int fd, struct request *r)
/* if we have a vhost prefix, prepend it to the target */ /* if we have a vhost prefix, prepend it to the target */
if (s.vhost[i].prefix) { 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)) { s.vhost[i].prefix, realtarget) >= sizeof(realtarget)) {
return http_send_status(fd, S_REQUEST_TOO_LARGE); 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 */ /* swap out target prefix */
if (snprintf(tmptarget, sizeof(tmptarget), "%s%s", s.map[i].to, if ((size_t)snprintf(tmptarget, sizeof(tmptarget), "%s%s",
realtarget + len) >= sizeof(tmptarget)) { s.map[i].to, realtarget + len) >= sizeof(tmptarget)) {
return http_send_status(fd, S_REQUEST_TOO_LARGE); return http_send_status(fd, S_REQUEST_TOO_LARGE);
} }
memcpy(realtarget, tmptarget, sizeof(realtarget)); memcpy(realtarget, tmptarget, sizeof(realtarget));
@ -441,8 +441,8 @@ http_send_response(int fd, struct request *r)
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
/* append docindex to target */ /* append docindex to target */
if (snprintf(realtarget, sizeof(realtarget), "%s%s", if ((size_t)snprintf(realtarget, sizeof(realtarget), "%s%s",
r->target, s.docindex) >= sizeof(realtarget)) { r->target, s.docindex) >= sizeof(realtarget)) {
return http_send_status(fd, S_REQUEST_TOO_LARGE); return http_send_status(fd, S_REQUEST_TOO_LARGE);
} }

3
main.c
View file

@ -109,8 +109,9 @@ main(int argc, char *argv[])
struct rlimit rlim; struct rlimit rlim;
struct sockaddr_storage in_sa; struct sockaddr_storage in_sa;
pid_t cpid, wpid, spid; pid_t cpid, wpid, spid;
size_t i;
socklen_t in_sa_len; socklen_t in_sa_len;
int i, insock, status = 0, infd; int insock, status = 0, infd;
const char *err; const char *err;
char *tok; char *tok;

5
resp.c
View file

@ -75,7 +75,7 @@ resp_dir(int fd, char *name, struct request *r)
} }
/* listing */ /* listing */
for (i = 0; i < dirlen; i++) { for (i = 0; i < (size_t)dirlen; i++) {
/* skip hidden files, "." and ".." */ /* skip hidden files, "." and ".." */
if (e[i]->d_name[0] == '.') { if (e[i]->d_name[0] == '.') {
continue; 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 */ /* write data until upper bound is hit */
remaining = upper - lower + 1; 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) { if (bread < 0) {
return S_INTERNAL_SERVER_ERROR; return S_INTERNAL_SERVER_ERROR;
} }