added gcc printf checking to debug(), error(), fatal(), info(), web_sprintf() and fixed all the occurences reported by the compiler
Costa Tsaousis (ktsaou) committed
Jun 11, 2016 at 22:26 UTC
56529fd082e321b1ea82cf3b6eef3795dc073b6d
17 files changed
+109
-95
src/appconfig.c
+1
-1
@@ -417,7 +417,7 @@ int load_config(char *filename, int overwrite_used)
417
if(!cv) cv = config_value_create(co, name, value);
418
else {
419
if(((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) {
420
- debug(D_CONFIG, "Overwriting '%s/%s'.", line, co->name, cv->name);
420
+ debug(D_CONFIG, "Line %d, overwriting '%s/%s'.", line, co->name, cv->name);
421
free(cv->value);
422
cv->value = strdup(value);
423
if(!cv->value) fatal("Cannot allocate config.value");
src/apps_plugin.c
+2
-2
@@ -172,7 +172,7 @@ void *realloc_debug(const char *file, int line, const char *function, void *ptr,
172
allocations.allocated -= old_size;
173
174
debug(D_MEMORY, "MEMORY: Re-allocated from %zu to %zu bytes for %s/%u@%s."
175
- " Status: allocated %z in %zu allocs."
175
+ " Status: allocated %zu in %zu allocs."
176
, old_size, size
177
, function, line, file
178
, allocations.allocated
@@ -547,7 +547,7 @@ int read_apps_groups_conf(const char *name)
547
548
struct target *n = get_apps_groups_target(s, w);
549
if(!n) {
550
- error("Cannot create target '%s' (line %d, word %d)", s, line, word);
550
+ error("Cannot create target '%s' (line %lu, word %lu)", s, line, word);
551
continue;
552
}
553
src/common.c
+12
@@ -701,6 +701,18 @@ void *mymmap(const char *filename, size_t size, int flags, int ksm)
701
#ifdef MADV_MERGEABLE
702
}
703
else {
704
+/*
705
+ // test - load the file into memory
706
+ mem = calloc(1, size);
707
+ if(mem) {
708
+ if(lseek(fd, 0, SEEK_SET) == 0) {
709
+ if(read(fd, mem, size) != (ssize_t)size)
710
+ error("Cannot read from file '%s'", filename);
711
+ }
712
+ else
713
+ error("Cannot seek to beginning of file '%s'.", filename);
714
+ }
715
+*/
716
mem = mmap(NULL, size, PROT_READ|PROT_WRITE, flags|MAP_ANONYMOUS, -1, 0);
717
if(mem != MAP_FAILED) {
718
if(lseek(fd, 0, SEEK_SET) == 0) {
src/dictionary.c
+4
-4
@@ -90,14 +90,14 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
90
debug(D_DICTIONARY, "Creating name value entry for name '%s'.", name);
91
92
NAME_VALUE *nv = calloc(1, sizeof(NAME_VALUE));
93
- if(unlikely(!nv)) fatal("Cannot allocate name_value of size %z", sizeof(NAME_VALUE));
93
+ if(unlikely(!nv)) fatal("Cannot allocate name_value of size %zu", sizeof(NAME_VALUE));
94
95
if(dict->flags & DICTIONARY_FLAG_NAME_LINK_DONT_CLONE)
96
nv->name = (char *)name;
97
else {
98
nv->name = strdup(name);
99
if (unlikely(!nv->name))
100
- fatal("Cannot allocate name_value.name of size %z", strlen(name));
100
+ fatal("Cannot allocate name_value.name of size %zu", strlen(name));
101
}
102
103
nv->hash = (hash)?hash:simple_hash(nv->name);
@@ -107,7 +107,7 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
107
else {
108
nv->value = malloc(value_len);
109
if (unlikely(!nv->value))
110
- fatal("Cannot allocate name_value.value of size %z", value_len);
110
+ fatal("Cannot allocate name_value.value of size %zu", value_len);
111
112
memcpy(nv->value, value, value_len);
113
}
@@ -215,7 +215,7 @@ void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t val
215
*old = nv->value;
216
217
if(unlikely(!nv->value))
218
- fatal("Cannot allocate value of size %z", value_len);
218
+ fatal("Cannot allocate value of size %zu", value_len);
219
220
memcpy(value, value, value_len);
221
nv->value = value;
src/log.h
+5
-5
@@ -59,10 +59,10 @@ extern int error_log_limit(int reset);
59
#define fatal(args...) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args)
60
61
extern void log_date(FILE *out);
62
-extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
63
-extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
64
-extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... );
65
-extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn));
66
-extern void log_access( const char *fmt, ... );
62
+extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
63
+extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
64
+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)));
65
+extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn, format (printf, 4, 5)));
66
+extern void log_access( const char *fmt, ... ) __attribute__ (( format (printf, 1, 2)));
67
68
#endif /* NETDATA_LOG_H */
src/main.c
+3
-3
@@ -119,17 +119,17 @@ void web_server_threading_selection(void) {
119
else if(!strcmp(s, "fixed"))
120
web_gzip_strategy = Z_FIXED;
121
else {
122
- error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.");
122
+ error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
123
web_gzip_strategy = Z_DEFAULT_STRATEGY;
124
}
125
126
web_gzip_level = (int)config_get_number("global", "web compression level", 3);
127
if(web_gzip_level < 1) {
128
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).");
128
+ error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
129
web_gzip_level = 1;
130
}
131
else if(web_gzip_level > 9) {
132
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).");
132
+ error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
133
web_gzip_level = 9;
134
}
135
#endif /* NETDATA_WITH_ZLIB */
src/plugin_tc.c
+1
-1
@@ -257,7 +257,7 @@ static inline void tc_device_commit(struct tc_device *d)
257
RRDDIM *rd = rrddim_find(st, c->id);
258
259
if(!rd) {
260
- debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s'", st->id, c->id, c->name);
260
+ debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s' (name: '%s')", st->id, c->id, c->name);
261
262
// new class, we have to add it
263
rd = rrddim_add(st, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_INCREMENTAL);
src/plugins_d.c
+2
-2
@@ -423,7 +423,7 @@ void *pluginsd_worker_thread(void *arg)
423
sleep((unsigned int) (cd->update_every * 10));
424
}
425
else {
426
- 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);
426
+ 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);
427
cd->enabled = 0;
428
}
429
}
@@ -439,7 +439,7 @@ void *pluginsd_worker_thread(void *arg)
439
sleep((unsigned int) (cd->update_every * 10));
440
}
441
else {
442
- 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);
442
+ 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);
443
cd->enabled = 0;
444
}
445
}
src/proc_net_stat_synproxy.c
+2
-2
@@ -37,9 +37,9 @@ int do_proc_net_stat_synproxy(int update_every, unsigned long long dt) {
37
if(!ff) return 0; // we return 0, so that we will retry to open it next time
38
39
// make sure we have 3 lines
40
- unsigned long lines = procfile_lines(ff), l;
40
+ size_t lines = procfile_lines(ff), l;
41
if(lines < 2) {
42
- error("/proc/net/stat/synproxy has %d lines, expected no less than 2. Disabling it.", lines);
42
+ error("/proc/net/stat/synproxy has %zu lines, expected no less than 2. Disabling it.", lines);
43
return 1;
44
}
45
src/registry.c
+9
-9
@@ -337,7 +337,7 @@ static inline URL *registry_url_allocate_nolock(const char *url, size_t urllen)
337
338
debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): allocating %zu bytes", url, sizeof(URL) + urllen);
339
URL *u = malloc(sizeof(URL) + urllen);
340
- if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen);
340
+ if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen, url);
341
342
// a simple strcpy() should do the job
343
// but I prefer to be safe, since the caller specified urllen
@@ -782,7 +782,7 @@ int registry_log_load(void) {
782
783
// verify it is valid
784
if (unlikely(len < 85 || s[1] != '\t' || s[10] != '\t' || s[47] != '\t' || s[84] != '\t')) {
785
- error("Registry: log line %u is wrong (len = %zu).", line, len);
785
+ error("Registry: log line %zu is wrong (len = %zu).", line, len);
786
continue;
787
}
788
s[1] = s[10] = s[47] = s[84] = '\0';
@@ -797,7 +797,7 @@ int registry_log_load(void) {
797
char *url = name;
798
while(*url && *url != '\t') url++;
799
if(!*url) {
800
- error("Registry: log line %u does not have a url.", line);
800
+ error("Registry: log line %zu does not have a url.", line);
801
continue;
802
}
803
*url++ = '\0';
@@ -1521,7 +1521,7 @@ static inline size_t registry_load(void) {
1521
switch(*s) {
1522
case 'T': // totals
1523
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')) {
1524
- error("Registry totals line %u is wrong (len = %zu).", line, len);
1524
+ error("Registry totals line %zu is wrong (len = %zu).", line, len);
1525
continue;
1526
}
1527
registry.persons_count = strtoull(&s[2], NULL, 16);
@@ -1536,7 +1536,7 @@ static inline size_t registry_load(void) {
1536
m = NULL;
1537
// verify it is valid
1538
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
1539
- error("Registry person line %u is wrong (len = %zu).", line, len);
1539
+ error("Registry person line %zu is wrong (len = %zu).", line, len);
1540
continue;
1541
}
1542
@@ -1551,7 +1551,7 @@ static inline size_t registry_load(void) {
1551
p = NULL;
1552
// verify it is valid
1553
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
1554
- error("Registry person line %u is wrong (len = %zu).", line, len);
1554
+ error("Registry person line %zu is wrong (len = %zu).", line, len);
1555
continue;
1556
}
1557
@@ -1570,7 +1570,7 @@ static inline size_t registry_load(void) {
1570
1571
// verify it is valid
1572
if(len < 69 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t' || s[68] != '\t') {
1573
- error("Registry person URL line %u is wrong (len = %zu).", line, len);
1573
+ error("Registry person URL line %zu is wrong (len = %zu).", line, len);
1574
continue;
1575
}
1576
@@ -1580,7 +1580,7 @@ static inline size_t registry_load(void) {
1580
char *url = &s[69];
1581
while(*url && *url != '\t') url++;
1582
if(!*url) {
1583
- error("Registry person URL line %u does not have a url.", line);
1583
+ error("Registry person URL line %zu does not have a url.", line);
1584
continue;
1585
}
1586
*url++ = '\0';
@@ -1607,7 +1607,7 @@ static inline size_t registry_load(void) {
1607
1608
// verify it is valid
1609
if(len < 32 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t') {
1610
- error("Registry person URL line %u is wrong (len = %zu).", line, len);
1610
+ error("Registry person URL line %zu is wrong (len = %zu).", line, len);
1611
continue;
1612
}
1613
src/rrd.c
+1
-1
@@ -876,7 +876,7 @@ unsigned long long rrdset_done(RRDSET *st)
876
877
// check if we will re-write the entire data set
878
if(unlikely(usecdiff(&st->last_collected_time, &st->last_updated) > st->update_every * st->entries * 1000000ULL)) {
879
- 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);
879
+ 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);
880
rrdset_reset(st);
881
882
st->usec_since_last_update = st->update_every * 1000000ULL;
src/rrd2json.c
+33
-33
@@ -292,7 +292,7 @@ typedef struct rrdresult {
292
long c; // current line ( -1 ~ n ), ( -1 = none, use rrdr_rows() to get number of rows )
293
294
long group; // how many collected values were grouped for each row
295
- long update_every; // what is the suggested update frequency in seconds
295
+ int update_every; // what is the suggested update frequency in seconds
296
297
calculated_number min;
298
calculated_number max;
@@ -508,10 +508,10 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, uint32_t opti
508
, kq, kq, sq, r->st->name, sq
509
, kq, kq, r->update_every
510
, kq, kq, r->st->update_every
511
- , kq, kq, rrdset_first_entry_t(r->st)
512
- , kq, kq, rrdset_last_entry_t(r->st)
513
- , kq, kq, r->before
514
- , kq, kq, r->after
511
+ , kq, kq, (uint32_t)rrdset_first_entry_t(r->st)
512
+ , kq, kq, (uint32_t)rrdset_last_entry_t(r->st)
513
+ , kq, kq, (uint32_t)r->before
514
+ , kq, kq, (uint32_t)r->after
515
, kq, kq);
516
517
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
606
}
607
608
buffer_sprintf(wb, "],\n"
609
- " %sdimensions%s: %d,\n"
610
- " %spoints%s: %d,\n"
609
+ " %sdimensions%s: %ld,\n"
610
+ " %spoints%s: %ld,\n"
611
" %sformat%s: %s"
612
, kq, kq, i
613
, kq, kq, rows
@@ -697,7 +697,7 @@ static void rrdr2json(RRDR *r, BUFFER *wb, uint32_t options, int datatable)
697
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);
698
snprintfz(normal_annotation, 200, ",{%sv%s:null},{%sv%s:null}", kq, kq, kq, kq);
699
700
- buffer_sprintf(wb, "{\n %scols%s:\n [\n", kq, kq, kq, kq);
700
+ buffer_sprintf(wb, "{\n %scols%s:\n [\n", kq, kq);
701
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);
702
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);
703
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)
1221
return r;
1222
1223
cleanup:
1224
- error("Cannot allocate RRDR memory for %d entries", n);
1224
+ error("Cannot allocate RRDR memory for %ld entries", n);
1225
if(likely(r)) rrdr_free(r);
1226
return NULL;
1227
}
@@ -1298,22 +1298,22 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
1298
1299
#ifdef NETDATA_INTERNAL_CHECKS
1300
if(after_new < first_entry_t) {
1301
- error("after_new %u is too small, minimum %u", after_new, first_entry_t);
1301
+ error("after_new %u is too small, minimum %u", (uint32_t)after_new, (uint32_t)first_entry_t);
1302
}
1303
if(after_new > last_entry_t) {
1304
- error("after_new %u is too big, maximum %u", after_new, last_entry_t);
1304
+ error("after_new %u is too big, maximum %u", (uint32_t)after_new, (uint32_t)last_entry_t);
1305
}
1306
if(before_new < first_entry_t) {
1307
- error("before_new %u is too small, minimum %u", before_new, first_entry_t);
1307
+ error("before_new %u is too small, minimum %u", (uint32_t)before_new, (uint32_t)first_entry_t);
1308
}
1309
if(before_new > last_entry_t) {
1310
- error("before_new %u is too big, maximum %u", before_new, last_entry_t);
1310
+ error("before_new %u is too big, maximum %u", (uint32_t)before_new, (uint32_t)last_entry_t);
1311
}
1312
if(start_at_slot < 0 || start_at_slot >= st->entries) {
1313
- error("start_at_slot is invalid %ld, expected %ld to %ld", start_at_slot, 0, st->entries - 1);
1313
+ error("start_at_slot is invalid %ld, expected 0 to %ld", start_at_slot, st->entries - 1);
1314
}
1315
if(stop_at_slot < 0 || stop_at_slot >= st->entries) {
1316
- error("stop_at_slot is invalid %ld, expected %ld to %ld", stop_at_slot, 0, st->entries - 1);
1316
+ error("stop_at_slot is invalid %ld, expected 0 to %ld", stop_at_slot, st->entries - 1);
1317
}
1318
if(points_new > (before_new - after_new) / group / st->update_every + 1) {
1319
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
1342
RRDR *r = rrdr_create(st, points);
1343
if(!r) {
1344
#ifdef NETDATA_INTERNAL_CHECKS
1345
- error("Cannot create RRDR for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
1345
+ 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);
1346
#endif
1347
return NULL;
1348
}
1349
if(!r->d) {
1350
#ifdef NETDATA_INTERNAL_CHECKS
1351
- error("Returning empty RRDR (no dimensions in RRDSET) for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
1351
+ 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);
1352
#endif
1353
return r;
1354
}
@@ -1365,14 +1365,14 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
1365
// -------------------------------------------------------------------------
1366
// checks for debugging
1367
1368
- 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"
1368
+ 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"
1369
, st->id
1370
- , first_entry_t
1371
- , last_entry_t
1372
- , last_entry_t - first_entry_t
1373
- , after
1374
- , before
1375
- , duration
1370
+ , (uint32_t)first_entry_t
1371
+ , (uint32_t)last_entry_t
1372
+ , (uint32_t)(last_entry_t - first_entry_t)
1373
+ , (uint32_t)after
1374
+ , (uint32_t)before
1375
+ , (uint32_t)duration
1376
, points
1377
, group
1378
);
@@ -1407,13 +1407,13 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
1407
dt = st->update_every,
1408
group_start_t = 0;
1409
1410
- 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"
1410
+ 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"
1411
, st->id
1412
- , after
1412
+ , (uint32_t)after
1413
, stop_at_slot
1414
- , before
1414
+ , (uint32_t)before
1415
, start_at_slot
1416
- , now
1416
+ , (uint32_t)now
1417
, st->current_entry
1418
, st->entries
1419
);
@@ -1915,15 +1915,15 @@ time_t rrd_stats_json(int type, RRDSET *st, BUFFER *wb, long points, long group,
1915
long count = 0, printed = 0, group_count = 0;
1916
last_timestamp = 0;
1917
1918
- 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"
1918
+ 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"
1919
, st->id
1920
- , after
1921
- , before
1920
+ , (uint32_t)after
1921
+ , (uint32_t)before
1922
, points
1923
, group
1924
, st->current_entry
1925
- , rrdset_first_entry_t(st)
1926
- , rrdset_last_entry_t(st)
1925
+ , (uint32_t)rrdset_first_entry_t(st)
1926
+ , (uint32_t)rrdset_last_entry_t(st)
1927
, t
1928
, stop_at_t
1929
);
src/sys_fs_cgroup.c
+1
-1
@@ -262,7 +262,7 @@ void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
262
263
ca->cpu_percpu = malloc(sizeof(unsigned long long) * i);
264
if(!ca->cpu_percpu)
265
- fatal("Cannot allocate memory (%z bytes)", sizeof(unsigned long long) * i);
265
+ fatal("Cannot allocate memory (%zu bytes)", sizeof(unsigned long long) * i);
266
267
ca->cpus = i;
268
}
src/web_buffer.c
+6
-6
@@ -281,11 +281,11 @@ void buffer_date(BUFFER *wb, int year, int month, int day, int hours, int minute
281
buffer_overflow_check(wb);
282
}
283
284
-BUFFER *buffer_create(long size)
284
+BUFFER *buffer_create(size_t size)
285
{
286
BUFFER *b;
287
288
- debug(D_WEB_BUFFER, "Creating new web buffer of size %d.", size);
288
+ debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size);
289
290
b = calloc(1, sizeof(BUFFER));
291
if(!b) {
@@ -295,7 +295,7 @@ BUFFER *buffer_create(long size)
295
296
b->buffer = malloc(size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
297
if(!b->buffer) {
298
- error("Cannot allocate a buffer of size %u.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
298
+ error("Cannot allocate a buffer of size %zu.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
299
free(b);
300
return NULL;
301
}
@@ -312,7 +312,7 @@ void buffer_free(BUFFER *b)
312
{
313
buffer_overflow_check(b);
314
315
- debug(D_WEB_BUFFER, "Freeing web buffer of size %d.", b->size);
315
+ debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size);
316
317
if(b->buffer) free(b->buffer);
318
free(b);
@@ -329,11 +329,11 @@ void buffer_increase(BUFFER *b, size_t free_size_required)
329
size_t increase = free_size_required - left;
330
if(increase < WEB_DATA_LENGTH_INCREASE_STEP) increase = WEB_DATA_LENGTH_INCREASE_STEP;
331
332
- debug(D_WEB_BUFFER, "Increasing data buffer from size %d to %d.", b->size, b->size + increase);
332
+ debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + increase);
333
334
b->buffer = realloc(b->buffer, b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
335
if(!b->buffer)
336
- fatal("Failed to increase data buffer from size %d to %d.",
336
+ fatal("Failed to increase data buffer from size %zu to %zu.",
337
b->size + sizeof(BUFFER_OVERFLOW_EOF) + 2,
338
b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
339
src/web_buffer.h
+3
-3
@@ -57,13 +57,13 @@ extern void buffer_rrd_value(BUFFER *wb, calculated_number value);
57
extern void buffer_date(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
58
extern void buffer_jsdate(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
59
60
-extern BUFFER *buffer_create(long size);
60
+extern BUFFER *buffer_create(size_t size);
61
extern void buffer_free(BUFFER *b);
62
extern void buffer_increase(BUFFER *b, size_t free_size_required);
63
64
-extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...);
64
+extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
65
extern void buffer_vsprintf(BUFFER *wb, const char *fmt, va_list args);
66
-extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...);
66
+extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...) __attribute__ (( format (printf, 2, 3)));
67
68
extern void buffer_char_replace(BUFFER *wb, char from, char to);
69
src/web_client.c
+21
-19
@@ -2050,7 +2050,7 @@ void web_client_process(struct web_client *w) {
2050
buffer_strcat(w->response.header_output, "\r\n");
2051
2052
// sent the HTTP header
2053
- debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %d: '%s'"
2053
+ debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %zu: '%s'"
2054
, w->id
2055
, buffer_strlen(w->response.header_output)
2056
, buffer_tostring(w->response.header_output)
@@ -2063,8 +2063,10 @@ void web_client_process(struct web_client *w) {
2063
if(bytes > 0)
2064
w->stats_sent_bytes += bytes;
2065
2066
- 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,
2067
- buffer_strlen(w->response.header_output), bytes);
2066
+ debug(D_WEB_CLIENT, "%llu: HTTP Header failed to be sent (I sent %zu bytes but the system sent %zd bytes). Closing web client."
2067
+ , w->id
2068
+ , buffer_strlen(w->response.header_output)
2069
+ , bytes);
2070
2071
WEB_CLIENT_IS_DEAD(w);
2072
return;
@@ -2079,16 +2081,16 @@ void web_client_process(struct web_client *w) {
2081
// pretty logging
2082
switch(w->mode) {
2083
case WEB_CLIENT_MODE_OPTIONS:
2082
- debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
2084
+ debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
2085
break;
2086
2087
case WEB_CLIENT_MODE_NORMAL:
2086
- debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
2088
+ debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
2089
break;
2090
2091
case WEB_CLIENT_MODE_FILECOPY:
2092
if(w->response.rlen) {
2091
- debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %d bytes to client.", w->id, w->response.rlen);
2093
+ debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %zu bytes to client.", w->id, w->response.rlen);
2094
w->wait_receive = 1;
2095
2096
/*
@@ -2116,13 +2118,13 @@ void web_client_process(struct web_client *w) {
2118
2119
ssize_t web_client_send_chunk_header(struct web_client *w, size_t len)
2120
{
2119
- debug(D_DEFLATE, "%llu: OPEN CHUNK of %d bytes (hex: %x).", w->id, len, len);
2121
+ debug(D_DEFLATE, "%llu: OPEN CHUNK of %zu bytes (hex: %zx).", w->id, len, len);
2122
char buf[24];
2123
sprintf(buf, "%zX\r\n", len);
2124
2125
ssize_t bytes = send(w->ofd, buf, strlen(buf), 0);
2126
if(bytes > 0) {
2125
- debug(D_DEFLATE, "%llu: Sent chunk header %d bytes.", w->id, bytes);
2127
+ debug(D_DEFLATE, "%llu: Sent chunk header %zd bytes.", w->id, bytes);
2128
w->stats_sent_bytes += bytes;
2129
}
2130
@@ -2144,7 +2146,7 @@ ssize_t web_client_send_chunk_close(struct web_client *w)
2146
2147
ssize_t bytes = send(w->ofd, "\r\n", 2, 0);
2148
if(bytes > 0) {
2147
- debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
2149
+ debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
2150
w->stats_sent_bytes += bytes;
2151
}
2152
@@ -2166,7 +2168,7 @@ ssize_t web_client_send_chunk_finalize(struct web_client *w)
2168
2169
ssize_t bytes = send(w->ofd, "\r\n0\r\n\r\n", 7, 0);
2170
if(bytes > 0) {
2169
- debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
2171
+ debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
2172
w->stats_sent_bytes += bytes;
2173
}
2174
@@ -2190,7 +2192,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
2192
// when using compression,
2193
// w->response.sent is the amount of bytes passed through compression
2194
2193
- 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.",
2195
+ 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.",
2196
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);
2197
2198
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)
2234
if(t < 0) return t;
2235
}
2236
2235
- 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);
2237
+ 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);
2238
2239
// give the compressor all the data not passed through the compressor yet
2240
if(w->response.data->len > w->response.sent) {
@@ -2268,7 +2270,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
2270
// keep track of the bytes passed through the compressor
2271
w->response.sent = w->response.data->len;
2272
2271
- debug(D_DEFLATE, "%llu: Compression produced %d bytes.", w->id, w->response.zhave);
2273
+ debug(D_DEFLATE, "%llu: Compression produced %zu bytes.", w->id, w->response.zhave);
2274
2275
// open a new chunk
2276
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)
2278
t += t2;
2279
}
2280
2279
- debug(D_WEB_CLIENT, "%llu: Sending %d bytes of data (+%d of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
2281
+ debug(D_WEB_CLIENT, "%llu: Sending %zu bytes of data (+%zd of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
2282
2283
len = send(w->ofd, &w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT);
2284
if(len > 0) {
2285
w->stats_sent_bytes += len;
2286
w->response.zsent += len;
2287
len += t;
2286
- debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, len);
2288
+ debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, len);
2289
}
2290
else if(len == 0) {
2291
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).",
2292
w->id, w->response.zhave, w->response.zsent, w->response.zhave - w->response.zsent);
2291
-
2293
+
2294
WEB_CLIENT_IS_DEAD(w);
2295
}
2296
else {
@@ -2338,7 +2340,7 @@ ssize_t web_client_send(struct web_client *w) {
2340
if(likely(bytes > 0)) {
2341
w->stats_sent_bytes += bytes;
2342
w->response.sent += bytes;
2341
- debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, bytes);
2343
+ debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, bytes);
2344
}
2345
else if(likely(bytes == 0)) {
2346
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)
2375
w->response.data->len += bytes;
2376
w->response.data->buffer[w->response.data->len] = '\0';
2377
2376
- debug(D_WEB_CLIENT, "%llu: Received %d bytes.", w->id, bytes);
2378
+ debug(D_WEB_CLIENT, "%llu: Received %zu bytes.", w->id, bytes);
2379
debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]);
2380
2381
if(w->mode == WEB_CLIENT_MODE_FILECOPY) {
@@ -2441,7 +2443,7 @@ void *web_client_main(void *ptr)
2443
break;
2444
}
2445
else if(unlikely(!w->wait_receive && !w->wait_send)) {
2444
- debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.");
2446
+ debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.", w->id);
2447
break;
2448
}
2449
src/web_server.c
+3
-3
@@ -277,7 +277,7 @@ void *socket_listen_main_multi_threaded(void *ptr) {
277
sleep(5);
278
create_listen_socket();
279
if(listen_fd < 0)
280
- fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
280
+ fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
281
282
failures = 0;
283
}
@@ -294,7 +294,7 @@ void *socket_listen_main_multi_threaded(void *ptr) {
294
}
295
296
if(pthread_create(&w->thread, NULL, web_client_main, w) != 0) {
297
- error("%llu: failed to create new thread for web client.");
297
+ error("%llu: failed to create new thread for web client.", w->id);
298
w->obsolete = 1;
299
}
300
else if(pthread_detach(w->thread) != 0) {
@@ -446,7 +446,7 @@ void *socket_listen_main_single_threaded(void *ptr) {
446
447
create_listen_socket();
448
if(listen_fd < 0 || listen_fd >= FD_SETSIZE)
449
- fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
449
+ fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
450
451
FD_ZERO (&ifds);
452
FD_ZERO (&ofds);