@cryptotaxi247 / netdata-1 / commits / daa4ce061

gcc options to check format of snprintfz(), fixes 387

Costa Tsaousis (ktsaou) committed Jun 17, 2016 at 00:51 UTC daa4ce061ebda276704e84ed6815ddcd97148897
2 files changed +3 -3
src/common.h
+1 -1
@@ -29,7 +29,7 @@ extern char *trim(char *s);
29
30 extern char *strncpyz(char *dst, const char *src, size_t n);
31 extern int vsnprintfz(char *dst, size_t n, const char *fmt, va_list args);
32 -extern int snprintfz(char *dst, size_t n, const char *fmt, ...);
32 +extern int snprintfz(char *dst, size_t n, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
33
34 extern void *mymmap(const char *filename, size_t size, int flags, int ksm);
35 extern int savememory(const char *filename, void *mem, size_t size);
src/sys_fs_cgroup.c
+2 -2
@@ -1018,14 +1018,14 @@ void update_cgroup_charts(int update_every) {
1018 st = rrdset_create(type, "cpu_per_core", NULL, "cpu", "cgroup.cpu_per_core", title, "%", 40100, update_every, RRDSET_TYPE_STACKED);
1019
1020 for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
1021 - snprintfz(id, CHART_TITLE_MAX, "cpu%d", i);
1021 + snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
1022 rrddim_add(st, id, NULL, 100, 1000000, RRDDIM_INCREMENTAL);
1023 }
1024 }
1025 else rrdset_next(st);
1026
1027 for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
1028 - snprintfz(id, CHART_TITLE_MAX, "cpu%d", i);
1028 + snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
1029 rrddim_set(st, id, cg->cpuacct_usage.cpu_percpu[i]);
1030 }
1031 rrdset_done(st);