commit 1879e14e79aca6f676d48e58500eb755f341e78b
Author:     Laslo Hunhold <[email protected]>
AuthorDate: Mon Mar 5 00:30:53 2018 +0100
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Mon Mar 5 00:30:53 2018 +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.

diff --git a/config.mk b/config.mk
index 0eb5f27..7056241 100644
--- 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
index 9140cc7..cf08ada 100644
--- 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
index 7bcaeed..1c7d285 100644
--- 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
index 7a7d7a2..06714fb 100644
--- 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;
                        }

Reply via email to