]> arthur.barton.de Git - netdata.git/commitdiff
added gcc printf checking to debug(), error(), fatal(), info(), web_sprintf() and...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 11 Jun 2016 19:26:17 +0000 (22:26 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 11 Jun 2016 19:26:17 +0000 (22:26 +0300)
17 files changed:
src/appconfig.c
src/apps_plugin.c
src/common.c
src/dictionary.c
src/log.h
src/main.c
src/plugin_tc.c
src/plugins_d.c
src/proc_net_stat_synproxy.c
src/registry.c
src/rrd.c
src/rrd2json.c
src/sys_fs_cgroup.c
src/web_buffer.c
src/web_buffer.h
src/web_client.c
src/web_server.c

index 415b475d7ec0eca20559981f14200823ee8e8c4f..2ca12637dbf499c7f69d2420b98ac3ff8a0b6833 100644 (file)
@@ -417,7 +417,7 @@ int load_config(char *filename, int overwrite_used)
                if(!cv) cv = config_value_create(co, name, value);
                else {
                        if(((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) {
-                               debug(D_CONFIG, "Overwriting '%s/%s'.", line, co->name, cv->name);
+                               debug(D_CONFIG, "Line %d, overwriting '%s/%s'.", line, co->name, cv->name);
                                free(cv->value);
                                cv->value = strdup(value);
                                if(!cv->value) fatal("Cannot allocate config.value");
index 8a08e2deb26986980dd0c7e908adccc497ff9214..92c0a4ae31bd450d44ad0c545578812a100a0332 100644 (file)
@@ -172,7 +172,7 @@ void *realloc_debug(const char *file, int line, const char *function, void *ptr,
        allocations.allocated -= old_size;
 
        debug(D_MEMORY, "MEMORY: Re-allocated from %zu to %zu bytes for %s/%u@%s."
-               " Status: allocated %z in %zu allocs."
+               " Status: allocated %zu in %zu allocs."
                , old_size, size
                , function, line, file
                , allocations.allocated
@@ -547,7 +547,7 @@ int read_apps_groups_conf(const char *name)
 
                        struct target *n = get_apps_groups_target(s, w);
                        if(!n) {
-                               error("Cannot create target '%s' (line %d, word %d)", s, line, word);
+                               error("Cannot create target '%s' (line %lu, word %lu)", s, line, word);
                                continue;
                        }
 
index 5e6d037640b9c313a9c63cdb853faafae20d78ed..195bfc84df7b2942b9abb904b14dbd7f85a88e60 100644 (file)
@@ -701,6 +701,18 @@ void *mymmap(const char *filename, size_t size, int flags, int ksm)
 #ifdef MADV_MERGEABLE
                                }
                                else {
+/*
+                                       // test - load the file into memory
+                                       mem = calloc(1, size);
+                                       if(mem) {
+                                               if(lseek(fd, 0, SEEK_SET) == 0) {
+                                                       if(read(fd, mem, size) != (ssize_t)size)
+                                                               error("Cannot read from file '%s'", filename);
+                                               }
+                                               else
+                                                       error("Cannot seek to beginning of file '%s'.", filename);
+                                       }
+*/
                                        mem = mmap(NULL, size, PROT_READ|PROT_WRITE, flags|MAP_ANONYMOUS, -1, 0);
                                        if(mem != MAP_FAILED) {
                                                if(lseek(fd, 0, SEEK_SET) == 0) {
index 3b9e8a90be5ab855e2b0f5a3927d01d2278aa944..8dbbc64c4febacc1060dd3095d1e5eec1b7f45b0 100644 (file)
@@ -90,14 +90,14 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
        debug(D_DICTIONARY, "Creating name value entry for name '%s'.", name);
 
        NAME_VALUE *nv = calloc(1, sizeof(NAME_VALUE));
-       if(unlikely(!nv)) fatal("Cannot allocate name_value of size %z", sizeof(NAME_VALUE));
+       if(unlikely(!nv)) fatal("Cannot allocate name_value of size %zu", sizeof(NAME_VALUE));
 
        if(dict->flags & DICTIONARY_FLAG_NAME_LINK_DONT_CLONE)
                nv->name = (char *)name;
        else {
                nv->name = strdup(name);
                if (unlikely(!nv->name))
-                       fatal("Cannot allocate name_value.name of size %z", strlen(name));
+                       fatal("Cannot allocate name_value.name of size %zu", strlen(name));
        }
 
        nv->hash = (hash)?hash:simple_hash(nv->name);
@@ -107,7 +107,7 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
        else {
                nv->value = malloc(value_len);
                if (unlikely(!nv->value))
-                       fatal("Cannot allocate name_value.value of size %z", value_len);
+                       fatal("Cannot allocate name_value.value of size %zu", value_len);
 
                memcpy(nv->value, value, value_len);
        }
@@ -215,7 +215,7 @@ void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t val
                                        *old = nv->value;
 
                        if(unlikely(!nv->value))
-                               fatal("Cannot allocate value of size %z", value_len);
+                               fatal("Cannot allocate value of size %zu", value_len);
 
                        memcpy(value, value, value_len);
                        nv->value = value;
index 4d441e8f6ade6913dc2d7d97d6413d8834d1d7f5..f3f504487a7a1f02cb4eeb3f3f04223fa24d290b 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -59,10 +59,10 @@ extern int error_log_limit(int reset);
 #define fatal(args...)   fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args)
 
 extern void log_date(FILE *out);
-extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn));
-extern void log_access( const char *fmt, ... );
+extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
+extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
+extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 5, 6)));
+extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn, format (printf, 4, 5)));
+extern void log_access( const char *fmt, ... ) __attribute__ (( format (printf, 1, 2)));
 
 #endif /* NETDATA_LOG_H */
index b053c281c29f5d9e89daa2e54e6458008348c553..b8d8391f4a637ac434a846e9c29672b4c3631b43 100644 (file)
@@ -119,17 +119,17 @@ void web_server_threading_selection(void) {
        else if(!strcmp(s, "fixed"))
                web_gzip_strategy = Z_FIXED;
        else {
-               error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.");
+               error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
                web_gzip_strategy = Z_DEFAULT_STRATEGY;
        }
 
        web_gzip_level = (int)config_get_number("global", "web compression level", 3);
        if(web_gzip_level < 1) {
-               error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).");
+               error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
                web_gzip_level = 1;
        }
        else if(web_gzip_level > 9) {
-               error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).");
+               error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
                web_gzip_level = 9;
        }
 #endif /* NETDATA_WITH_ZLIB */
index 3d3e35217c0404ed6491cc02a545170f6ce6044a..45f129832c413d64d21a62fddec97912bc0b699e 100644 (file)
@@ -257,7 +257,7 @@ static inline void tc_device_commit(struct tc_device *d)
                                RRDDIM *rd = rrddim_find(st, c->id);
 
                                if(!rd) {
-                                       debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s'", st->id, c->id, c->name);
+                                       debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s' (name: '%s')", st->id, c->id, c->name);
 
                                        // new class, we have to add it
                                        rd = rrddim_add(st, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_INCREMENTAL);
index d7815433e4db7769c8d725d4571dd8557654f770..23757bbe7d9f8af448045f90fdff798f2df2fa68 100644 (file)
@@ -423,7 +423,7 @@ void *pluginsd_worker_thread(void *arg)
                                        sleep((unsigned int) (cd->update_every * 10));
                                }
                                else {
-                                       error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). We tried %d times to restart it, but it failed to generate data. Disabling it.", cd->fullfilename, code, cd->successful_collections, cd->serial_failures);
+                                       error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). We tried %zu times to restart it, but it failed to generate data. Disabling it.", cd->fullfilename, code, cd->successful_collections, cd->serial_failures);
                                        cd->enabled = 0;
                                }
                        }
@@ -439,7 +439,7 @@ void *pluginsd_worker_thread(void *arg)
                                        sleep((unsigned int) (cd->update_every * 10));
                                }
                                else {
-                                       error("PLUGINSD: '%s' (pid %d) does not generate useful output, although it reports success (exits with 0), but we have tried %d times to collect something. Disabling it.", cd->fullfilename, cd->pid, cd->serial_failures);
+                                       error("PLUGINSD: '%s' (pid %d) does not generate useful output, although it reports success (exits with 0), but we have tried %zu times to collect something. Disabling it.", cd->fullfilename, cd->pid, cd->serial_failures);
                                        cd->enabled = 0;
                                }
                        }
index 508b7d3b40fea62c90a190d557c704d87325f9f2..d90a376f0914bbe3a9b903ad74b9302fde6d1b20 100644 (file)
@@ -37,9 +37,9 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
        if(!ff) return 0; // we return 0, so that we will retry to open it next time
 
        // make sure we have 3 lines
-       unsigned long lines = procfile_lines(ff), l;
+       size_t lines = procfile_lines(ff), l;
        if(lines < 2) {
-               error("/proc/net/stat/synproxy has %d lines, expected no less than 2. Disabling it.", lines);
+               error("/proc/net/stat/synproxy has %zu lines, expected no less than 2. Disabling it.", lines);
                return 1;
        }
 
index 8c3535a3800bc979851eb547de0891cfa5bd66d8..60a9ced72c92a479879b321b54e5451f164d7047 100644 (file)
@@ -337,7 +337,7 @@ static inline URL *registry_url_allocate_nolock(const char *url, size_t urllen)
 
        debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): allocating %zu bytes", url, sizeof(URL) + urllen);
        URL *u = malloc(sizeof(URL) + urllen);
-       if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen);
+       if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen, url);
 
        // a simple strcpy() should do the job
        // but I prefer to be safe, since the caller specified urllen
@@ -782,7 +782,7 @@ int registry_log_load(void) {
 
                                        // verify it is valid
                                        if (unlikely(len < 85 || s[1] != '\t' || s[10] != '\t' || s[47] != '\t' || s[84] != '\t')) {
-                                               error("Registry: log line %u is wrong (len = %zu).", line, len);
+                                               error("Registry: log line %zu is wrong (len = %zu).", line, len);
                                                continue;
                                        }
                                        s[1] = s[10] = s[47] = s[84] = '\0';
@@ -797,7 +797,7 @@ int registry_log_load(void) {
                                        char *url = name;
                                        while(*url && *url != '\t') url++;
                                        if(!*url) {
-                                               error("Registry: log line %u does not have a url.", line);
+                                               error("Registry: log line %zu does not have a url.", line);
                                                continue;
                                        }
                                        *url++ = '\0';
@@ -1521,7 +1521,7 @@ static inline size_t registry_load(void) {
                switch(*s) {
                        case 'T': // totals
                                if(unlikely(len != 103 || s[1] != '\t' || s[18] != '\t' || s[35] != '\t' || s[52] != '\t' || s[69] != '\t' || s[86] != '\t' || s[103] != '\0')) {
-                                       error("Registry totals line %u is wrong (len = %zu).", line, len);
+                                       error("Registry totals line %zu is wrong (len = %zu).", line, len);
                                        continue;
                                }
                                registry.persons_count = strtoull(&s[2], NULL, 16);
@@ -1536,7 +1536,7 @@ static inline size_t registry_load(void) {
                                m = NULL;
                                // verify it is valid
                                if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
-                                       error("Registry person line %u is wrong (len = %zu).", line, len);
+                                       error("Registry person line %zu is wrong (len = %zu).", line, len);
                                        continue;
                                }
 
@@ -1551,7 +1551,7 @@ static inline size_t registry_load(void) {
                                p = NULL;
                                // verify it is valid
                                if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
-                                       error("Registry person line %u is wrong (len = %zu).", line, len);
+                                       error("Registry person line %zu is wrong (len = %zu).", line, len);
                                        continue;
                                }
 
@@ -1570,7 +1570,7 @@ static inline size_t registry_load(void) {
 
                                // verify it is valid
                                if(len < 69 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t' || s[68] != '\t') {
-                                       error("Registry person URL line %u is wrong (len = %zu).", line, len);
+                                       error("Registry person URL line %zu is wrong (len = %zu).", line, len);
                                        continue;
                                }
 
@@ -1580,7 +1580,7 @@ static inline size_t registry_load(void) {
                                char *url = &s[69];
                                while(*url && *url != '\t') url++;
                                if(!*url) {
-                                       error("Registry person URL line %u does not have a url.", line);
+                                       error("Registry person URL line %zu does not have a url.", line);
                                        continue;
                                }
                                *url++ = '\0';
@@ -1607,7 +1607,7 @@ static inline size_t registry_load(void) {
 
                                // verify it is valid
                                if(len < 32 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t') {
-                                       error("Registry person URL line %u is wrong (len = %zu).", line, len);
+                                       error("Registry person URL line %zu is wrong (len = %zu).", line, len);
                                        continue;
                                }
 
index 60e8d6f2f192567ae967892359ec6c92c6860127..28efff0a15074992287fba30a053c58eb9974da9 100644 (file)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -876,7 +876,7 @@ unsigned long long rrdset_done(RRDSET *st)
 
        // check if we will re-write the entire data set
        if(unlikely(usecdiff(&st->last_collected_time, &st->last_updated) > st->update_every * st->entries * 1000000ULL)) {
-               info("%s: too old data (last updated at %u.%u, last collected at %u.%u). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
+               info("%s: too old data (last updated at %zu.%zu, last collected at %zu.%zu). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
                rrdset_reset(st);
 
                st->usec_since_last_update = st->update_every * 1000000ULL;
index 4b5873cf033f7e2fd743a1db67e6a77f51f0fcaa..9639247eb04d1e191dd985796801c1b908d63eee 100644 (file)
@@ -292,7 +292,7 @@ typedef struct rrdresult {
        long c;                                 // current line ( -1 ~ n ), ( -1 = none, use rrdr_rows() to get number of rows )
 
        long group;                             // how many collected values were grouped for each row
-       long update_every;              // what is the suggested update frequency in seconds
+       int update_every;               // what is the suggested update frequency in seconds
 
        calculated_number min;
        calculated_number max;
@@ -508,10 +508,10 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, uint32_t opti
                        , kq, kq, sq, r->st->name, sq
                        , kq, kq, r->update_every
                        , kq, kq, r->st->update_every
-                       , kq, kq, rrdset_first_entry_t(r->st)
-                       , kq, kq, rrdset_last_entry_t(r->st)
-                       , kq, kq, r->before
-                       , kq, kq, r->after
+                       , kq, kq, (uint32_t)rrdset_first_entry_t(r->st)
+                       , kq, kq, (uint32_t)rrdset_last_entry_t(r->st)
+                       , kq, kq, (uint32_t)r->before
+                       , kq, kq, (uint32_t)r->after
                        , kq, kq);
 
        for(c = 0, i = 0, rd = r->st->dimensions; rd && c < r->d ;c++, rd = rd->next) {
@@ -606,8 +606,8 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, uint32_t opti
        }
 
        buffer_sprintf(wb, "],\n"
-                       "       %sdimensions%s: %d,\n"
-                       "       %spoints%s: %d,\n"
+                       "       %sdimensions%s: %ld,\n"
+                       "       %spoints%s: %ld,\n"
                        "       %sformat%s: %s"
                        , kq, kq, i
                        , kq, kq, rows
@@ -697,7 +697,7 @@ static void rrdr2json(RRDR *r, BUFFER *wb, uint32_t options, int datatable)
                snprintfz(overflow_annotation, 200, ",{%sv%s:%sRESET OR OVERFLOW%s},{%sv%s:%sThe counters have been wrapped.%s}", kq, kq, sq, sq, kq, kq, sq, sq);
                snprintfz(normal_annotation,   200, ",{%sv%s:null},{%sv%s:null}", kq, kq, kq, kq);
 
-               buffer_sprintf(wb, "{\n %scols%s:\n     [\n", kq, kq, kq, kq);
+               buffer_sprintf(wb, "{\n %scols%s:\n     [\n", kq, kq);
                buffer_sprintf(wb, "            {%sid%s:%s%s,%slabel%s:%stime%s,%spattern%s:%s%s,%stype%s:%sdatetime%s},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq);
                buffer_sprintf(wb, "            {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotation%s}},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
                buffer_sprintf(wb, "            {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotationText%s}}", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
@@ -1221,7 +1221,7 @@ static RRDR *rrdr_create(RRDSET *st, long n)
        return r;
 
 cleanup:
-       error("Cannot allocate RRDR memory for %d entries", n);
+       error("Cannot allocate RRDR memory for %ld entries", n);
        if(likely(r)) rrdr_free(r);
        return NULL;
 }
@@ -1298,22 +1298,22 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
 
 #ifdef NETDATA_INTERNAL_CHECKS
        if(after_new < first_entry_t) {
-               error("after_new %u is too small, minimum %u", after_new, first_entry_t);
+               error("after_new %u is too small, minimum %u", (uint32_t)after_new, (uint32_t)first_entry_t);
        }
        if(after_new > last_entry_t) {
-               error("after_new %u is too big, maximum %u", after_new, last_entry_t);
+               error("after_new %u is too big, maximum %u", (uint32_t)after_new, (uint32_t)last_entry_t);
        }
        if(before_new < first_entry_t) {
-               error("before_new %u is too small, minimum %u", before_new, first_entry_t);
+               error("before_new %u is too small, minimum %u", (uint32_t)before_new, (uint32_t)first_entry_t);
        }
        if(before_new > last_entry_t) {
-               error("before_new %u is too big, maximum %u", before_new, last_entry_t);
+               error("before_new %u is too big, maximum %u", (uint32_t)before_new, (uint32_t)last_entry_t);
        }
        if(start_at_slot < 0 || start_at_slot >= st->entries) {
-               error("start_at_slot is invalid %ld, expected %ld to %ld", start_at_slot, 0, st->entries - 1);
+               error("start_at_slot is invalid %ld, expected 0 to %ld", start_at_slot, st->entries - 1);
        }
        if(stop_at_slot < 0 || stop_at_slot >= st->entries) {
-               error("stop_at_slot is invalid %ld, expected %ld to %ld", stop_at_slot, 0, st->entries - 1);
+               error("stop_at_slot is invalid %ld, expected 0 to %ld", stop_at_slot, st->entries - 1);
        }
        if(points_new > (before_new - after_new) / group / st->update_every + 1) {
                error("points_new %ld is more than points %ld", points_new, (before_new - after_new) / group / st->update_every + 1);
@@ -1342,13 +1342,13 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
        RRDR *r = rrdr_create(st, points);
        if(!r) {
 #ifdef NETDATA_INTERNAL_CHECKS
-               error("Cannot create RRDR for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
+               error("Cannot create RRDR for %s, after=%u, before=%u, duration=%u, points=%ld", st->id, (uint32_t)after, (uint32_t)before, (uint32_t)duration, points);
 #endif
                return NULL;
        }
        if(!r->d) {
 #ifdef NETDATA_INTERNAL_CHECKS
-               error("Returning empty RRDR (no dimensions in RRDSET) for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
+               error("Returning empty RRDR (no dimensions in RRDSET) for %s, after=%u, before=%u, duration=%u, points=%ld", st->id, (uint32_t)after, (uint32_t)before, (uint32_t)duration, points);
 #endif
                return r;
        }
@@ -1365,14 +1365,14 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
        // -------------------------------------------------------------------------
        // checks for debugging
 
-       if(debug) debug(D_RRD_STATS, "INFO %s first_t: %lu, last_t: %lu, all_duration: %lu, after: %lu, before: %lu, duration: %lu, points: %ld, group: %ld"
+       if(debug) debug(D_RRD_STATS, "INFO %s first_t: %u, last_t: %u, all_duration: %u, after: %u, before: %u, duration: %u, points: %ld, group: %ld"
                        , st->id
-                       , first_entry_t
-                       , last_entry_t
-                       , last_entry_t - first_entry_t
-                       , after
-                       , before
-                       , duration
+                       , (uint32_t)first_entry_t
+                       , (uint32_t)last_entry_t
+                       , (uint32_t)(last_entry_t - first_entry_t)
+                       , (uint32_t)after
+                       , (uint32_t)before
+                       , (uint32_t)duration
                        , points
                        , group
                        );
@@ -1407,13 +1407,13 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
                        dt = st->update_every,
                        group_start_t = 0;
 
-       if(unlikely(debug)) debug(D_RRD_STATS, "BEGIN %s after_t: %lu (stop_at_t: %ld), before_t: %lu (start_at_t: %ld), start_t(now): %lu, current_entry: %ld, entries: %ld"
+       if(unlikely(debug)) debug(D_RRD_STATS, "BEGIN %s after_t: %u (stop_at_t: %ld), before_t: %u (start_at_t: %ld), start_t(now): %u, current_entry: %ld, entries: %ld"
                        , st->id
-                       , after
+                       , (uint32_t)after
                        , stop_at_slot
-                       , before
+                       , (uint32_t)before
                        , start_at_slot
-                       , now
+                       , (uint32_t)now
                        , st->current_entry
                        , st->entries
                        );
@@ -1915,15 +1915,15 @@ time_t rrd_stats_json(int type, RRDSET *st, BUFFER *wb, long points, long group,
                long count = 0, printed = 0, group_count = 0;
                last_timestamp = 0;
 
-               if(st->debug) debug(D_RRD_STATS, "%s: REQUEST after:%lu before:%lu, points:%d, group:%d, CHART cur:%ld first: %lu last:%lu, CALC start_t:%ld, stop_t:%ld"
+               if(st->debug) debug(D_RRD_STATS, "%s: REQUEST after:%u before:%u, points:%ld, group:%ld, CHART cur:%ld first: %u last:%u, CALC start_t:%ld, stop_t:%ld"
                                        , st->id
-                                       , after
-                                       , before
+                                       , (uint32_t)after
+                                       , (uint32_t)before
                                        , points
                                        , group
                                        , st->current_entry
-                                       , rrdset_first_entry_t(st)
-                                       , rrdset_last_entry_t(st)
+                                       , (uint32_t)rrdset_first_entry_t(st)
+                                       , (uint32_t)rrdset_last_entry_t(st)
                                        , t
                                        , stop_at_t
                                        );
index 9f3d3f0fdbc0fa17fcbbcc998182ed878cb83411..904b8a15133345c72687922e543a0d26c8f41c58 100644 (file)
@@ -262,7 +262,7 @@ void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
 
                        ca->cpu_percpu = malloc(sizeof(unsigned long long) * i);
                        if(!ca->cpu_percpu)
-                               fatal("Cannot allocate memory (%z bytes)", sizeof(unsigned long long) * i);
+                               fatal("Cannot allocate memory (%zu bytes)", sizeof(unsigned long long) * i);
 
                        ca->cpus = i;
                }
index 3ff813984af5fc313d20cc6489c55cb16e0ce353..6d0ccf0f42ad82c157fb49f4544e8bdd925b86e8 100644 (file)
@@ -281,11 +281,11 @@ void buffer_date(BUFFER *wb, int year, int month, int day, int hours, int minute
        buffer_overflow_check(wb);
 }
 
-BUFFER *buffer_create(long size)
+BUFFER *buffer_create(size_t size)
 {
        BUFFER *b;
 
-       debug(D_WEB_BUFFER, "Creating new web buffer of size %d.", size);
+       debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size);
 
        b = calloc(1, sizeof(BUFFER));
        if(!b) {
@@ -295,7 +295,7 @@ BUFFER *buffer_create(long size)
 
        b->buffer = malloc(size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
        if(!b->buffer) {
-               error("Cannot allocate a buffer of size %u.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
+               error("Cannot allocate a buffer of size %zu.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
                free(b);
                return NULL;
        }
@@ -312,7 +312,7 @@ void buffer_free(BUFFER *b)
 {
        buffer_overflow_check(b);
 
-       debug(D_WEB_BUFFER, "Freeing web buffer of size %d.", b->size);
+       debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size);
 
        if(b->buffer) free(b->buffer);
        free(b);
@@ -329,11 +329,11 @@ void buffer_increase(BUFFER *b, size_t free_size_required)
        size_t increase = free_size_required - left;
        if(increase < WEB_DATA_LENGTH_INCREASE_STEP) increase = WEB_DATA_LENGTH_INCREASE_STEP;
 
-       debug(D_WEB_BUFFER, "Increasing data buffer from size %d to %d.", b->size, b->size + increase);
+       debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + increase);
 
        b->buffer = realloc(b->buffer, b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
        if(!b->buffer)
-               fatal("Failed to increase data buffer from size %d to %d.",
+               fatal("Failed to increase data buffer from size %zu to %zu.",
                        b->size + sizeof(BUFFER_OVERFLOW_EOF) + 2,
                        b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
 
index 73533f499d8fe33dea9b12d18f42f49be8f9392a..8e026496746f1c7863e77e93fff693829361bf81 100644 (file)
@@ -57,13 +57,13 @@ extern void buffer_rrd_value(BUFFER *wb, calculated_number value);
 extern void buffer_date(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
 extern void buffer_jsdate(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
 
-extern BUFFER *buffer_create(long size);
+extern BUFFER *buffer_create(size_t size);
 extern void buffer_free(BUFFER *b);
 extern void buffer_increase(BUFFER *b, size_t free_size_required);
 
-extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...);
+extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
 extern void buffer_vsprintf(BUFFER *wb, const char *fmt, va_list args);
-extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...);
+extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...) __attribute__ (( format (printf, 2, 3)));
 
 extern void buffer_char_replace(BUFFER *wb, char from, char to);
 
index eff90446b3f2182b54f333c472a39497a825bf48..aec9e92e89dc2e71bd03fbd6d56711386912f1d3 100644 (file)
@@ -2050,7 +2050,7 @@ void web_client_process(struct web_client *w) {
        buffer_strcat(w->response.header_output, "\r\n");
 
        // sent the HTTP header
-       debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %d: '%s'"
+       debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %zu: '%s'"
                        , w->id
                        , buffer_strlen(w->response.header_output)
                        , buffer_tostring(w->response.header_output)
@@ -2063,8 +2063,10 @@ void web_client_process(struct web_client *w) {
                if(bytes > 0)
                        w->stats_sent_bytes += bytes;
 
-               debug(D_WEB_CLIENT, "%llu: HTTP Header failed to be sent (I sent %d bytes but the system sent %d bytes). Closing web client.", w->id,
-                         buffer_strlen(w->response.header_output), bytes);
+               debug(D_WEB_CLIENT, "%llu: HTTP Header failed to be sent (I sent %zu bytes but the system sent %zd bytes). Closing web client."
+                       , w->id
+                       , buffer_strlen(w->response.header_output)
+                       , bytes);
 
                WEB_CLIENT_IS_DEAD(w);
                return;
@@ -2079,16 +2081,16 @@ void web_client_process(struct web_client *w) {
        // pretty logging
        switch(w->mode) {
                case WEB_CLIENT_MODE_OPTIONS:
-                       debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
+                       debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
                        break;
 
                case WEB_CLIENT_MODE_NORMAL:
-                       debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
+                       debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
                        break;
 
                case WEB_CLIENT_MODE_FILECOPY:
                        if(w->response.rlen) {
-                               debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %d bytes to client.", w->id, w->response.rlen);
+                               debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %zu bytes to client.", w->id, w->response.rlen);
                                w->wait_receive = 1;
 
                                /*
@@ -2116,13 +2118,13 @@ void web_client_process(struct web_client *w) {
 
 ssize_t web_client_send_chunk_header(struct web_client *w, size_t len)
 {
-       debug(D_DEFLATE, "%llu: OPEN CHUNK of %d bytes (hex: %x).", w->id, len, len);
+       debug(D_DEFLATE, "%llu: OPEN CHUNK of %zu bytes (hex: %zx).", w->id, len, len);
        char buf[24];
        sprintf(buf, "%zX\r\n", len);
        
        ssize_t bytes = send(w->ofd, buf, strlen(buf), 0);
        if(bytes > 0) {
-               debug(D_DEFLATE, "%llu: Sent chunk header %d bytes.", w->id, bytes);
+               debug(D_DEFLATE, "%llu: Sent chunk header %zd bytes.", w->id, bytes);
                w->stats_sent_bytes += bytes;
        }
 
@@ -2144,7 +2146,7 @@ ssize_t web_client_send_chunk_close(struct web_client *w)
 
        ssize_t bytes = send(w->ofd, "\r\n", 2, 0);
        if(bytes > 0) {
-               debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
+               debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
                w->stats_sent_bytes += bytes;
        }
 
@@ -2166,7 +2168,7 @@ ssize_t web_client_send_chunk_finalize(struct web_client *w)
 
        ssize_t bytes = send(w->ofd, "\r\n0\r\n\r\n", 7, 0);
        if(bytes > 0) {
-               debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
+               debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
                w->stats_sent_bytes += bytes;
        }
 
@@ -2190,7 +2192,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
        // when using compression,
        // w->response.sent is the amount of bytes passed through compression
 
-       debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %d, w->response.sent = %d, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %d, w->response.zstream.avail_out = %d, w->response.zstream.total_in = %d, w->response.zstream.total_out = %d.",
+       debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %d, w->response.zstream.avail_out = %d, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.",
                w->id, w->response.data->len, w->response.sent, w->response.zhave, w->response.zsent, w->response.zstream.avail_in, w->response.zstream.avail_out, w->response.zstream.total_in, w->response.zstream.total_out);
 
        if(w->response.data->len - w->response.sent == 0 && w->response.zstream.avail_in == 0 && w->response.zhave == w->response.zsent && w->response.zstream.avail_out != 0) {
@@ -2232,7 +2234,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
                        if(t < 0) return t;
                }
 
-               debug(D_DEFLATE, "%llu: Compressing %d new bytes starting from %d (and %d left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in);
+               debug(D_DEFLATE, "%llu: Compressing %zu new bytes starting from %zu (and %u left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in);
 
                // give the compressor all the data not passed through the compressor yet
                if(w->response.data->len > w->response.sent) {
@@ -2268,7 +2270,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
                // keep track of the bytes passed through the compressor
                w->response.sent = w->response.data->len;
 
-               debug(D_DEFLATE, "%llu: Compression produced %d bytes.", w->id, w->response.zhave);
+               debug(D_DEFLATE, "%llu: Compression produced %zu bytes.", w->id, w->response.zhave);
 
                // open a new chunk
                ssize_t t2 = web_client_send_chunk_header(w, w->response.zhave);
@@ -2276,19 +2278,19 @@ ssize_t web_client_send_deflate(struct web_client *w)
                t += t2;
        }
        
-       debug(D_WEB_CLIENT, "%llu: Sending %d bytes of data (+%d of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
+       debug(D_WEB_CLIENT, "%llu: Sending %zu bytes of data (+%zd of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
 
        len = send(w->ofd, &w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT);
        if(len > 0) {
                w->stats_sent_bytes += len;
                w->response.zsent += len;
                len += t;
-               debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, len);
+               debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, len);
        }
        else if(len == 0) {
                debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).",
                        w->id, w->response.zhave, w->response.zsent, w->response.zhave - w->response.zsent);
-               
+
                WEB_CLIENT_IS_DEAD(w);
        }
        else {
@@ -2338,7 +2340,7 @@ ssize_t web_client_send(struct web_client *w) {
        if(likely(bytes > 0)) {
                w->stats_sent_bytes += bytes;
                w->response.sent += bytes;
-               debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, bytes);
+               debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, bytes);
        }
        else if(likely(bytes == 0)) {
                debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id);
@@ -2373,7 +2375,7 @@ ssize_t web_client_receive(struct web_client *w)
                w->response.data->len += bytes;
                w->response.data->buffer[w->response.data->len] = '\0';
 
-               debug(D_WEB_CLIENT, "%llu: Received %d bytes.", w->id, bytes);
+               debug(D_WEB_CLIENT, "%llu: Received %zu bytes.", w->id, bytes);
                debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]);
 
                if(w->mode == WEB_CLIENT_MODE_FILECOPY) {
@@ -2441,7 +2443,7 @@ void *web_client_main(void *ptr)
                        break;
                }
                else if(unlikely(!w->wait_receive && !w->wait_send)) {
-                       debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.");
+                       debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.", w->id);
                        break;
                }
 
index 1ef5a54ee0f234abf944160e333d805ed807de2b..e349469fedf394be7528080d51f7cddb519faf67 100644 (file)
@@ -277,7 +277,7 @@ void *socket_listen_main_multi_threaded(void *ptr) {
                                sleep(5);
                                create_listen_socket();
                                if(listen_fd < 0)
-                                       fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
+                                       fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
 
                                failures = 0;
                        }
@@ -294,7 +294,7 @@ void *socket_listen_main_multi_threaded(void *ptr) {
                                }
 
                                if(pthread_create(&w->thread, NULL, web_client_main, w) != 0) {
-                                       error("%llu: failed to create new thread for web client.");
+                                       error("%llu: failed to create new thread for web client.", w->id);
                                        w->obsolete = 1;
                                }
                                else if(pthread_detach(w->thread) != 0) {
@@ -446,7 +446,7 @@ void *socket_listen_main_single_threaded(void *ptr) {
 
                                create_listen_socket();
                                if(listen_fd < 0 || listen_fd >= FD_SETSIZE)
-                                       fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
+                                       fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
 
                                FD_ZERO (&ifds);
                                FD_ZERO (&ofds);