fixed some warnings

Thu, 20 Jun 2013 14:07:46 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 20 Jun 2013 14:07:46 +0200
changeset 70
4e6e812c1d97
parent 69
4a10bc0ee80d
child 71
069c152f6272

fixed some warnings

src/server/daemon/config.c file | annotate | diff | comparison | revisions
src/server/daemon/error.c file | annotate | diff | comparison | revisions
src/server/daemon/httprequest.c file | annotate | diff | comparison | revisions
src/server/daemon/vfs.c file | annotate | diff | comparison | revisions
src/server/safs/service.c file | annotate | diff | comparison | revisions
src/server/ucx/string.c file | annotate | diff | comparison | revisions
src/server/util/io.c file | annotate | diff | comparison | revisions
src/server/util/uri.cpp file | annotate | diff | comparison | revisions
src/server/webdav/webdav.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/config.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/daemon/config.c	Thu Jun 20 14:07:46 2013 +0200
@@ -377,6 +377,8 @@
     }
     
     create_threadpool(name, &poolcfg);
+    
+    return 0;
 }
 
 int cfg_handle_eventhandler(ServerConfiguration *c, ServerConfigObject *obj) {
@@ -639,7 +641,7 @@
 void object_conf_unref(HTTPObjectConfig *conf) {
     uint32_t ref = ws_atomic_dec32(&conf->ref);
     if(ref == 0) {
-        printf("free HTTPObjectConfig %d\n", conf);
+        printf("free HTTPObjectConfig %x\n", conf);
         pool_destroy(conf->pool);
     }
 }
@@ -768,7 +770,7 @@
 void mime_conf_unref(MimeMap *conf) {
     uint32_t ref = ws_atomic_dec32(&conf->ref);
     if(ref == 0) {
-        printf("free MimeConfig %d\n", conf);
+        printf("free MimeConfig %x\n", conf);
         UcxMapIterator i = ucx_map_iterator(conf->map);
         char *str;
         UCX_MAP_FOREACH(str, i) {
--- a/src/server/daemon/error.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/daemon/error.c	Thu Jun 20 14:07:46 2013 +0200
@@ -93,7 +93,7 @@
     }
     
     char buf[512];
-    int len = snprintf(buf, 512, "HTTP/1.1 %d %s\r\nServer: webserver\r\nContent-type: text/html\r\nContent-length: %d\r\n\r\n", status, statusmsg, msg.length);
+    int len = snprintf(buf, 512, "HTTP/1.1 %d %s\r\nServer: webserver\r\nContent-type: text/html\r\nContent-length: %zd\r\n\r\n", status, statusmsg, msg.length);
     
     // set socket blocking
     int flags;
--- a/src/server/daemon/httprequest.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/daemon/httprequest.c	Thu Jun 20 14:07:46 2013 +0200
@@ -375,6 +375,7 @@
                 rq->phase++;
                 nsapi_context_next_stage(&rq->context);
             }
+            default: // should not happen, but when it does, finish the req
             case REQ_FINISH: {
                 //printf(">>> Finish\n");
                 r = nsapi_finish_request(sn, rq);
--- a/src/server/daemon/vfs.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/daemon/vfs.c	Thu Jun 20 14:07:46 2013 +0200
@@ -310,7 +310,7 @@
     }
     dir->ctx = ctx;
     dir->data = sys_dir;
-    dir->fd = dirfd(dir);
+    dir->fd = dirfd(sys_dir);
     dir->io = &sys_dir_io;
     return dir;
 }
--- a/src/server/safs/service.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/safs/service.c	Thu Jun 20 14:07:46 2013 +0200
@@ -86,7 +86,7 @@
 
     /* add content-length header*/
     char contentLength[32];
-    int len = snprintf(contentLength, 32, "%d", s->st_size);
+    int len = snprintf(contentLength, 32, "%lld", s->st_size);
 
     pblock_kvinsert(pb_key_content_length, contentLength, len, rq->srvhdrs);
 
--- a/src/server/ucx/string.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/ucx/string.c	Thu Jun 20 14:07:46 2013 +0200
@@ -88,7 +88,7 @@
 
 sstr_t sstrsubsl (sstr_t s, size_t start, size_t length) {
     sstr_t new_sstr;
-    if (start < 0 || start >= s.length || length < 0) {
+    if (start >= s.length) {
         return s;
     }
     if (length > s.length-start) {
--- a/src/server/util/io.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/util/io.c	Thu Jun 20 14:07:46 2013 +0200
@@ -95,7 +95,7 @@
         struct iovec io[2];
         char chunk_len[16];
         io[0].iov_base = chunk_len;
-        io[0].iov_len = snprintf(chunk_len, 16, "\n%x\r\n", nbytes);
+        io[0].iov_len = snprintf(chunk_len, 16, "\n%zx\r\n", nbytes);
         io[1].iov_base = buf;
         io[1].iov_len = nbytes;
         ssize_t r = writev(st->fd, io, 2);
@@ -114,7 +114,7 @@
         for(int i=0;i<iovcnt;i++) {
             len += iovec[i].iov_len;
         }
-        io[0].iov_len = snprintf(chunk_len, 16, "\n%x\r\n", len);
+        io[0].iov_len = snprintf(chunk_len, 16, "\n%zx\r\n", len);
         memcpy(io + 1, iovec, iovcnt * sizeof(struct iovec));
         ssize_t r = writev(st->fd, io, iovcnt + 1);
         return r - io[0].iov_len;
@@ -150,7 +150,8 @@
         hdtr.trailers = &trvec;
         hdtr.trl_cnt = 1;
         
-        ret = sendfile(sfd->fd->fd, st->fd, sfd->offset, (off_t*)&sfd->len, &hdtr, 0);
+        off_t len = sfd->len;
+        ret = sendfile(sfd->fd->fd, st->fd, sfd->offset, &len, &hdtr, 0);
 #else
         ret = sendfile(st->fd, sfd->fd->fd, &fileoffset, sfd->len);
 #endif
--- a/src/server/util/uri.cpp	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/util/uri.cpp	Thu Jun 20 14:07:46 2013 +0200
@@ -319,7 +319,7 @@
     // As per RFC2396, URI path segments can contain parameters beginning with
     // ';'.  These parameters must be removed from the ppath.  Bug 418271
     char* out;
-    if (out = strchr(uri, ';')) {
+    if((out = strchr(uri, ';'))) {
         char* in = out;
         while (*in) {
             if (*in == ';') {
--- a/src/server/webdav/webdav.c	Thu Jun 20 13:27:07 2013 +0200
+++ b/src/server/webdav/webdav.c	Thu Jun 20 14:07:46 2013 +0200
@@ -572,7 +572,7 @@
         if(!S_ISDIR(st.st_mode)) {
             prop.name = "getcontentlength";
             char buf[32];
-            size_t n = snprintf(buf, 32, "%d", st.st_size);
+            size_t n = snprintf(buf, 32, "%lld", st.st_size);
             dav_propfind_add_str_prop(rq, &prop, buf, n);
         }
         
@@ -600,7 +600,7 @@
             }
         } else if(!strcmp(s, "getcontentlength") && !S_ISDIR(st.st_mode)) {
             char buf[32];
-            size_t n = snprintf(buf, 32, "%d", st.st_size);
+            size_t n = snprintf(buf, 32, "%lld", st.st_size);
             dav_propfind_add_str_prop(rq, prop, buf, n);
         } else if(!strcmp(s, "getlastmodified")) {
             sstr_t s = date_format_http(st.st_mtime, rq->sn->pool);

mercurial