replace strcmp() with strsame() and procfile improvements
Costa Tsaousis (ktsaou) committed
Jan 20, 2017 at 22:59 UTC
655715342478c5da5d43c5a8e619bd214585db4d
46 files changed
+673
-767
src/adaptive_resortable_list.c
+1
-1
@@ -128,7 +128,7 @@ int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, uint32_t hash,
128
129
// find if it already exists in the data
130
for(e = base->head; e ; e = e->next)
131
- if(e->hash == hash && !strcmp(e->name, s))
131
+ if(e->hash == hash && !strsame(e->name, s))
132
break;
133
134
#ifdef NETDATA_INTERNAL_CHECKS
src/adaptive_resortable_list.h
+1
-1
@@ -118,7 +118,7 @@ static inline int arl_check(ARL_BASE *base, const char *keyword, const char *val
118
uint32_t hash = simple_hash(keyword);
119
120
// it should be the first entry (pointed by base->next_keyword)
121
- if(likely(hash == e->hash && !strcmp(keyword, e->name))) {
121
+ if(likely(hash == e->hash && !strsame(keyword, e->name))) {
122
// it is
123
124
#ifdef NETDATA_INTERNAL_CHECKS
src/appconfig.c
+14
-14
@@ -69,7 +69,7 @@ static inline void config_section_unlock(struct config *co) {
69
static int config_value_compare(void* a, void* b) {
70
if(((struct config_value *)a)->hash < ((struct config_value *)b)->hash) return -1;
71
else if(((struct config_value *)a)->hash > ((struct config_value *)b)->hash) return 1;
72
- else return strcmp(((struct config_value *)a)->name, ((struct config_value *)b)->name);
72
+ else return strsame(((struct config_value *)a)->name, ((struct config_value *)b)->name);
73
}
74
75
#define config_value_index_add(co, cv) (struct config_value *)avl_insert_lock(&((co)->values_index), (avl *)(cv))
@@ -90,7 +90,7 @@ static struct config_value *config_value_index_find(struct config *co, const cha
90
static int config_compare(void* a, void* b) {
91
if(((struct config *)a)->hash < ((struct config *)b)->hash) return -1;
92
else if(((struct config *)a)->hash > ((struct config *)b)->hash) return 1;
93
- else return strcmp(((struct config *)a)->name, ((struct config *)b)->name);
93
+ else return strsame(((struct config *)a)->name, ((struct config *)b)->name);
94
}
95
96
avl_tree_lock config_root_index = {
@@ -238,7 +238,7 @@ char *config_get(const char *section, const char *name, const char *default_valu
238
// this is a loaded value from the config file
239
// if it is different that the default, mark it
240
if(!(cv->flags & CONFIG_VALUE_CHECKED)) {
241
- if(strcmp(cv->value, default_value) != 0) cv->flags |= CONFIG_VALUE_CHANGED;
241
+ if(strsame(cv->value, default_value) != 0) cv->flags |= CONFIG_VALUE_CHANGED;
242
cv->flags |= CONFIG_VALUE_CHECKED;
243
}
244
}
@@ -266,7 +266,7 @@ int config_get_boolean(const char *section, const char *name, int value)
266
s = config_get(section, name, s);
267
if(!s) return value;
268
269
- if(!strcmp(s, "yes") || !strcmp(s, "auto") || !strcmp(s, "on demand")) return 1;
269
+ if(!strsame(s, "yes") || !strsame(s, "auto") || !strsame(s, "on demand")) return 1;
270
return 0;
271
}
272
@@ -286,11 +286,11 @@ int config_get_boolean_ondemand(const char *section, const char *name, int value
286
s = config_get(section, name, s);
287
if(!s) return value;
288
289
- if(!strcmp(s, "yes"))
289
+ if(!strsame(s, "yes"))
290
return CONFIG_ONDEMAND_YES;
291
- else if(!strcmp(s, "no"))
291
+ else if(!strsame(s, "no"))
292
return CONFIG_ONDEMAND_NO;
293
- else if(!strcmp(s, "auto") || !strcmp(s, "on demand"))
293
+ else if(!strsame(s, "auto") || !strsame(s, "on demand"))
294
return CONFIG_ONDEMAND_ONDEMAND;
295
296
return value;
@@ -313,7 +313,7 @@ const char *config_set_default(const char *section, const char *name, const char
313
if(cv->flags & CONFIG_VALUE_LOADED)
314
return cv->value;
315
316
- if(strcmp(cv->value, value) != 0) {
316
+ if(strsame(cv->value, value) != 0) {
317
cv->flags |= CONFIG_VALUE_CHANGED;
318
319
freez(cv->value);
@@ -336,7 +336,7 @@ const char *config_set(const char *section, const char *name, const char *value)
336
if(!cv) cv = config_value_create(co, name, value);
337
cv->flags |= CONFIG_VALUE_USED;
338
339
- if(strcmp(cv->value, value) != 0) {
339
+ if(strsame(cv->value, value) != 0) {
340
cv->flags |= CONFIG_VALUE_CHANGED;
341
342
freez(cv->value);
@@ -492,11 +492,11 @@ void generate_config(BUFFER *wb, int only_changed)
492
493
config_global_write_lock();
494
for(co = config_root; co ; co = co->next) {
495
- if(!strcmp(co->name, "global") ||
496
- !strcmp(co->name, "plugins") ||
497
- !strcmp(co->name, "registry") ||
498
- !strcmp(co->name, "health") ||
499
- !strcmp(co->name, "backend"))
495
+ if(!strsame(co->name, "global") ||
496
+ !strsame(co->name, "plugins") ||
497
+ !strsame(co->name, "registry") ||
498
+ !strsame(co->name, "health") ||
499
+ !strsame(co->name, "backend"))
500
pri = 0;
501
else if(!strncmp(co->name, "plugin:", 7)) pri = 1;
502
else pri = 2;
src/apps_plugin.c
+21
-21
@@ -218,7 +218,7 @@ static struct target *get_apps_groups_target(const char *id, struct target *targ
218
name++;
219
}
220
for(target = apps_groups_root_target ; target ; target = target->next) {
221
- if(!target->target && strcmp(name, target->name) == 0)
221
+ if(!target->target && strsame(name, target->name) == 0)
222
break;
223
}
224
if(unlikely(debug)) {
@@ -947,7 +947,7 @@ int file_descriptor_compare(void* a, void* b) {
947
return 1;
948
949
else
950
- return strcmp(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
950
+ return strsame(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
951
}
952
953
int file_descriptor_iterator(avl *a) { if(a) {}; return 0; }
@@ -1122,11 +1122,11 @@ static inline int file_descriptor_find_or_add(const char *name)
1122
if(name[0] == '/') type = FILETYPE_FILE;
1123
else if(strncmp(name, "pipe:", 5) == 0) type = FILETYPE_PIPE;
1124
else if(strncmp(name, "socket:", 7) == 0) type = FILETYPE_SOCKET;
1125
- else if(strcmp(name, "anon_inode:inotify") == 0 || strcmp(name, "inotify") == 0) type = FILETYPE_INOTIFY;
1126
- else if(strcmp(name, "anon_inode:[eventfd]") == 0) type = FILETYPE_EVENTFD;
1127
- else if(strcmp(name, "anon_inode:[eventpoll]") == 0) type = FILETYPE_EVENTPOLL;
1128
- else if(strcmp(name, "anon_inode:[timerfd]") == 0) type = FILETYPE_TIMERFD;
1129
- else if(strcmp(name, "anon_inode:[signalfd]") == 0) type = FILETYPE_SIGNALFD;
1125
+ else if(strsame(name, "anon_inode:inotify") == 0 || strsame(name, "inotify") == 0) type = FILETYPE_INOTIFY;
1126
+ else if(strsame(name, "anon_inode:[eventfd]") == 0) type = FILETYPE_EVENTFD;
1127
+ else if(strsame(name, "anon_inode:[eventpoll]") == 0) type = FILETYPE_EVENTPOLL;
1128
+ else if(strsame(name, "anon_inode:[timerfd]") == 0) type = FILETYPE_TIMERFD;
1129
+ else if(strsame(name, "anon_inode:[signalfd]") == 0) type = FILETYPE_SIGNALFD;
1130
else if(strncmp(name, "anon_inode:", 11) == 0) {
1131
if(unlikely(debug))
1132
fprintf(stderr, "apps.plugin: FIXME: unknown anonymous inode: %s\n", name);
@@ -1173,7 +1173,7 @@ static inline int read_pid_file_descriptors(struct pid_stat *p) {
1173
p->fds[c] = -p->fds[c];
1174
1175
while((de = readdir(fds))) {
1176
- if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
1176
+ if(strsame(de->d_name, ".") == 0 || strsame(de->d_name, "..") == 0)
1177
continue;
1178
1179
// check if the fds array is small
@@ -1647,9 +1647,9 @@ static inline int collect_data_for_pid(pid_t pid) {
1647
// 2. the target has the prefix
1648
// 3. the target has the suffix
1649
// 4. the target is something inside cmdline
1650
- if( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strcmp(w->compare, p->comm))
1650
+ if( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strsame(w->compare, p->comm))
1651
|| (w->starts_with && !w->ends_with && !strncmp(w->compare, p->comm, w->comparelen))
1652
- || (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strcmp(w->compare, &p->comm[pclen - w->comparelen]))
1652
+ || (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strsame(w->compare, &p->comm[pclen - w->comparelen]))
1653
|| (proc_pid_cmdline_is_needed && w->starts_with && w->ends_with && strstr(p->cmdline, w->compare))
1654
) {
1655
if(w->target) p->target = w->target;
@@ -2684,58 +2684,58 @@ static void parse_args(int argc, char **argv)
2684
}
2685
}
2686
2687
- if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
2687
+ if(strsame("version", argv[i]) == 0 || strsame("-v", argv[i]) == 0) {
2688
printf("apps.plugin %s\n", VERSION);
2689
exit(0);
2690
}
2691
2692
- if(strcmp("debug", argv[i]) == 0) {
2692
+ if(strsame("debug", argv[i]) == 0) {
2693
debug = 1;
2694
// debug_flags = 0xffffffff;
2695
continue;
2696
}
2697
2698
- if(strcmp("no-childs", argv[i]) == 0 || strcmp("without-childs", argv[i]) == 0) {
2698
+ if(strsame("no-childs", argv[i]) == 0 || strsame("without-childs", argv[i]) == 0) {
2699
include_exited_childs = 0;
2700
continue;
2701
}
2702
2703
- if(strcmp("with-childs", argv[i]) == 0) {
2703
+ if(strsame("with-childs", argv[i]) == 0) {
2704
include_exited_childs = 1;
2705
continue;
2706
}
2707
2708
- if(strcmp("with-guest", argv[i]) == 0) {
2708
+ if(strsame("with-guest", argv[i]) == 0) {
2709
enable_guest_charts = 1;
2710
continue;
2711
}
2712
2713
- if(strcmp("no-guest", argv[i]) == 0 || strcmp("without-guest", argv[i]) == 0) {
2713
+ if(strsame("no-guest", argv[i]) == 0 || strsame("without-guest", argv[i]) == 0) {
2714
enable_guest_charts = 0;
2715
continue;
2716
}
2717
2718
- if(strcmp("with-files", argv[i]) == 0) {
2718
+ if(strsame("with-files", argv[i]) == 0) {
2719
enable_file_charts = 1;
2720
continue;
2721
}
2722
2723
- if(strcmp("no-files", argv[i]) == 0 || strcmp("without-files", argv[i]) == 0) {
2723
+ if(strsame("no-files", argv[i]) == 0 || strsame("without-files", argv[i]) == 0) {
2724
enable_file_charts = 0;
2725
continue;
2726
}
2727
2728
- if(strcmp("no-users", argv[i]) == 0 || strcmp("without-users", argv[i]) == 0) {
2728
+ if(strsame("no-users", argv[i]) == 0 || strsame("without-users", argv[i]) == 0) {
2729
enable_users_charts = 0;
2730
continue;
2731
}
2732
2733
- if(strcmp("no-groups", argv[i]) == 0 || strcmp("without-groups", argv[i]) == 0) {
2733
+ if(strsame("no-groups", argv[i]) == 0 || strsame("without-groups", argv[i]) == 0) {
2734
enable_groups_charts = 0;
2735
continue;
2736
}
2737
2738
- if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
2738
+ if(strsame("-h", argv[i]) == 0 || strsame("--help", argv[i]) == 0) {
2739
fprintf(stderr,
2740
"apps.plugin %s\n"
2741
"(C) 2016 Costa Tsaousis"
src/backends.c
+5
-5
@@ -169,13 +169,13 @@ void *backends_main(void *ptr) {
169
if(!enabled || frequency < 1)
170
goto cleanup;
171
172
- if(!strcmp(source, "as collected")) {
172
+ if(!strsame(source, "as collected")) {
173
options = BACKEND_SOURCE_DATA_AS_COLLECTED;
174
}
175
- else if(!strcmp(source, "average")) {
175
+ else if(!strsame(source, "average")) {
176
options = BACKEND_SOURCE_DATA_AVERAGE;
177
}
178
- else if(!strcmp(source, "sum") || !strcmp(source, "volume")) {
178
+ else if(!strsame(source, "sum") || !strsame(source, "volume")) {
179
options = BACKEND_SOURCE_DATA_SUM;
180
}
181
else {
@@ -183,7 +183,7 @@ void *backends_main(void *ptr) {
183
goto cleanup;
184
}
185
186
- if(!strcmp(type, "graphite") || !strcmp(type, "graphite:plaintext")) {
186
+ if(!strsame(type, "graphite") || !strsame(type, "graphite:plaintext")) {
187
default_port = 2003;
188
if(options == BACKEND_SOURCE_DATA_AS_COLLECTED)
189
backend_request_formatter = format_dimension_collected_graphite_plaintext;
@@ -192,7 +192,7 @@ void *backends_main(void *ptr) {
192
193
backend_response_checker = process_graphite_response;
194
}
195
- else if(!strcmp(type, "opentsdb") || !strcmp(type, "opentsdb:telnet")) {
195
+ else if(!strsame(type, "opentsdb") || !strsame(type, "opentsdb:telnet")) {
196
default_port = 4242;
197
if(options == BACKEND_SOURCE_DATA_AS_COLLECTED)
198
backend_request_formatter = format_dimension_collected_opentsdb_telnet;
src/dictionary.c
+1
-1
@@ -56,7 +56,7 @@ static inline void dictionary_unlock(DICTIONARY *dict) {
56
static int name_value_compare(void* a, void* b) {
57
if(((NAME_VALUE *)a)->hash < ((NAME_VALUE *)b)->hash) return -1;
58
else if(((NAME_VALUE *)a)->hash > ((NAME_VALUE *)b)->hash) return 1;
59
- else return strcmp(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
59
+ else return strsame(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
60
}
61
62
static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *dict, const char *name, uint32_t hash) {
src/eval.c
+11
-11
@@ -77,7 +77,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
77
critical_hash = simple_hash("CRITICAL");
78
}
79
80
- if(unlikely(v->hash == this_hash && !strcmp(v->name, "this"))) {
80
+ if(unlikely(v->hash == this_hash && !strsame(v->name, "this"))) {
81
n = (exp->this)?*exp->this:NAN;
82
buffer_strcat(exp->error_msg, "[ $this = ");
83
print_parsed_as_constant(exp->error_msg, n);
@@ -85,7 +85,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
85
return n;
86
}
87
88
- if(unlikely(v->hash == after_hash && !strcmp(v->name, "after"))) {
88
+ if(unlikely(v->hash == after_hash && !strsame(v->name, "after"))) {
89
n = (exp->after && *exp->after)?*exp->after:NAN;
90
buffer_strcat(exp->error_msg, "[ $after = ");
91
print_parsed_as_constant(exp->error_msg, n);
@@ -93,7 +93,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
93
return n;
94
}
95
96
- if(unlikely(v->hash == before_hash && !strcmp(v->name, "before"))) {
96
+ if(unlikely(v->hash == before_hash && !strsame(v->name, "before"))) {
97
n = (exp->before && *exp->before)?*exp->before:NAN;
98
buffer_strcat(exp->error_msg, "[ $before = ");
99
print_parsed_as_constant(exp->error_msg, n);
@@ -101,7 +101,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
101
return n;
102
}
103
104
- if(unlikely(v->hash == now_hash && !strcmp(v->name, "now"))) {
104
+ if(unlikely(v->hash == now_hash && !strsame(v->name, "now"))) {
105
n = now_realtime_sec();
106
buffer_strcat(exp->error_msg, "[ $now = ");
107
print_parsed_as_constant(exp->error_msg, n);
@@ -109,7 +109,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
109
return n;
110
}
111
112
- if(unlikely(v->hash == status_hash && !strcmp(v->name, "status"))) {
112
+ if(unlikely(v->hash == status_hash && !strsame(v->name, "status"))) {
113
n = (exp->status)?*exp->status:RRDCALC_STATUS_UNINITIALIZED;
114
buffer_strcat(exp->error_msg, "[ $status = ");
115
print_parsed_as_constant(exp->error_msg, n);
@@ -117,7 +117,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
117
return n;
118
}
119
120
- if(unlikely(v->hash == removed_hash && !strcmp(v->name, "REMOVED"))) {
120
+ if(unlikely(v->hash == removed_hash && !strsame(v->name, "REMOVED"))) {
121
n = RRDCALC_STATUS_REMOVED;
122
buffer_strcat(exp->error_msg, "[ $REMOVED = ");
123
print_parsed_as_constant(exp->error_msg, n);
@@ -125,7 +125,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
125
return n;
126
}
127
128
- if(unlikely(v->hash == uninitialized_hash && !strcmp(v->name, "UNINITIALIZED"))) {
128
+ if(unlikely(v->hash == uninitialized_hash && !strsame(v->name, "UNINITIALIZED"))) {
129
n = RRDCALC_STATUS_UNINITIALIZED;
130
buffer_strcat(exp->error_msg, "[ $UNINITIALIZED = ");
131
print_parsed_as_constant(exp->error_msg, n);
@@ -133,7 +133,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
133
return n;
134
}
135
136
- if(unlikely(v->hash == undefined_hash && !strcmp(v->name, "UNDEFINED"))) {
136
+ if(unlikely(v->hash == undefined_hash && !strsame(v->name, "UNDEFINED"))) {
137
n = RRDCALC_STATUS_UNDEFINED;
138
buffer_strcat(exp->error_msg, "[ $UNDEFINED = ");
139
print_parsed_as_constant(exp->error_msg, n);
@@ -141,7 +141,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
141
return n;
142
}
143
144
- if(unlikely(v->hash == clear_hash && !strcmp(v->name, "CLEAR"))) {
144
+ if(unlikely(v->hash == clear_hash && !strsame(v->name, "CLEAR"))) {
145
n = RRDCALC_STATUS_CLEAR;
146
buffer_strcat(exp->error_msg, "[ $CLEAR = ");
147
print_parsed_as_constant(exp->error_msg, n);
@@ -149,7 +149,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
149
return n;
150
}
151
152
- if(unlikely(v->hash == warning_hash && !strcmp(v->name, "WARNING"))) {
152
+ if(unlikely(v->hash == warning_hash && !strsame(v->name, "WARNING"))) {
153
n = RRDCALC_STATUS_WARNING;
154
buffer_strcat(exp->error_msg, "[ $WARNING = ");
155
print_parsed_as_constant(exp->error_msg, n);
@@ -157,7 +157,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
157
return n;
158
}
159
160
- if(unlikely(v->hash == critical_hash && !strcmp(v->name, "CRITICAL"))) {
160
+ if(unlikely(v->hash == critical_hash && !strsame(v->name, "CRITICAL"))) {
161
n = RRDCALC_STATUS_CRITICAL;
162
buffer_strcat(exp->error_msg, "[ $CRITICAL = ");
163
print_parsed_as_constant(exp->error_msg, n);
src/freebsd_sysctl.c
+5
-5
@@ -2127,11 +2127,11 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
2127
if (mntbuf[i].f_flags == MNT_RDONLY ||
2128
mntbuf[i].f_blocks == 0 ||
2129
// taken from gnulib/mountlist.c and shortened to FreeBSD related fstypes
2130
- strcmp(mntbuf[i].f_fstypename, "autofs") == 0 ||
2131
- strcmp(mntbuf[i].f_fstypename, "procfs") == 0 ||
2132
- strcmp(mntbuf[i].f_fstypename, "subfs") == 0 ||
2133
- strcmp(mntbuf[i].f_fstypename, "devfs") == 0 ||
2134
- strcmp(mntbuf[i].f_fstypename, "none") == 0)
2130
+ strsame(mntbuf[i].f_fstypename, "autofs") == 0 ||
2131
+ strsame(mntbuf[i].f_fstypename, "procfs") == 0 ||
2132
+ strsame(mntbuf[i].f_fstypename, "subfs") == 0 ||
2133
+ strsame(mntbuf[i].f_fstypename, "devfs") == 0 ||
2134
+ strsame(mntbuf[i].f_fstypename, "none") == 0)
2135
continue;
2136
2137
// --------------------------------------------------------------------------
src/health.c
+20
-20
@@ -232,7 +232,7 @@ static inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char
232
}
233
234
// check for a possible host missmatch
235
- //if(strcmp(pointers[1], host->hostname))
235
+ //if(strsame(pointers[1], host->hostname))
236
// error("Health: line %zu of file '%s' provides an alarm for host '%s' but this is named '%s'.", line, filename, pointers[1], host->hostname);
237
238
ae->unique_id = unique_id;
@@ -453,7 +453,7 @@ static inline int rrdvar_fix_name(char *variable) {
453
int rrdvar_compare(void* a, void* b) {
454
if(((RRDVAR *)a)->hash < ((RRDVAR *)b)->hash) return -1;
455
else if(((RRDVAR *)a)->hash > ((RRDVAR *)b)->hash) return 1;
456
- else return strcmp(((RRDVAR *)a)->name, ((RRDVAR *)b)->name);
456
+ else return strsame(((RRDVAR *)a)->name, ((RRDVAR *)b)->name);
457
}
458
459
static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
@@ -1100,8 +1100,8 @@ static void rrdsetcalc_link(RRDSET *st, RRDCALC *rc) {
1100
}
1101
1102
static inline int rrdcalc_is_matching_this_rrdset(RRDCALC *rc, RRDSET *st) {
1103
- if( (rc->hash_chart == st->hash && !strcmp(rc->chart, st->id)) ||
1104
- (rc->hash_chart == st->hash_name && !strcmp(rc->chart, st->name)))
1103
+ if( (rc->hash_chart == st->hash && !strsame(rc->chart, st->id)) ||
1104
+ (rc->hash_chart == st->hash_name && !strsame(rc->chart, st->name)))
1105
return 1;
1106
1107
return 0;
@@ -1176,7 +1176,7 @@ RRDCALC *rrdcalc_find(RRDSET *st, const char *name) {
1176
uint32_t hash = simple_hash(name);
1177
1178
for( rc = st->alarms; rc ; rc = rc->rrdset_next ) {
1179
- if(unlikely(rc->hash == hash && !strcmp(rc->name, name)))
1179
+ if(unlikely(rc->hash == hash && !strsame(rc->name, name)))
1180
return rc;
1181
}
1182
@@ -1196,7 +1196,7 @@ static inline int rrdcalc_exists(RRDHOST *host, const char *chart, const char *n
1196
1197
// make sure it does not already exist
1198
for(rc = host->alarms; rc ; rc = rc->next) {
1199
- if (unlikely(rc->chart && rc->hash == hash_name && rc->hash_chart == hash_chart && !strcmp(name, rc->name) && !strcmp(chart, rc->chart))) {
1199
+ if (unlikely(rc->chart && rc->hash == hash_name && rc->hash_chart == hash_chart && !strsame(name, rc->name) && !strsame(chart, rc->chart))) {
1200
debug(D_HEALTH, "Health alarm '%s.%s' already exists in host '%s'.", chart, name, host->hostname);
1201
error("Health alarm '%s.%s' already exists in host '%s'.", chart, name, host->hostname);
1202
return 1;
@@ -1214,7 +1214,7 @@ static inline uint32_t rrdcalc_get_unique_id(RRDHOST *host, const char *chart, c
1214
// re-use old IDs, by looking them up in the alarm log
1215
ALARM_ENTRY *ae;
1216
for(ae = host->health_log.alarms; ae ;ae = ae->next) {
1217
- if(unlikely(ae->hash_name == hash_name && ae->hash_chart == hash_chart && !strcmp(name, ae->name) && !strcmp(chart, ae->chart))) {
1217
+ if(unlikely(ae->hash_name == hash_name && ae->hash_chart == hash_chart && !strsame(name, ae->name) && !strsame(chart, ae->chart))) {
1218
if(next_event_id) *next_event_id = ae->alarm_event_id + 1;
1219
return ae->alarm_id;
1220
}
@@ -1400,7 +1400,7 @@ void rrdcalctemplate_link_matching(RRDSET *st) {
1400
RRDCALCTEMPLATE *rt;
1401
1402
for(rt = st->rrdhost->templates; rt ; rt = rt->next) {
1403
- if(rt->hash_context == st->hash_context && !strcmp(rt->context, st->context)
1403
+ if(rt->hash_context == st->hash_context && !strsame(rt->context, st->context)
1404
&& (!rt->family_pattern || simple_pattern_matches(rt->family_pattern, st->family))) {
1405
RRDCALC *rc = rrdcalc_create(st->rrdhost, rt, st->id);
1406
if(unlikely(!rc))
@@ -1540,7 +1540,7 @@ static inline int rrdcalctemplate_add_template_from_config(RRDHOST *host, RRDCAL
1540
1541
RRDCALCTEMPLATE *t, *last = NULL;
1542
for (t = host->templates; t ; last = t, t = t->next) {
1543
- if(unlikely(t->hash_name == rt->hash_name && !strcmp(t->name, rt->name))) {
1543
+ if(unlikely(t->hash_name == rt->hash_name && !strsame(t->name, rt->name))) {
1544
error("Health configuration template '%s' already exists for host '%s'.", rt->name, host->hostname);
1545
return 0;
1546
}
@@ -1955,7 +1955,7 @@ int health_readfile(const char *path, const char *filename) {
1955
else if(rc) {
1956
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
1957
if(rc->chart) {
1958
- if(strcmp(rc->chart, value))
1958
+ if(strsame(rc->chart, value))
1959
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1960
line, path, filename, rc->name, key, rc->chart, value, value);
1961
@@ -2019,7 +2019,7 @@ int health_readfile(const char *path, const char *filename) {
2019
}
2020
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
2021
if(rc->exec) {
2022
- if(strcmp(rc->exec, value))
2022
+ if(strsame(rc->exec, value))
2023
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2024
line, path, filename, rc->name, key, rc->exec, value, value);
2025
@@ -2029,7 +2029,7 @@ int health_readfile(const char *path, const char *filename) {
2029
}
2030
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
2031
if(rc->recipient) {
2032
- if(strcmp(rc->recipient, value))
2032
+ if(strsame(rc->recipient, value))
2033
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2034
line, path, filename, rc->name, key, rc->recipient, value, value);
2035
@@ -2039,7 +2039,7 @@ int health_readfile(const char *path, const char *filename) {
2039
}
2040
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
2041
if(rc->units) {
2042
- if(strcmp(rc->units, value))
2042
+ if(strsame(rc->units, value))
2043
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2044
line, path, filename, rc->name, key, rc->units, value, value);
2045
@@ -2050,7 +2050,7 @@ int health_readfile(const char *path, const char *filename) {
2050
}
2051
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
2052
if(rc->info) {
2053
- if(strcmp(rc->info, value))
2053
+ if(strsame(rc->info, value))
2054
error("Health configuration at line %zu of file '%s/%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2055
line, path, filename, rc->name, key, rc->info, value, value);
2056
@@ -2070,7 +2070,7 @@ int health_readfile(const char *path, const char *filename) {
2070
else if(rt) {
2071
if(hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
2072
if(rt->context) {
2073
- if(strcmp(rt->context, value))
2073
+ if(strsame(rt->context, value))
2074
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2075
line, path, filename, rt->name, key, rt->context, value, value);
2076
@@ -2140,7 +2140,7 @@ int health_readfile(const char *path, const char *filename) {
2140
}
2141
else if(hash == hash_exec && !strcasecmp(key, HEALTH_EXEC_KEY)) {
2142
if(rt->exec) {
2143
- if(strcmp(rt->exec, value))
2143
+ if(strsame(rt->exec, value))
2144
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2145
line, path, filename, rt->name, key, rt->exec, value, value);
2146
@@ -2150,7 +2150,7 @@ int health_readfile(const char *path, const char *filename) {
2150
}
2151
else if(hash == hash_recipient && !strcasecmp(key, HEALTH_RECIPIENT_KEY)) {
2152
if(rt->recipient) {
2153
- if(strcmp(rt->recipient, value))
2153
+ if(strsame(rt->recipient, value))
2154
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2155
line, path, filename, rt->name, key, rt->recipient, value, value);
2156
@@ -2160,7 +2160,7 @@ int health_readfile(const char *path, const char *filename) {
2160
}
2161
else if(hash == hash_units && !strcasecmp(key, HEALTH_UNITS_KEY)) {
2162
if(rt->units) {
2163
- if(strcmp(rt->units, value))
2163
+ if(strsame(rt->units, value))
2164
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2165
line, path, filename, rt->name, key, rt->units, value, value);
2166
@@ -2171,7 +2171,7 @@ int health_readfile(const char *path, const char *filename) {
2171
}
2172
else if(hash == hash_info && !strcasecmp(key, HEALTH_INFO_KEY)) {
2173
if(rt->info) {
2174
- if(strcmp(rt->info, value))
2174
+ if(strsame(rt->info, value))
2175
error("Health configuration at line %zu of file '%s/%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
2176
line, path, filename, rt->name, key, rt->info, value, value);
2177
@@ -2239,7 +2239,7 @@ void health_readdir(const char *path) {
2239
}
2240
2241
else if((de->d_type == DT_LNK || de->d_type == DT_REG || de->d_type == DT_UNKNOWN) &&
2242
- len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) {
2242
+ len > 5 && !strsame(&de->d_name[len - 5], ".conf")) {
2243
health_readfile(path, de->d_name);
2244
}
2245
src/inlined.h
+6
@@ -77,6 +77,12 @@ static inline unsigned long long str2ull(const char *s) {
77
return n;
78
}
79
80
+static inline int strsame(register const char *a, register const char *b) {
81
+ if(unlikely(a == b)) return 0;
82
+ while(*a && *a == *b) { a++; b++; }
83
+ return *a - *b;
84
+}
85
+
86
static inline int read_single_number_file(const char *filename, unsigned long long *result) {
87
char buffer[30 + 1];
88
src/log.c
+5
-5
@@ -26,10 +26,10 @@ void syslog_init(void) {
26
int open_log_file(int fd, FILE **fp, const char *filename, int *enabled_syslog) {
27
int f;
28
29
- if(!filename || !*filename || !strcmp(filename, "none"))
29
+ if(!filename || !*filename || !strsame(filename, "none"))
30
filename = "/dev/null";
31
32
- if(!strcmp(filename, "syslog")) {
32
+ if(!strsame(filename, "syslog")) {
33
filename = "/dev/null";
34
syslog_init();
35
if(enabled_syslog) *enabled_syslog = 1;
@@ -38,15 +38,15 @@ int open_log_file(int fd, FILE **fp, const char *filename, int *enabled_syslog)
38
39
// don't do anything if the user is willing
40
// to have the standard one
41
- if(!strcmp(filename, "system")) {
41
+ if(!strsame(filename, "system")) {
42
if(fd != -1) return fd;
43
filename = "stdout";
44
}
45
46
- if(!strcmp(filename, "stdout"))
46
+ if(!strsame(filename, "stdout"))
47
f = STDOUT_FILENO;
48
49
- else if(!strcmp(filename, "stderr"))
49
+ else if(!strsame(filename, "stderr"))
50
f = STDERR_FILENO;
51
52
else {
src/macos_fw.c
+5
-5
@@ -330,11 +330,11 @@ int do_macos_iokit(int update_every, usec_t dt) {
330
if (mntbuf[i].f_flags == MNT_RDONLY ||
331
mntbuf[i].f_blocks == 0 ||
332
// taken from gnulib/mountlist.c and shortened to FreeBSD related fstypes
333
- strcmp(mntbuf[i].f_fstypename, "autofs") == 0 ||
334
- strcmp(mntbuf[i].f_fstypename, "procfs") == 0 ||
335
- strcmp(mntbuf[i].f_fstypename, "subfs") == 0 ||
336
- strcmp(mntbuf[i].f_fstypename, "devfs") == 0 ||
337
- strcmp(mntbuf[i].f_fstypename, "none") == 0)
333
+ strsame(mntbuf[i].f_fstypename, "autofs") == 0 ||
334
+ strsame(mntbuf[i].f_fstypename, "procfs") == 0 ||
335
+ strsame(mntbuf[i].f_fstypename, "subfs") == 0 ||
336
+ strsame(mntbuf[i].f_fstypename, "devfs") == 0 ||
337
+ strsame(mntbuf[i].f_fstypename, "none") == 0)
338
continue;
339
340
// --------------------------------------------------------------------------
src/main.c
+11
-11
@@ -77,15 +77,15 @@ void web_server_threading_selection(void) {
77
web_enable_gzip = config_get_boolean("global", "enable web responses gzip compression", web_enable_gzip);
78
79
char *s = config_get("global", "web compression strategy", "default");
80
- if(!strcmp(s, "default"))
80
+ if(!strsame(s, "default"))
81
web_gzip_strategy = Z_DEFAULT_STRATEGY;
82
- else if(!strcmp(s, "filtered"))
82
+ else if(!strsame(s, "filtered"))
83
web_gzip_strategy = Z_FILTERED;
84
- else if(!strcmp(s, "huffman only"))
84
+ else if(!strsame(s, "huffman only"))
85
web_gzip_strategy = Z_HUFFMAN_ONLY;
86
- else if(!strcmp(s, "rle"))
86
+ else if(!strsame(s, "rle"))
87
web_gzip_strategy = Z_RLE;
88
- else if(!strcmp(s, "fixed"))
88
+ else if(!strsame(s, "fixed"))
89
web_gzip_strategy = Z_FIXED;
90
else {
91
error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
@@ -351,22 +351,22 @@ int main(int argc, char **argv)
351
{
352
i = 1;
353
while(i < argc) {
354
- if(strcmp(argv[i], "-pidfile") == 0 && (i+1) < argc) {
354
+ if(strsame(argv[i], "-pidfile") == 0 && (i+1) < argc) {
355
strncpyz(pidfile, argv[i+1], FILENAME_MAX);
356
fprintf(stderr, "%s: deprecated option -- %s -- please use -P instead.\n", argv[0], argv[i]);
357
remove_option(i, &argc, argv);
358
}
359
- else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(argv[i], "-nd") == 0) {
359
+ else if(strsame(argv[i], "-nodaemon") == 0 || strsame(argv[i], "-nd") == 0) {
360
dont_fork = 1;
361
fprintf(stderr, "%s: deprecated option -- %s -- please use -D instead.\n ", argv[0], argv[i]);
362
remove_option(i, &argc, argv);
363
}
364
- else if(strcmp(argv[i], "-ch") == 0 && (i+1) < argc) {
364
+ else if(strsame(argv[i], "-ch") == 0 && (i+1) < argc) {
365
config_set("global", "host access prefix", argv[i+1]);
366
fprintf(stderr, "%s: deprecated option -- %s -- please use -s instead.\n", argv[0], argv[i]);
367
remove_option(i, &argc, argv);
368
}
369
- else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) {
369
+ else if(strsame(argv[i], "-l") == 0 && (i+1) < argc) {
370
config_set("global", "history", argv[i+1]);
371
fprintf(stderr, "%s: deprecated option -- %s -- This option will be removed with V2.*.\n", argv[0], argv[i]);
372
remove_option(i, &argc, argv);
@@ -443,14 +443,14 @@ int main(int argc, char **argv)
443
{
444
char* stacksize_string = "stacksize=";
445
char* debug_flags_string = "debug_flags=";
446
- if(strcmp(optarg, "unittest") == 0) {
446
+ if(strsame(optarg, "unittest") == 0) {
447
rrd_update_every = 1;
448
if(run_all_mockup_tests()) exit(1);
449
if(unit_test_storage()) exit(1);
450
fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
451
exit(0);
452
}
453
- else if(strcmp(optarg, "simple-pattern") == 0) {
453
+ else if(strsame(optarg, "simple-pattern") == 0) {
454
if(optind + 2 > argc) {
455
fprintf(stderr, "%s", "\nUSAGE: -W simple-pattern 'pattern' 'string'\n\n"
456
" Checks if 'pattern' matches the given 'string'.\n"
src/plugin_tc.c
+28
-28
@@ -92,7 +92,7 @@ struct tc_device *tc_device_root = NULL;
92
static int tc_device_compare(void* a, void* b) {
93
if(((struct tc_device *)a)->hash < ((struct tc_device *)b)->hash) return -1;
94
else if(((struct tc_device *)a)->hash > ((struct tc_device *)b)->hash) return 1;
95
- else return strcmp(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
95
+ else return strsame(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
96
}
97
98
avl_tree tc_device_root_index = {
@@ -118,7 +118,7 @@ static inline struct tc_device *tc_device_index_find(const char *id, uint32_t ha
118
static int tc_class_compare(void* a, void* b) {
119
if(((struct tc_class *)a)->hash < ((struct tc_class *)b)->hash) return -1;
120
else if(((struct tc_class *)a)->hash > ((struct tc_class *)b)->hash) return 1;
121
- else return strcmp(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
121
+ else return strsame(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
122
}
123
124
#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl *)(rd))
@@ -216,8 +216,8 @@ static inline void tc_device_commit(struct tc_device *d) {
216
if(unlikely(c == x)) continue;
217
218
if(x->parentid && (
219
- ( c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
220
- (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0))) {
219
+ ( c->hash == x->parent_hash && strsame(c->id, x->parentid) == 0) ||
220
+ (c->leafid && c->leaf_hash == x->parent_hash && strsame(c->leafid, x->parentid) == 0))) {
221
// debug(D_TC_LOOP, "TC: In device '%s', class '%s' (leafid: '%s') has as leaf class '%s' (parentid: '%s').", d->name?d->name:d->id, c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->name?x->name:x->id, x->parentid?x->parentid:x->id);
222
c->isleaf = 0;
223
x->hasparent = 1;
@@ -309,7 +309,7 @@ static inline void tc_device_commit(struct tc_device *d) {
309
debug(D_TC_LOOP, "TC: Updating chart for device '%s'", d->name?d->name:d->id);
310
rrdset_next(d->st_bytes);
311
312
- if(unlikely(d->name_updated && d->name && strcmp(d->id, d->name) != 0)) {
312
+ if(unlikely(d->name_updated && d->name && strsame(d->id, d->name) != 0)) {
313
rrdset_set_name(d->st_bytes, d->name);
314
d->name_updated = 0;
315
}
@@ -338,7 +338,7 @@ static inline void tc_device_commit(struct tc_device *d) {
338
rrddim_set_by_pointer(d->st_bytes, c->rd_bytes, c->bytes);
339
340
// if it has a name, different to the id
341
- if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
341
+ if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
342
// update the rrd dimension with the new name
343
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_bytes->id, c->rd_bytes->id, c->name);
344
rrddim_set_name(d->st_bytes, c->rd_bytes, c->name);
@@ -392,7 +392,7 @@ static inline void tc_device_commit(struct tc_device *d) {
392
rrddim_set_by_pointer(d->st_packets, c->rd_packets, c->packets);
393
394
// if it has a name, different to the id
395
- if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
395
+ if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
396
// update the rrd dimension with the new name
397
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_packets->id, c->rd_packets->id, c->name);
398
rrddim_set_name(d->st_packets, c->rd_packets, c->name);
@@ -446,7 +446,7 @@ static inline void tc_device_commit(struct tc_device *d) {
446
rrddim_set_by_pointer(d->st_dropped, c->rd_dropped, c->dropped);
447
448
// if it has a name, different to the id
449
- if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
449
+ if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
450
// update the rrd dimension with the new name
451
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_dropped->id, c->rd_dropped->id, c->name);
452
rrddim_set_name(d->st_dropped, c->rd_dropped, c->name);
@@ -500,7 +500,7 @@ static inline void tc_device_commit(struct tc_device *d) {
500
rrddim_set_by_pointer(d->st_tokens, c->rd_tokens, c->tokens);
501
502
// if it has a name, different to the id
503
- if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
503
+ if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
504
// update the rrd dimension with the new name
505
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_tokens->id, c->rd_tokens->id, c->name);
506
rrddim_set_name(d->st_tokens, c->rd_tokens, c->name);
@@ -554,7 +554,7 @@ static inline void tc_device_commit(struct tc_device *d) {
554
rrddim_set_by_pointer(d->st_ctokens, c->rd_ctokens, c->ctokens);
555
556
// if it has a name, different to the id
557
- if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
557
+ if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
558
// update the rrd dimension with the new name
559
debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_ctokens->id, c->rd_ctokens->id, c->name);
560
rrddim_set_name(d->st_ctokens, c->rd_ctokens, c->name);
@@ -575,7 +575,7 @@ static inline void tc_device_set_class_name(struct tc_device *d, char *id, char
575
freez(c->name);
576
c->name = NULL;
577
578
- if(likely(name && *name && strcmp(c->id, name) != 0)) {
578
+ if(likely(name && *name && strsame(c->id, name) != 0)) {
579
debug(D_TC_LOOP, "TC: Setting device '%s', class '%s' name to '%s'", d->id, id, name);
580
c->name = strdupz(name);
581
c->name_updated = 1;
@@ -587,7 +587,7 @@ static inline void tc_device_set_device_name(struct tc_device *d, char *name) {
587
freez(d->name);
588
d->name = NULL;
589
590
- if(likely(name && *name && strcmp(d->id, name) != 0)) {
590
+ if(likely(name && *name && strsame(d->id, name) != 0)) {
591
debug(D_TC_LOOP, "TC: Setting device '%s' name to '%s'", d->id, name);
592
d->name = strdupz(name);
593
d->name_updated = 1;
@@ -598,7 +598,7 @@ static inline void tc_device_set_device_family(struct tc_device *d, char *family
598
freez(d->family);
599
d->family = NULL;
600
601
- if(likely(family && *family && strcmp(d->id, family) != 0)) {
601
+ if(likely(family && *family && strsame(d->id, family) != 0)) {
602
debug(D_TC_LOOP, "TC: Setting device '%s' family to '%s'", d->id, family);
603
d->family = strdupz(family);
604
d->family_updated = 1;
@@ -815,17 +815,17 @@ void *tc_main(void *ptr) {
815
816
first_hash = simple_hash(words[0]);
817
818
- if(unlikely(device && first_hash == CLASS_HASH && strcmp(words[0], "class") == 0)) {
818
+ if(unlikely(device && first_hash == CLASS_HASH && strsame(words[0], "class") == 0)) {
819
// debug(D_TC_LOOP, "CLASS line on class id='%s', parent='%s', parentid='%s', leaf='%s', leafid='%s'", words[2], words[3], words[4], words[5], words[6]);
820
821
// words[1] : class type
822
// words[2] : N:XX
823
// words[3] : parent or root
824
- if(likely(words[1] && words[2] && words[3] && (strcmp(words[3], "parent") == 0 || strcmp(words[3], "root") == 0))) {
824
+ if(likely(words[1] && words[2] && words[3] && (strsame(words[3], "parent") == 0 || strsame(words[3], "root") == 0))) {
825
//char *type = words[1]; // the class: htb, fq_codel, etc
826
827
// we are only interested for HTB classes
828
- //if(strcmp(type, "htb") != 0) continue;
828
+ //if(strsame(type, "htb") != 0) continue;
829
830
char *id = words[2]; // the class major:minor
831
char *parent = words[3]; // 'parent' or 'root'
@@ -833,11 +833,11 @@ void *tc_main(void *ptr) {
833
char *leaf = words[5]; // 'leaf'
834
char *leafid = words[6]; // leafid
835
836
- if(strcmp(parent, "root") == 0) {
836
+ if(strsame(parent, "root") == 0) {
837
parentid = NULL;
838
leafid = NULL;
839
}
840
- else if(!leaf || strcmp(leaf, "leaf") != 0)
840
+ else if(!leaf || strsame(leaf, "leaf") != 0)
841
leafid = NULL;
842
843
char leafbuf[20 + 1] = "";
@@ -854,7 +854,7 @@ void *tc_main(void *ptr) {
854
class = NULL;
855
}
856
}
857
- else if(unlikely(first_hash == END_HASH && strcmp(words[0], "END") == 0)) {
857
+ else if(unlikely(first_hash == END_HASH && strsame(words[0], "END") == 0)) {
858
// debug(D_TC_LOOP, "END line");
859
860
if(likely(device)) {
@@ -871,7 +871,7 @@ void *tc_main(void *ptr) {
871
device = NULL;
872
class = NULL;
873
}
874
- else if(unlikely(first_hash == BEGIN_HASH && strcmp(words[0], "BEGIN") == 0)) {
874
+ else if(unlikely(first_hash == BEGIN_HASH && strsame(words[0], "BEGIN") == 0)) {
875
// debug(D_TC_LOOP, "BEGIN line on device '%s'", words[1]);
876
877
if(likely(words[1] && *words[1])) {
@@ -884,7 +884,7 @@ void *tc_main(void *ptr) {
884
885
class = NULL;
886
}
887
- else if(unlikely(device && class && first_hash == SENT_HASH && strcmp(words[0], "Sent") == 0)) {
887
+ else if(unlikely(device && class && first_hash == SENT_HASH && strsame(words[0], "Sent") == 0)) {
888
// debug(D_TC_LOOP, "SENT line '%s'", words[1]);
889
if(likely(words[1] && *words[1])) {
890
class->bytes = str2ull(words[1]);
@@ -906,7 +906,7 @@ void *tc_main(void *ptr) {
906
if(likely(words[10] && *words[10]))
907
class->requeues = str2ull(words[8]);
908
}
909
- else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strcmp(words[0], "lended:") == 0)) {
909
+ else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strsame(words[0], "lended:") == 0)) {
910
// debug(D_TC_LOOP, "LENDED line '%s'", words[1]);
911
if(likely(words[1] && *words[1]))
912
class->lended = str2ull(words[1]);
@@ -917,7 +917,7 @@ void *tc_main(void *ptr) {
917
if(likely(words[5] && *words[5]))
918
class->giants = str2ull(words[5]);
919
}
920
- else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strcmp(words[0], "tokens:") == 0)) {
920
+ else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strsame(words[0], "tokens:") == 0)) {
921
// debug(D_TC_LOOP, "TOKENS line '%s'", words[1]);
922
if(likely(words[1] && *words[1]))
923
class->tokens = str2ull(words[1]);
@@ -925,24 +925,24 @@ void *tc_main(void *ptr) {
925
if(likely(words[3] && *words[3]))
926
class->ctokens = str2ull(words[3]);
927
}
928
- else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strcmp(words[0], "SETDEVICENAME") == 0)) {
928
+ else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strsame(words[0], "SETDEVICENAME") == 0)) {
929
// debug(D_TC_LOOP, "SETDEVICENAME line '%s'", words[1]);
930
if(likely(words[1] && *words[1]))
931
tc_device_set_device_name(device, words[1]);
932
}
933
- else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strcmp(words[0], "SETDEVICEGROUP") == 0)) {
933
+ else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strsame(words[0], "SETDEVICEGROUP") == 0)) {
934
// debug(D_TC_LOOP, "SETDEVICEGROUP line '%s'", words[1]);
935
if(likely(words[1] && *words[1]))
936
tc_device_set_device_family(device, words[1]);
937
}
938
- else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strcmp(words[0], "SETCLASSNAME") == 0)) {
938
+ else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strsame(words[0], "SETCLASSNAME") == 0)) {
939
// debug(D_TC_LOOP, "SETCLASSNAME line '%s' '%s'", words[1], words[2]);
940
char *id = words[1];
941
char *path = words[2];
942
if(likely(id && *id && path && *path))
943
tc_device_set_class_name(device, id, path);
944
}
945
- else if(unlikely(first_hash == WORKTIME_HASH && strcmp(words[0], "WORKTIME") == 0)) {
945
+ else if(unlikely(first_hash == WORKTIME_HASH && strsame(words[0], "WORKTIME") == 0)) {
946
// debug(D_TC_LOOP, "WORKTIME line '%s' '%s'", words[1], words[2]);
947
getrusage(RUSAGE_THREAD, &thread);
948
@@ -970,7 +970,7 @@ void *tc_main(void *ptr) {
970
971
}
972
#ifdef DETACH_PLUGINS_FROM_NETDATA
973
- else if(unlikely(first_hash == MYPID_HASH && (strcmp(words[0], "MYPID") == 0))) {
973
+ else if(unlikely(first_hash == MYPID_HASH && (strsame(words[0], "MYPID") == 0))) {
974
// debug(D_TC_LOOP, "MYPID line '%s'", words[1]);
975
char *id = words[1];
976
pid_t pid = atol(id);
src/plugins_d.c
+13
-13
@@ -143,7 +143,7 @@ void *pluginsd_worker_thread(void *arg)
143
144
hash = simple_hash(s);
145
146
- if(likely(hash == SET_HASH && !strcmp(s, "SET"))) {
146
+ if(likely(hash == SET_HASH && !strsame(s, "SET"))) {
147
char *dimension = words[1];
148
char *value = words[2];
149
@@ -167,7 +167,7 @@ void *pluginsd_worker_thread(void *arg)
167
168
if(value) rrddim_set(st, dimension, strtoll(value, NULL, 0));
169
}
170
- else if(likely(hash == BEGIN_HASH && !strcmp(s, "BEGIN"))) {
170
+ else if(likely(hash == BEGIN_HASH && !strsame(s, "BEGIN"))) {
171
char *id = words[1];
172
char *microseconds_txt = words[2];
173
@@ -193,7 +193,7 @@ void *pluginsd_worker_thread(void *arg)
193
else rrdset_next(st);
194
}
195
}
196
- else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
196
+ else if(likely(hash == END_HASH && !strsame(s, "END"))) {
197
if(unlikely(!st)) {
198
error("PLUGINSD: '%s' is requesting an END, without a BEGIN. Disabling it.", cd->fullfilename);
199
cd->enabled = 0;
@@ -208,15 +208,15 @@ void *pluginsd_worker_thread(void *arg)
208
209
count++;
210
}
211
- else if(likely(hash == FLUSH_HASH && !strcmp(s, "FLUSH"))) {
211
+ else if(likely(hash == FLUSH_HASH && !strsame(s, "FLUSH"))) {
212
debug(D_PLUGINSD, "PLUGINSD: '%s' is requesting a FLUSH", cd->fullfilename);
213
st = NULL;
214
}
215
- else if(likely(hash == CHART_HASH && !strcmp(s, "CHART"))) {
215
+ else if(likely(hash == CHART_HASH && !strsame(s, "CHART"))) {
216
int noname = 0;
217
st = NULL;
218
219
- if((words[1]) != NULL && (words[2]) != NULL && strcmp(words[1], words[2]) == 0)
219
+ if((words[1]) != NULL && (words[2]) != NULL && strsame(words[1], words[2]) == 0)
220
noname = 1;
221
222
char *type = words[1];
@@ -272,7 +272,7 @@ void *pluginsd_worker_thread(void *arg)
272
}
273
else debug(D_PLUGINSD, "PLUGINSD: Chart '%s' already exists. Not adding it again.", st->id);
274
}
275
- else if(likely(hash == DIMENSION_HASH && !strcmp(s, "DIMENSION"))) {
275
+ else if(likely(hash == DIMENSION_HASH && !strsame(s, "DIMENSION"))) {
276
char *id = words[1];
277
char *name = words[2];
278
char *algorithm = words[3];
@@ -326,21 +326,21 @@ void *pluginsd_worker_thread(void *arg)
326
}
327
else if(unlikely(st->debug)) debug(D_PLUGINSD, "PLUGINSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
328
}
329
- else if(unlikely(hash == DISABLE_HASH && !strcmp(s, "DISABLE"))) {
329
+ else if(unlikely(hash == DISABLE_HASH && !strsame(s, "DISABLE"))) {
330
info("PLUGINSD: '%s' called DISABLE. Disabling it.", cd->fullfilename);
331
cd->enabled = 0;
332
killpid(cd->pid, SIGTERM);
333
break;
334
}
335
#ifdef DETACH_PLUGINS_FROM_NETDATA
336
- else if(likely(hash == MYPID_HASH && !strcmp(s, "MYPID"))) {
336
+ else if(likely(hash == MYPID_HASH && !strsame(s, "MYPID"))) {
337
char *pid_s = words[1];
338
pid_t pid = strtod(pid_s, NULL, 0);
339
340
if(likely(pid)) cd->pid = pid;
341
debug(D_PLUGINSD, "PLUGINSD: %s is on pid %d", cd->id, cd->pid);
342
}
343
- else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strcmp(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
343
+ else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strsame(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
344
error("PLUGINSD: '%s' (pid %d) called STOPPING_WAKE_ME_UP_PLEASE.", cd->fullfilename, cd->pid);
345
346
now_realtime_timeval(&now);
@@ -472,11 +472,11 @@ void *pluginsd_main(void *ptr) {
472
473
debug(D_PLUGINSD, "PLUGINSD: Examining file '%s'", file->d_name);
474
475
- if(unlikely(strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)) continue;
475
+ if(unlikely(strsame(file->d_name, ".") == 0 || strsame(file->d_name, "..") == 0)) continue;
476
477
int len = (int) strlen(file->d_name);
478
if(unlikely(len <= (int)PLUGINSD_FILE_SUFFIX_LEN)) continue;
479
- if(unlikely(strcmp(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
479
+ if(unlikely(strsame(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
480
debug(D_PLUGINSD, "PLUGINSD: File '%s' does not end in '%s'.", file->d_name, PLUGINSD_FILE_SUFFIX);
481
continue;
482
}
@@ -492,7 +492,7 @@ void *pluginsd_main(void *ptr) {
492
493
// check if it runs already
494
for(cd = pluginsd_root ; cd ; cd = cd->next)
495
- if(unlikely(strcmp(cd->filename, file->d_name) == 0)) break;
495
+ if(unlikely(strsame(cd->filename, file->d_name) == 0)) break;
496
497
if(likely(cd && !cd->obsolete)) {
498
debug(D_PLUGINSD, "PLUGINSD: plugin '%s' is already running", cd->filename);
src/proc_diskstats.c
+3
-3
@@ -91,7 +91,7 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
91
struct dirent *dp;
92
while( (dp = readdir(dirp)) ) {
93
// . and .. are also files in empty folders.
94
- if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
94
+ if(unlikely(strsame(dp->d_name, ".") == 0 || strsame(dp->d_name, "..") == 0)) {
95
continue;
96
}
97
@@ -243,7 +243,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
243
ff = procfile_readall(ff);
244
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
245
246
- uint32_t lines = procfile_lines(ff), l;
246
+ size_t lines = procfile_lines(ff), l;
247
248
for(l = 0; l < lines ;l++) {
249
// --------------------------------------------------------------------------
@@ -260,7 +260,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
260
last_writes = 0, last_writesectors = 0, last_writems = 0,
261
last_busy_ms = 0;
262
263
- uint32_t words = procfile_linewords(ff, l);
263
+ size_t words = procfile_linewords(ff, l);
264
if(unlikely(words < 14)) continue;
265
266
major = str2ul(procfile_lineword(ff, l, 0));
src/proc_interrupts.c
+9
-9
@@ -23,12 +23,12 @@ struct interrupt {
23
// given a base, get a pointer to each record
24
#define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[line * recordsize(cpus)])
25
26
-static inline struct interrupt *get_interrupts_array(uint32_t lines, int cpus) {
26
+static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) {
27
static struct interrupt *irrs = NULL;
28
- static uint32_t allocated = 0;
28
+ static size_t allocated = 0;
29
30
if(unlikely(lines != allocated)) {
31
- uint32_t l;
31
+ size_t l;
32
int c;
33
34
irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus));
@@ -69,8 +69,8 @@ int do_proc_interrupts(int update_every, usec_t dt) {
69
if(unlikely(!ff))
70
return 0; // we return 0, so that we will retry to open it next time
71
72
- uint32_t lines = procfile_lines(ff), l;
73
- uint32_t words = procfile_linewords(ff, 0);
72
+ size_t lines = procfile_lines(ff), l;
73
+ size_t words = procfile_linewords(ff, 0);
74
75
if(unlikely(!lines)) {
76
error("Cannot read /proc/interrupts, zero lines reported.");
@@ -108,8 +108,8 @@ int do_proc_interrupts(int update_every, usec_t dt) {
108
irr->id = procfile_lineword(ff, l, 0);
109
if(unlikely(!irr->id || !irr->id[0])) continue;
110
111
- int idlen = strlen(irr->id);
112
- if(unlikely(irr->id[idlen - 1] == ':'))
111
+ size_t idlen = strlen(irr->id);
112
+ if(unlikely(idlen && irr->id[idlen - 1] == ':'))
113
irr->id[idlen - 1] = '\0';
114
115
int c;
@@ -124,8 +124,8 @@ int do_proc_interrupts(int update_every, usec_t dt) {
124
125
if(unlikely(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words)) {
126
strncpyz(irr->name, procfile_lineword(ff, l, words - 1), MAX_INTERRUPT_NAME);
127
- int nlen = strlen(irr->name);
128
- int idlen = strlen(irr->id);
127
+ size_t nlen = strlen(irr->name);
128
+ idlen = strlen(irr->id);
129
if(likely(nlen + 1 + idlen <= MAX_INTERRUPT_NAME)) {
130
irr->name[nlen] = '_';
131
strncpyz(&irr->name[nlen + 1], irr->id, MAX_INTERRUPT_NAME - nlen - 1);
src/proc_meminfo.c
+44
-44
@@ -113,7 +113,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
113
if(unlikely(!ff))
114
return 0; // we return 0, so that we will retry to open it next time
115
116
- uint32_t lines = procfile_lines(ff), l;
116
+ size_t lines = procfile_lines(ff), l;
117
118
int hwcorrupted = 0;
119
@@ -162,54 +162,54 @@ int do_proc_meminfo(int update_every, usec_t dt) {
162
163
unsigned long long *value = NULL;
164
for(l = 0; l < lines ;l++) {
165
- uint32_t words = procfile_linewords(ff, l);
165
+ size_t words = procfile_linewords(ff, l);
166
if(unlikely(words < 2)) continue;
167
168
char *name = procfile_lineword(ff, l, 0);
169
uint32_t hash = simple_hash(name);
170
171
- if(hash == MemTotal_hash && strcmp(name, "MemTotal") == 0) value = &MemTotal;
172
- else if(hash == MemFree_hash && strcmp(name, "MemFree") == 0) value = &MemFree;
173
- else if(hash == Buffers_hash && strcmp(name, "Buffers") == 0) value = &Buffers;
174
- else if(hash == Cached_hash && strcmp(name, "Cached") == 0) value = &Cached;
175
- //else if(hash == SwapCached_hash && strcmp(name, "SwapCached") == 0) value = &SwapCached;
176
- //else if(hash == Active_hash && strcmp(name, "Active") == 0) value = &Active;
177
- //else if(hash == Inactive_hash && strcmp(name, "Inactive") == 0) value = &Inactive;
178
- //else if(hash == ActiveAnon_hash && strcmp(name, "ActiveAnon") == 0) value = &ActiveAnon;
179
- //else if(hash == InactiveAnon_hash && strcmp(name, "InactiveAnon") == 0) value = &InactiveAnon;
180
- //else if(hash == ActiveFile_hash && strcmp(name, "ActiveFile") == 0) value = &ActiveFile;
181
- //else if(hash == InactiveFile_hash && strcmp(name, "InactiveFile") == 0) value = &InactiveFile;
182
- //else if(hash == Unevictable_hash && strcmp(name, "Unevictable") == 0) value = &Unevictable;
183
- //else if(hash == Mlocked_hash && strcmp(name, "Mlocked") == 0) value = &Mlocked;
184
- else if(hash == SwapTotal_hash && strcmp(name, "SwapTotal") == 0) value = &SwapTotal;
185
- else if(hash == SwapFree_hash && strcmp(name, "SwapFree") == 0) value = &SwapFree;
186
- else if(hash == Dirty_hash && strcmp(name, "Dirty") == 0) value = &Dirty;
187
- else if(hash == Writeback_hash && strcmp(name, "Writeback") == 0) value = &Writeback;
188
- //else if(hash == AnonPages_hash && strcmp(name, "AnonPages") == 0) value = &AnonPages;
189
- //else if(hash == Mapped_hash && strcmp(name, "Mapped") == 0) value = &Mapped;
190
- //else if(hash == Shmem_hash && strcmp(name, "Shmem") == 0) value = &Shmem;
191
- else if(hash == Slab_hash && strcmp(name, "Slab") == 0) value = &Slab;
192
- else if(hash == SReclaimable_hash && strcmp(name, "SReclaimable") == 0) value = &SReclaimable;
193
- else if(hash == SUnreclaim_hash && strcmp(name, "SUnreclaim") == 0) value = &SUnreclaim;
194
- else if(hash == KernelStack_hash && strcmp(name, "KernelStack") == 0) value = &KernelStack;
195
- else if(hash == PageTables_hash && strcmp(name, "PageTables") == 0) value = &PageTables;
196
- else if(hash == NFS_Unstable_hash && strcmp(name, "NFS_Unstable") == 0) value = &NFS_Unstable;
197
- else if(hash == Bounce_hash && strcmp(name, "Bounce") == 0) value = &Bounce;
198
- else if(hash == WritebackTmp_hash && strcmp(name, "WritebackTmp") == 0) value = &WritebackTmp;
199
- //else if(hash == CommitLimit_hash && strcmp(name, "CommitLimit") == 0) value = &CommitLimit;
200
- else if(hash == Committed_AS_hash && strcmp(name, "Committed_AS") == 0) value = &Committed_AS;
201
- //else if(hash == VmallocTotal_hash && strcmp(name, "VmallocTotal") == 0) value = &VmallocTotal;
202
- else if(hash == VmallocUsed_hash && strcmp(name, "VmallocUsed") == 0) value = &VmallocUsed;
203
- //else if(hash == VmallocChunk_hash && strcmp(name, "VmallocChunk") == 0) value = &VmallocChunk;
204
- else if(hash == HardwareCorrupted_hash && strcmp(name, "HardwareCorrupted") == 0) { value = &HardwareCorrupted; hwcorrupted = 1; }
205
- //else if(hash == AnonHugePages_hash && strcmp(name, "AnonHugePages") == 0) value = &AnonHugePages;
206
- //else if(hash == HugePages_Total_hash && strcmp(name, "HugePages_Total") == 0) value = &HugePages_Total;
207
- //else if(hash == HugePages_Free_hash && strcmp(name, "HugePages_Free") == 0) value = &HugePages_Free;
208
- //else if(hash == HugePages_Rsvd_hash && strcmp(name, "HugePages_Rsvd") == 0) value = &HugePages_Rsvd;
209
- //else if(hash == HugePages_Surp_hash && strcmp(name, "HugePages_Surp") == 0) value = &HugePages_Surp;
210
- //else if(hash == Hugepagesize_hash && strcmp(name, "Hugepagesize") == 0) value = &Hugepagesize;
211
- //else if(hash == DirectMap4k_hash && strcmp(name, "DirectMap4k") == 0) value = &DirectMap4k;
212
- //else if(hash == DirectMap2M_hash && strcmp(name, "DirectMap2M") == 0) value = &DirectMap2M;
171
+ if(hash == MemTotal_hash && strsame(name, "MemTotal") == 0) value = &MemTotal;
172
+ else if(hash == MemFree_hash && strsame(name, "MemFree") == 0) value = &MemFree;
173
+ else if(hash == Buffers_hash && strsame(name, "Buffers") == 0) value = &Buffers;
174
+ else if(hash == Cached_hash && strsame(name, "Cached") == 0) value = &Cached;
175
+ //else if(hash == SwapCached_hash && strsame(name, "SwapCached") == 0) value = &SwapCached;
176
+ //else if(hash == Active_hash && strsame(name, "Active") == 0) value = &Active;
177
+ //else if(hash == Inactive_hash && strsame(name, "Inactive") == 0) value = &Inactive;
178
+ //else if(hash == ActiveAnon_hash && strsame(name, "ActiveAnon") == 0) value = &ActiveAnon;
179
+ //else if(hash == InactiveAnon_hash && strsame(name, "InactiveAnon") == 0) value = &InactiveAnon;
180
+ //else if(hash == ActiveFile_hash && strsame(name, "ActiveFile") == 0) value = &ActiveFile;
181
+ //else if(hash == InactiveFile_hash && strsame(name, "InactiveFile") == 0) value = &InactiveFile;
182
+ //else if(hash == Unevictable_hash && strsame(name, "Unevictable") == 0) value = &Unevictable;
183
+ //else if(hash == Mlocked_hash && strsame(name, "Mlocked") == 0) value = &Mlocked;
184
+ else if(hash == SwapTotal_hash && strsame(name, "SwapTotal") == 0) value = &SwapTotal;
185
+ else if(hash == SwapFree_hash && strsame(name, "SwapFree") == 0) value = &SwapFree;
186
+ else if(hash == Dirty_hash && strsame(name, "Dirty") == 0) value = &Dirty;
187
+ else if(hash == Writeback_hash && strsame(name, "Writeback") == 0) value = &Writeback;
188
+ //else if(hash == AnonPages_hash && strsame(name, "AnonPages") == 0) value = &AnonPages;
189
+ //else if(hash == Mapped_hash && strsame(name, "Mapped") == 0) value = &Mapped;
190
+ //else if(hash == Shmem_hash && strsame(name, "Shmem") == 0) value = &Shmem;
191
+ else if(hash == Slab_hash && strsame(name, "Slab") == 0) value = &Slab;
192
+ else if(hash == SReclaimable_hash && strsame(name, "SReclaimable") == 0) value = &SReclaimable;
193
+ else if(hash == SUnreclaim_hash && strsame(name, "SUnreclaim") == 0) value = &SUnreclaim;
194
+ else if(hash == KernelStack_hash && strsame(name, "KernelStack") == 0) value = &KernelStack;
195
+ else if(hash == PageTables_hash && strsame(name, "PageTables") == 0) value = &PageTables;
196
+ else if(hash == NFS_Unstable_hash && strsame(name, "NFS_Unstable") == 0) value = &NFS_Unstable;
197
+ else if(hash == Bounce_hash && strsame(name, "Bounce") == 0) value = &Bounce;
198
+ else if(hash == WritebackTmp_hash && strsame(name, "WritebackTmp") == 0) value = &WritebackTmp;
199
+ //else if(hash == CommitLimit_hash && strsame(name, "CommitLimit") == 0) value = &CommitLimit;
200
+ else if(hash == Committed_AS_hash && strsame(name, "Committed_AS") == 0) value = &Committed_AS;
201
+ //else if(hash == VmallocTotal_hash && strsame(name, "VmallocTotal") == 0) value = &VmallocTotal;
202
+ else if(hash == VmallocUsed_hash && strsame(name, "VmallocUsed") == 0) value = &VmallocUsed;
203
+ //else if(hash == VmallocChunk_hash && strsame(name, "VmallocChunk") == 0) value = &VmallocChunk;
204
+ else if(hash == HardwareCorrupted_hash && strsame(name, "HardwareCorrupted") == 0) { value = &HardwareCorrupted; hwcorrupted = 1; }
205
+ //else if(hash == AnonHugePages_hash && strsame(name, "AnonHugePages") == 0) value = &AnonHugePages;
206
+ //else if(hash == HugePages_Total_hash && strsame(name, "HugePages_Total") == 0) value = &HugePages_Total;
207
+ //else if(hash == HugePages_Free_hash && strsame(name, "HugePages_Free") == 0) value = &HugePages_Free;
208
+ //else if(hash == HugePages_Rsvd_hash && strsame(name, "HugePages_Rsvd") == 0) value = &HugePages_Rsvd;
209
+ //else if(hash == HugePages_Surp_hash && strsame(name, "HugePages_Surp") == 0) value = &HugePages_Surp;
210
+ //else if(hash == Hugepagesize_hash && strsame(name, "Hugepagesize") == 0) value = &Hugepagesize;
211
+ //else if(hash == DirectMap4k_hash && strsame(name, "DirectMap4k") == 0) value = &DirectMap4k;
212
+ //else if(hash == DirectMap2M_hash && strsame(name, "DirectMap2M") == 0) value = &DirectMap2M;
213
214
if(value) {
215
*value = str2ull(procfile_lineword(ff, l, 1));
src/proc_net_dev.c
+3
-3
@@ -77,7 +77,7 @@ static struct netdev *get_netdev(const char *name) {
77
78
// search it, from the last position to the end
79
for(d = last ; d ; d = d->next) {
80
- if(unlikely(hash == d->hash && !strcmp(name, d->name))) {
80
+ if(unlikely(hash == d->hash && !strsame(name, d->name))) {
81
last = d->next;
82
return d;
83
}
@@ -85,7 +85,7 @@ static struct netdev *get_netdev(const char *name) {
85
86
// search it from the beginning to the last position we used
87
for(d = netdev_root ; d != last ; d = d->next) {
88
- if(unlikely(hash == d->hash && !strcmp(name, d->name))) {
88
+ if(unlikely(hash == d->hash && !strsame(name, d->name))) {
89
last = d->next;
90
return d;
91
}
@@ -143,7 +143,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
143
ff = procfile_readall(ff);
144
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
145
146
- uint32_t lines = procfile_lines(ff), l;
146
+ size_t lines = procfile_lines(ff), l;
147
for(l = 2; l < lines ;l++) {
148
// require 17 words on each line
149
if(unlikely(procfile_linewords(ff, l) < 17)) continue;
src/proc_net_ip_vs_stats.c
-1
@@ -1,7 +1,6 @@
1
#include "common.h"
2
3
#define RRD_TYPE_NET_IPVS "ipvs"
4
-#define RRD_TYPE_NET_IPVS_LEN strlen(RRD_TYPE_NET_IPVS)
4
5
int do_proc_net_ip_vs_stats(int update_every, usec_t dt) {
6
static int do_bandwidth = -1, do_sockets = -1, do_packets = -1;
src/proc_net_netstat.c
+17
-17
@@ -161,19 +161,19 @@ static unsigned long long *netstat_columns_find(struct netstat_columns *nc, cons
161
uint32_t i, hash = simple_hash(name);
162
163
for(i = 0; nc[i].name ;i++)
164
- if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
164
+ if(unlikely(nc[i].hash == hash && !strsame(nc[i].name, name)))
165
return &nc[i].value;
166
167
fatal("Cannot find key '%s' in /proc/net/netstat internal array.", name);
168
}
169
170
-static void parse_line_pair(procfile *ff, struct netstat_columns *nc, uint32_t header_line, uint32_t values_line) {
171
- uint32_t hwords = procfile_linewords(ff, header_line);
172
- uint32_t vwords = procfile_linewords(ff, values_line);
173
- uint32_t w, i;
170
+static void parse_line_pair(procfile *ff, struct netstat_columns *nc, size_t header_line, size_t values_line) {
171
+ size_t hwords = procfile_linewords(ff, header_line);
172
+ size_t vwords = procfile_linewords(ff, values_line);
173
+ size_t w, i;
174
175
if(unlikely(vwords > hwords)) {
176
- error("File /proc/net/netstat on header line %u has %u words, but on value line %u has %u words.", header_line, hwords, values_line, vwords);
176
+ error("File /proc/net/netstat on header line %zu has %zu words, but on value line %zu has %zu words.", header_line, hwords, values_line, vwords);
177
vwords = hwords;
178
}
179
@@ -182,7 +182,7 @@ static void parse_line_pair(procfile *ff, struct netstat_columns *nc, uint32_t h
182
uint32_t hash = simple_hash(key);
183
184
for(i = 0 ; nc[i].name ;i++) {
185
- if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
185
+ if(unlikely(hash == nc[i].hash && !strsame(key, nc[i].name))) {
186
nc[i].value = str2ull(procfile_lineword(ff, values_line, w));
187
break;
188
}
@@ -549,23 +549,23 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
549
ff = procfile_readall(ff);
550
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
551
552
- uint32_t lines = procfile_lines(ff), l;
553
- uint32_t words;
552
+ size_t lines = procfile_lines(ff), l;
553
+ size_t words;
554
555
for(l = 0; l < lines ;l++) {
556
char *key = procfile_lineword(ff, l, 0);
557
uint32_t hash = simple_hash(key);
558
559
- if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
560
- uint32_t h = l++;
559
+ if(unlikely(hash == hash_ipext && strsame(key, "IpExt") == 0)) {
560
+ size_t h = l++;
561
562
- if(unlikely(strcmp(procfile_lineword(ff, l, 0), "IpExt") != 0)) {
562
+ if(unlikely(strsame(procfile_lineword(ff, l, 0), "IpExt") != 0)) {
563
error("Cannot read IpExt line from /proc/net/netstat.");
564
break;
565
}
566
words = procfile_linewords(ff, l);
567
if(unlikely(words < 2)) {
568
- error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %u.", words);
568
+ error("Cannot read /proc/net/netstat IpExt line. Expected 2+ params, read %zu.", words);
569
continue;
570
}
571
@@ -711,16 +711,16 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
711
rrdset_done(st);
712
}
713
}
714
- else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
715
- uint32_t h = l++;
714
+ else if(unlikely(hash == hash_tcpext && strsame(key, "TcpExt") == 0)) {
715
+ size_t h = l++;
716
717
- if(unlikely(strcmp(procfile_lineword(ff, l, 0), "TcpExt") != 0)) {
717
+ if(unlikely(strsame(procfile_lineword(ff, l, 0), "TcpExt") != 0)) {
718
error("Cannot read TcpExt line from /proc/net/netstat.");
719
break;
720
}
721
words = procfile_linewords(ff, l);
722
if(unlikely(words < 2)) {
723
- error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %u.", words);
723
+ error("Cannot read /proc/net/netstat TcpExt line. Expected 2+ params, read %zu.", words);
724
continue;
725
}
726
src/proc_net_rpc_nfs.c
+10
-10
@@ -151,28 +151,28 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
151
if(do_proc4 == -1) do_proc4 = config_get_boolean("plugin:proc:/proc/net/rpc/nfs", "NFS v4 procedures", 1);
152
153
// if they are enabled, reset them to 1
154
- // later we do them =2 to avoid doing strcmp for all lines
154
+ // later we do them =2 to avoid doing strsame() for all lines
155
if(do_net) do_net = 1;
156
if(do_rpc) do_rpc = 1;
157
if(do_proc2) do_proc2 = 1;
158
if(do_proc3) do_proc3 = 1;
159
if(do_proc4) do_proc4 = 1;
160
161
- uint32_t lines = procfile_lines(ff), l;
161
+ size_t lines = procfile_lines(ff), l;
162
163
char *type;
164
unsigned long long net_count = 0, net_udp_count = 0, net_tcp_count = 0, net_tcp_connections = 0;
165
unsigned long long rpc_calls = 0, rpc_retransmits = 0, rpc_auth_refresh = 0;
166
167
for(l = 0; l < lines ;l++) {
168
- uint32_t words = procfile_linewords(ff, l);
168
+ size_t words = procfile_linewords(ff, l);
169
if(!words) continue;
170
171
type = procfile_lineword(ff, l, 0);
172
173
- if(do_net == 1 && strcmp(type, "net") == 0) {
173
+ if(do_net == 1 && strsame(type, "net") == 0) {
174
if(words < 5) {
175
- error("%s line of /proc/net/rpc/nfs has %u words, expected %d", type, words, 5);
175
+ error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 5);
176
continue;
177
}
178
@@ -185,9 +185,9 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
185
if(sum == 0ULL) do_net = -1;
186
else do_net = 2;
187
}
188
- else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
188
+ else if(do_rpc == 1 && strsame(type, "rpc") == 0) {
189
if(words < 4) {
190
- error("%s line of /proc/net/rpc/nfs has %u words, expected %d", type, words, 6);
190
+ error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 6);
191
continue;
192
}
193
@@ -199,7 +199,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
199
if(sum == 0ULL) do_rpc = -1;
200
else do_rpc = 2;
201
}
202
- else if(do_proc2 == 1 && strcmp(type, "proc2") == 0) {
202
+ else if(do_proc2 == 1 && strsame(type, "proc2") == 0) {
203
// the first number is the count of numbers present
204
// so we start for word 2
205
@@ -220,7 +220,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
220
}
221
else do_proc2 = 2;
222
}
223
- else if(do_proc3 == 1 && strcmp(type, "proc3") == 0) {
223
+ else if(do_proc3 == 1 && strsame(type, "proc3") == 0) {
224
// the first number is the count of numbers present
225
// so we start for word 2
226
@@ -241,7 +241,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
241
}
242
else do_proc3 = 2;
243
}
244
- else if(do_proc4 == 1 && strcmp(type, "proc4") == 0) {
244
+ else if(do_proc4 == 1 && strsame(type, "proc4") == 0) {
245
// the first number is the count of numbers present
246
// so we start for word 2
247
src/proc_net_rpc_nfsd.c
+21
-21
@@ -239,7 +239,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
239
if(do_proc4ops == -1) do_proc4ops = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 operations", 1);
240
241
// if they are enabled, reset them to 1
242
- // later we do them =2 to avoid doing strcmp for all lines
242
+ // later we do them =2 to avoid doing strsame() for all lines
243
if(do_rc) do_rc = 1;
244
if(do_fh) do_fh = 1;
245
if(do_io) do_io = 1;
@@ -252,7 +252,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
252
if(do_proc4) do_proc4 = 1;
253
if(do_proc4ops) do_proc4ops = 1;
254
255
- uint32_t lines = procfile_lines(ff), l;
255
+ size_t lines = procfile_lines(ff), l;
256
257
char *type;
258
unsigned long long rc_hits = 0, rc_misses = 0, rc_nocache = 0;
@@ -264,14 +264,14 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
264
unsigned long long rpc_calls = 0, rpc_bad_format = 0, rpc_bad_auth = 0, rpc_bad_client = 0;
265
266
for(l = 0; l < lines ;l++) {
267
- uint32_t words = procfile_linewords(ff, l);
267
+ size_t words = procfile_linewords(ff, l);
268
if(!words) continue;
269
270
type = procfile_lineword(ff, l, 0);
271
272
- if(do_rc == 1 && strcmp(type, "rc") == 0) {
272
+ if(do_rc == 1 && strsame(type, "rc") == 0) {
273
if(words < 4) {
274
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 4);
274
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 4);
275
continue;
276
}
277
@@ -283,9 +283,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
283
if(sum == 0ULL) do_rc = -1;
284
else do_rc = 2;
285
}
286
- else if(do_fh == 1 && strcmp(type, "fh") == 0) {
286
+ else if(do_fh == 1 && strsame(type, "fh") == 0) {
287
if(words < 6) {
288
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 6);
288
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
289
continue;
290
}
291
@@ -299,9 +299,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
299
if(sum == 0ULL) do_fh = -1;
300
else do_fh = 2;
301
}
302
- else if(do_io == 1 && strcmp(type, "io") == 0) {
302
+ else if(do_io == 1 && strsame(type, "io") == 0) {
303
if(words < 3) {
304
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 3);
304
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 3);
305
continue;
306
}
307
@@ -312,9 +312,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
312
if(sum == 0ULL) do_io = -1;
313
else do_io = 2;
314
}
315
- else if(do_th == 1 && strcmp(type, "th") == 0) {
315
+ else if(do_th == 1 && strsame(type, "th") == 0) {
316
if(words < 13) {
317
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 13);
317
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
318
continue;
319
}
320
@@ -343,9 +343,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
343
}
344
else do_th = 2;
345
}
346
- else if(do_ra == 1 && strcmp(type, "ra") == 0) {
346
+ else if(do_ra == 1 && strsame(type, "ra") == 0) {
347
if(words < 13) {
348
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 13);
348
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
349
continue;
350
}
351
@@ -372,9 +372,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
372
}
373
else do_ra = 2;
374
}
375
- else if(do_net == 1 && strcmp(type, "net") == 0) {
375
+ else if(do_net == 1 && strsame(type, "net") == 0) {
376
if(words < 5) {
377
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 5);
377
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 5);
378
continue;
379
}
380
@@ -387,9 +387,9 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
387
if(sum == 0ULL) do_net = -1;
388
else do_net = 2;
389
}
390
- else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
390
+ else if(do_rpc == 1 && strsame(type, "rpc") == 0) {
391
if(words < 6) {
392
- error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 6);
392
+ error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
393
continue;
394
}
395
@@ -402,7 +402,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
402
if(sum == 0ULL) do_rpc = -1;
403
else do_rpc = 2;
404
}
405
- else if(do_proc2 == 1 && strcmp(type, "proc2") == 0) {
405
+ else if(do_proc2 == 1 && strsame(type, "proc2") == 0) {
406
// the first number is the count of numbers present
407
// so we start for word 2
408
@@ -423,7 +423,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
423
}
424
else do_proc2 = 2;
425
}
426
- else if(do_proc3 == 1 && strcmp(type, "proc3") == 0) {
426
+ else if(do_proc3 == 1 && strsame(type, "proc3") == 0) {
427
// the first number is the count of numbers present
428
// so we start for word 2
429
@@ -444,7 +444,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
444
}
445
else do_proc3 = 2;
446
}
447
- else if(do_proc4 == 1 && strcmp(type, "proc4") == 0) {
447
+ else if(do_proc4 == 1 && strsame(type, "proc4") == 0) {
448
// the first number is the count of numbers present
449
// so we start for word 2
450
@@ -465,7 +465,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
465
}
466
else do_proc4 = 2;
467
}
468
- else if(do_proc4ops == 1 && strcmp(type, "proc4ops") == 0) {
468
+ else if(do_proc4ops == 1 && strsame(type, "proc4ops") == 0) {
469
// the first number is the count of numbers present
470
// so we start for word 2
471
src/proc_net_snmp.c
+32
-35
@@ -1,9 +1,6 @@
1
#include "common.h"
2
3
#define RRD_TYPE_NET_SNMP "ipv4"
4
-#define RRD_TYPE_NET_SNMP_LEN strlen(RRD_TYPE_NET_SNMP)
5
-
6
-#define NETSTAT_PRESENT 0x00000001
4
5
struct netstat_columns {
6
char *name;
@@ -168,19 +165,19 @@ static unsigned long long *netstat_columns_find(struct netstat_columns *nc, cons
165
uint32_t i, hash = simple_hash(name);
166
167
for(i = 0; nc[i].name ;i++)
171
- if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
168
+ if(unlikely(nc[i].hash == hash && !strsame(nc[i].name, name)))
169
return &nc[i].value;
170
171
fatal("Cannot find key '%s' in /proc/net/snmp internal array.", name);
172
}
173
177
-static void parse_line_pair(procfile *ff, struct netstat_columns *nc, uint32_t header_line, uint32_t values_line) {
178
- uint32_t hwords = procfile_linewords(ff, header_line);
179
- uint32_t vwords = procfile_linewords(ff, values_line);
180
- uint32_t w, i;
174
+static void parse_line_pair(procfile *ff, struct netstat_columns *nc, size_t header_line, size_t values_line) {
175
+ size_t hwords = procfile_linewords(ff, header_line);
176
+ size_t vwords = procfile_linewords(ff, values_line);
177
+ size_t w, i;
178
179
if(unlikely(vwords > hwords)) {
183
- error("File /proc/net/snmp on header line %u has %u words, but on value line %u has %u words.", header_line, hwords, values_line, vwords);
180
+ error("File /proc/net/snmp on header line %zu has %zu words, but on value line %zu has %zu words.", header_line, hwords, values_line, vwords);
181
vwords = hwords;
182
}
183
@@ -189,7 +186,7 @@ static void parse_line_pair(procfile *ff, struct netstat_columns *nc, uint32_t h
186
uint32_t hash = simple_hash(key);
187
188
for(i = 0 ; nc[i].name ;i++) {
192
- if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
189
+ if(unlikely(hash == nc[i].hash && !strsame(key, nc[i].name))) {
190
nc[i].value = str2ull(procfile_lineword(ff, values_line, w));
191
break;
192
}
@@ -366,8 +363,8 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
363
ff = procfile_readall(ff);
364
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
365
369
- uint32_t lines = procfile_lines(ff), l;
370
- uint32_t words;
366
+ size_t lines = procfile_lines(ff), l;
367
+ size_t words;
368
369
RRDSET *st;
370
@@ -375,17 +372,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
372
char *key = procfile_lineword(ff, l, 0);
373
uint32_t hash = simple_hash(key);
374
378
- if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) {
379
- uint32_t h = l++;
375
+ if(unlikely(hash == hash_ip && strsame(key, "Ip") == 0)) {
376
+ size_t h = l++;
377
381
- if(strcmp(procfile_lineword(ff, l, 0), "Ip") != 0) {
378
+ if(strsame(procfile_lineword(ff, l, 0), "Ip") != 0) {
379
error("Cannot read Ip line from /proc/net/snmp.");
380
break;
381
}
382
383
words = procfile_linewords(ff, l);
384
if(words < 3) {
388
- error("Cannot read /proc/net/snmp Ip line. Expected 3+ params, read %u.", words);
385
+ error("Cannot read /proc/net/snmp Ip line. Expected 3+ params, read %zu.", words);
386
continue;
387
}
388
@@ -481,17 +478,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
478
rrdset_done(st);
479
}
480
}
484
- else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) {
485
- uint32_t h = l++;
481
+ else if(unlikely(hash == hash_icmp && strsame(key, "Icmp") == 0)) {
482
+ size_t h = l++;
483
487
- if(strcmp(procfile_lineword(ff, l, 0), "Icmp") != 0) {
484
+ if(strsame(procfile_lineword(ff, l, 0), "Icmp") != 0) {
485
error("Cannot read Icmp line from /proc/net/snmp.");
486
break;
487
}
488
489
words = procfile_linewords(ff, l);
490
if(words < 3) {
494
- error("Cannot read /proc/net/snmp Icmp line. Expected 3+ params, read %u.", words);
491
+ error("Cannot read /proc/net/snmp Icmp line. Expected 3+ params, read %zu.", words);
492
continue;
493
}
494
@@ -531,10 +528,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
528
rrdset_done(st);
529
}
530
}
534
- else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) {
535
- uint32_t h = l++;
531
+ else if(unlikely(hash == hash_icmpmsg && strsame(key, "IcmpMsg") == 0)) {
532
+ size_t h = l++;
533
537
- if(strcmp(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
534
+ if(strsame(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
535
error("Cannot read IcmpMsg line from /proc/net/snmp.");
536
break;
537
}
@@ -561,17 +558,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
558
rrdset_done(st);
559
}
560
}
564
- else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) {
565
- uint32_t h = l++;
561
+ else if(unlikely(hash == hash_tcp && strsame(key, "Tcp") == 0)) {
562
+ size_t h = l++;
563
567
- if(strcmp(procfile_lineword(ff, l, 0), "Tcp") != 0) {
564
+ if(strsame(procfile_lineword(ff, l, 0), "Tcp") != 0) {
565
error("Cannot read Tcp line from /proc/net/snmp.");
566
break;
567
}
568
569
words = procfile_linewords(ff, l);
570
if(words < 3) {
574
- error("Cannot read /proc/net/snmp Tcp line. Expected 3+ params, read %u.", words);
571
+ error("Cannot read /proc/net/snmp Tcp line. Expected 3+ params, read %zu.", words);
572
continue;
573
}
574
@@ -654,17 +651,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
651
rrdset_done(st);
652
}
653
}
657
- else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) {
658
- uint32_t h = l++;
654
+ else if(unlikely(hash == hash_udp && strsame(key, "Udp") == 0)) {
655
+ size_t h = l++;
656
660
- if(strcmp(procfile_lineword(ff, l, 0), "Udp") != 0) {
657
+ if(strsame(procfile_lineword(ff, l, 0), "Udp") != 0) {
658
error("Cannot read Udp line from /proc/net/snmp.");
659
break;
660
}
661
662
words = procfile_linewords(ff, l);
663
if(words < 3) {
667
- error("Cannot read /proc/net/snmp Udp line. Expected 3+ params, read %u.", words);
664
+ error("Cannot read /proc/net/snmp Udp line. Expected 3+ params, read %zu.", words);
665
continue;
666
}
667
@@ -714,17 +711,17 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
711
rrdset_done(st);
712
}
713
}
717
- else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) {
718
- uint32_t h = l++;
714
+ else if(unlikely(hash == hash_udplite && strsame(key, "UdpLite") == 0)) {
715
+ size_t h = l++;
716
720
- if(strcmp(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
717
+ if(strsame(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
718
error("Cannot read UdpLite line from /proc/net/snmp.");
719
break;
720
}
721
722
words = procfile_linewords(ff, l);
723
if(words < 3) {
727
- error("Cannot read /proc/net/snmp UdpLite line. Expected 3+ params, read %u.", words);
724
+ error("Cannot read /proc/net/snmp UdpLite line. Expected 3+ params, read %zu.", words);
725
continue;
726
}
727
src/proc_net_snmp6.c
+95
-96
@@ -1,7 +1,6 @@
1
#include "common.h"
2
3
#define RRD_TYPE_NET_SNMP6 "ipv6"
4
-#define RRD_TYPE_NET_SNMP6_LEN strlen(RRD_TYPE_NET_SNMP6)
4
5
int do_proc_net_snmp6(int update_every, usec_t dt) {
6
(void)dt;
@@ -252,7 +251,7 @@ int do_proc_net_snmp6(int update_every, usec_t dt) {
251
if(unlikely(!ff))
252
return 0; // we return 0, so that we will retry to open it next time
253
255
- uint32_t lines = procfile_lines(ff), l;
254
+ size_t lines = procfile_lines(ff), l;
255
256
unsigned long long Ip6InReceives = 0ULL;
257
unsigned long long Ip6InHdrErrors = 0ULL;
@@ -350,9 +349,9 @@ int do_proc_net_snmp6(int update_every, usec_t dt) {
349
unsigned long long *ptr = NULL;
350
351
for(l = 0; l < lines ;l++) {
353
- uint32_t words = procfile_linewords(ff, l);
352
+ size_t words = procfile_linewords(ff, l);
353
if(unlikely(words < 2)) {
355
- if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
354
+ if(unlikely(words)) error("Cannot read /proc/net/snmp6 line %zu. Expected 2 params, read %zu.", l, words);
355
continue;
356
}
357
@@ -363,98 +362,98 @@ int do_proc_net_snmp6(int update_every, usec_t dt) {
362
363
uint32_t hash = simple_hash(name);
364
366
- if(unlikely(hash == hash_Ip6InReceives && strcmp(name, "Ip6InReceives") == 0)) ptr = &Ip6InReceives;
367
- else if(unlikely(hash == hash_Ip6InHdrErrors && strcmp(name, "Ip6InHdrErrors") == 0)) ptr = &Ip6InHdrErrors;
368
- else if(unlikely(hash == hash_Ip6InTooBigErrors && strcmp(name, "Ip6InTooBigErrors") == 0)) ptr = &Ip6InTooBigErrors;
369
- else if(unlikely(hash == hash_Ip6InNoRoutes && strcmp(name, "Ip6InNoRoutes") == 0)) ptr = &Ip6InNoRoutes;
370
- else if(unlikely(hash == hash_Ip6InAddrErrors && strcmp(name, "Ip6InAddrErrors") == 0)) ptr = &Ip6InAddrErrors;
371
- else if(unlikely(hash == hash_Ip6InUnknownProtos && strcmp(name, "Ip6InUnknownProtos") == 0)) ptr = &Ip6InUnknownProtos;
372
- else if(unlikely(hash == hash_Ip6InTruncatedPkts && strcmp(name, "Ip6InTruncatedPkts") == 0)) ptr = &Ip6InTruncatedPkts;
373
- else if(unlikely(hash == hash_Ip6InDiscards && strcmp(name, "Ip6InDiscards") == 0)) ptr = &Ip6InDiscards;
374
- else if(unlikely(hash == hash_Ip6InDelivers && strcmp(name, "Ip6InDelivers") == 0)) ptr = &Ip6InDelivers;
375
- else if(unlikely(hash == hash_Ip6OutForwDatagrams && strcmp(name, "Ip6OutForwDatagrams") == 0)) ptr = &Ip6OutForwDatagrams;
376
- else if(unlikely(hash == hash_Ip6OutRequests && strcmp(name, "Ip6OutRequests") == 0)) ptr = &Ip6OutRequests;
377
- else if(unlikely(hash == hash_Ip6OutDiscards && strcmp(name, "Ip6OutDiscards") == 0)) ptr = &Ip6OutDiscards;
378
- else if(unlikely(hash == hash_Ip6OutNoRoutes && strcmp(name, "Ip6OutNoRoutes") == 0)) ptr = &Ip6OutNoRoutes;
379
- else if(unlikely(hash == hash_Ip6ReasmTimeout && strcmp(name, "Ip6ReasmTimeout") == 0)) ptr = &Ip6ReasmTimeout;
380
- else if(unlikely(hash == hash_Ip6ReasmReqds && strcmp(name, "Ip6ReasmReqds") == 0)) ptr = &Ip6ReasmReqds;
381
- else if(unlikely(hash == hash_Ip6ReasmOKs && strcmp(name, "Ip6ReasmOKs") == 0)) ptr = &Ip6ReasmOKs;
382
- else if(unlikely(hash == hash_Ip6ReasmFails && strcmp(name, "Ip6ReasmFails") == 0)) ptr = &Ip6ReasmFails;
383
- else if(unlikely(hash == hash_Ip6FragOKs && strcmp(name, "Ip6FragOKs") == 0)) ptr = &Ip6FragOKs;
384
- else if(unlikely(hash == hash_Ip6FragFails && strcmp(name, "Ip6FragFails") == 0)) ptr = &Ip6FragFails;
385
- else if(unlikely(hash == hash_Ip6FragCreates && strcmp(name, "Ip6FragCreates") == 0)) ptr = &Ip6FragCreates;
386
- else if(unlikely(hash == hash_Ip6InMcastPkts && strcmp(name, "Ip6InMcastPkts") == 0)) ptr = &Ip6InMcastPkts;
387
- else if(unlikely(hash == hash_Ip6OutMcastPkts && strcmp(name, "Ip6OutMcastPkts") == 0)) ptr = &Ip6OutMcastPkts;
388
- else if(unlikely(hash == hash_Ip6InOctets && strcmp(name, "Ip6InOctets") == 0)) ptr = &Ip6InOctets;
389
- else if(unlikely(hash == hash_Ip6OutOctets && strcmp(name, "Ip6OutOctets") == 0)) ptr = &Ip6OutOctets;
390
- else if(unlikely(hash == hash_Ip6InMcastOctets && strcmp(name, "Ip6InMcastOctets") == 0)) ptr = &Ip6InMcastOctets;
391
- else if(unlikely(hash == hash_Ip6OutMcastOctets && strcmp(name, "Ip6OutMcastOctets") == 0)) ptr = &Ip6OutMcastOctets;
392
- else if(unlikely(hash == hash_Ip6InBcastOctets && strcmp(name, "Ip6InBcastOctets") == 0)) ptr = &Ip6InBcastOctets;
393
- else if(unlikely(hash == hash_Ip6OutBcastOctets && strcmp(name, "Ip6OutBcastOctets") == 0)) ptr = &Ip6OutBcastOctets;
394
- else if(unlikely(hash == hash_Ip6InNoECTPkts && strcmp(name, "Ip6InNoECTPkts") == 0)) ptr = &Ip6InNoECTPkts;
395
- else if(unlikely(hash == hash_Ip6InECT1Pkts && strcmp(name, "Ip6InECT1Pkts") == 0)) ptr = &Ip6InECT1Pkts;
396
- else if(unlikely(hash == hash_Ip6InECT0Pkts && strcmp(name, "Ip6InECT0Pkts") == 0)) ptr = &Ip6InECT0Pkts;
397
- else if(unlikely(hash == hash_Ip6InCEPkts && strcmp(name, "Ip6InCEPkts") == 0)) ptr = &Ip6InCEPkts;
398
- else if(unlikely(hash == hash_Icmp6InMsgs && strcmp(name, "Icmp6InMsgs") == 0)) ptr = &Icmp6InMsgs;
399
- else if(unlikely(hash == hash_Icmp6InErrors && strcmp(name, "Icmp6InErrors") == 0)) ptr = &Icmp6InErrors;
400
- else if(unlikely(hash == hash_Icmp6OutMsgs && strcmp(name, "Icmp6OutMsgs") == 0)) ptr = &Icmp6OutMsgs;
401
- else if(unlikely(hash == hash_Icmp6OutErrors && strcmp(name, "Icmp6OutErrors") == 0)) ptr = &Icmp6OutErrors;
402
- else if(unlikely(hash == hash_Icmp6InCsumErrors && strcmp(name, "Icmp6InCsumErrors") == 0)) ptr = &Icmp6InCsumErrors;
403
- else if(unlikely(hash == hash_Icmp6InDestUnreachs && strcmp(name, "Icmp6InDestUnreachs") == 0)) ptr = &Icmp6InDestUnreachs;
404
- else if(unlikely(hash == hash_Icmp6InPktTooBigs && strcmp(name, "Icmp6InPktTooBigs") == 0)) ptr = &Icmp6InPktTooBigs;
405
- else if(unlikely(hash == hash_Icmp6InTimeExcds && strcmp(name, "Icmp6InTimeExcds") == 0)) ptr = &Icmp6InTimeExcds;
406
- else if(unlikely(hash == hash_Icmp6InParmProblems && strcmp(name, "Icmp6InParmProblems") == 0)) ptr = &Icmp6InParmProblems;
407
- else if(unlikely(hash == hash_Icmp6InEchos && strcmp(name, "Icmp6InEchos") == 0)) ptr = &Icmp6InEchos;
408
- else if(unlikely(hash == hash_Icmp6InEchoReplies && strcmp(name, "Icmp6InEchoReplies") == 0)) ptr = &Icmp6InEchoReplies;
409
- else if(unlikely(hash == hash_Icmp6InGroupMembQueries && strcmp(name, "Icmp6InGroupMembQueries") == 0)) ptr = &Icmp6InGroupMembQueries;
410
- else if(unlikely(hash == hash_Icmp6InGroupMembResponses && strcmp(name, "Icmp6InGroupMembResponses") == 0)) ptr = &Icmp6InGroupMembResponses;
411
- else if(unlikely(hash == hash_Icmp6InGroupMembReductions && strcmp(name, "Icmp6InGroupMembReductions") == 0)) ptr = &Icmp6InGroupMembReductions;
412
- else if(unlikely(hash == hash_Icmp6InRouterSolicits && strcmp(name, "Icmp6InRouterSolicits") == 0)) ptr = &Icmp6InRouterSolicits;
413
- else if(unlikely(hash == hash_Icmp6InRouterAdvertisements && strcmp(name, "Icmp6InRouterAdvertisements") == 0)) ptr = &Icmp6InRouterAdvertisements;
414
- else if(unlikely(hash == hash_Icmp6InNeighborSolicits && strcmp(name, "Icmp6InNeighborSolicits") == 0)) ptr = &Icmp6InNeighborSolicits;
415
- else if(unlikely(hash == hash_Icmp6InNeighborAdvertisements && strcmp(name, "Icmp6InNeighborAdvertisements") == 0)) ptr = &Icmp6InNeighborAdvertisements;
416
- else if(unlikely(hash == hash_Icmp6InRedirects && strcmp(name, "Icmp6InRedirects") == 0)) ptr = &Icmp6InRedirects;
417
- else if(unlikely(hash == hash_Icmp6InMLDv2Reports && strcmp(name, "Icmp6InMLDv2Reports") == 0)) ptr = &Icmp6InMLDv2Reports;
418
- else if(unlikely(hash == hash_Icmp6OutDestUnreachs && strcmp(name, "Icmp6OutDestUnreachs") == 0)) ptr = &Icmp6OutDestUnreachs;
419
- else if(unlikely(hash == hash_Icmp6OutPktTooBigs && strcmp(name, "Icmp6OutPktTooBigs") == 0)) ptr = &Icmp6OutPktTooBigs;
420
- else if(unlikely(hash == hash_Icmp6OutTimeExcds && strcmp(name, "Icmp6OutTimeExcds") == 0)) ptr = &Icmp6OutTimeExcds;
421
- else if(unlikely(hash == hash_Icmp6OutParmProblems && strcmp(name, "Icmp6OutParmProblems") == 0)) ptr = &Icmp6OutParmProblems;
422
- else if(unlikely(hash == hash_Icmp6OutEchos && strcmp(name, "Icmp6OutEchos") == 0)) ptr = &Icmp6OutEchos;
423
- else if(unlikely(hash == hash_Icmp6OutEchoReplies && strcmp(name, "Icmp6OutEchoReplies") == 0)) ptr = &Icmp6OutEchoReplies;
424
- else if(unlikely(hash == hash_Icmp6OutGroupMembQueries && strcmp(name, "Icmp6OutGroupMembQueries") == 0)) ptr = &Icmp6OutGroupMembQueries;
425
- else if(unlikely(hash == hash_Icmp6OutGroupMembResponses && strcmp(name, "Icmp6OutGroupMembResponses") == 0)) ptr = &Icmp6OutGroupMembResponses;
426
- else if(unlikely(hash == hash_Icmp6OutGroupMembReductions && strcmp(name, "Icmp6OutGroupMembReductions") == 0)) ptr = &Icmp6OutGroupMembReductions;
427
- else if(unlikely(hash == hash_Icmp6OutRouterSolicits && strcmp(name, "Icmp6OutRouterSolicits") == 0)) ptr = &Icmp6OutRouterSolicits;
428
- else if(unlikely(hash == hash_Icmp6OutRouterAdvertisements && strcmp(name, "Icmp6OutRouterAdvertisements") == 0)) ptr = &Icmp6OutRouterAdvertisements;
429
- else if(unlikely(hash == hash_Icmp6OutNeighborSolicits && strcmp(name, "Icmp6OutNeighborSolicits") == 0)) ptr = &Icmp6OutNeighborSolicits;
430
- else if(unlikely(hash == hash_Icmp6OutNeighborAdvertisements && strcmp(name, "Icmp6OutNeighborAdvertisements") == 0)) ptr = &Icmp6OutNeighborAdvertisements;
431
- else if(unlikely(hash == hash_Icmp6OutRedirects && strcmp(name, "Icmp6OutRedirects") == 0)) ptr = &Icmp6OutRedirects;
432
- else if(unlikely(hash == hash_Icmp6OutMLDv2Reports && strcmp(name, "Icmp6OutMLDv2Reports") == 0)) ptr = &Icmp6OutMLDv2Reports;
433
- else if(unlikely(hash == hash_Icmp6InType1 && strcmp(name, "Icmp6InType1") == 0)) ptr = &Icmp6InType1;
434
- else if(unlikely(hash == hash_Icmp6InType128 && strcmp(name, "Icmp6InType128") == 0)) ptr = &Icmp6InType128;
435
- else if(unlikely(hash == hash_Icmp6InType129 && strcmp(name, "Icmp6InType129") == 0)) ptr = &Icmp6InType129;
436
- else if(unlikely(hash == hash_Icmp6InType136 && strcmp(name, "Icmp6InType136") == 0)) ptr = &Icmp6InType136;
437
- else if(unlikely(hash == hash_Icmp6OutType1 && strcmp(name, "Icmp6OutType1") == 0)) ptr = &Icmp6OutType1;
438
- else if(unlikely(hash == hash_Icmp6OutType128 && strcmp(name, "Icmp6OutType128") == 0)) ptr = &Icmp6OutType128;
439
- else if(unlikely(hash == hash_Icmp6OutType129 && strcmp(name, "Icmp6OutType129") == 0)) ptr = &Icmp6OutType129;
440
- else if(unlikely(hash == hash_Icmp6OutType133 && strcmp(name, "Icmp6OutType133") == 0)) ptr = &Icmp6OutType133;
441
- else if(unlikely(hash == hash_Icmp6OutType135 && strcmp(name, "Icmp6OutType135") == 0)) ptr = &Icmp6OutType135;
442
- else if(unlikely(hash == hash_Icmp6OutType143 && strcmp(name, "Icmp6OutType143") == 0)) ptr = &Icmp6OutType143;
443
- else if(unlikely(hash == hash_Udp6InDatagrams && strcmp(name, "Udp6InDatagrams") == 0)) ptr = &Udp6InDatagrams;
444
- else if(unlikely(hash == hash_Udp6NoPorts && strcmp(name, "Udp6NoPorts") == 0)) ptr = &Udp6NoPorts;
445
- else if(unlikely(hash == hash_Udp6InErrors && strcmp(name, "Udp6InErrors") == 0)) ptr = &Udp6InErrors;
446
- else if(unlikely(hash == hash_Udp6OutDatagrams && strcmp(name, "Udp6OutDatagrams") == 0)) ptr = &Udp6OutDatagrams;
447
- else if(unlikely(hash == hash_Udp6RcvbufErrors && strcmp(name, "Udp6RcvbufErrors") == 0)) ptr = &Udp6RcvbufErrors;
448
- else if(unlikely(hash == hash_Udp6SndbufErrors && strcmp(name, "Udp6SndbufErrors") == 0)) ptr = &Udp6SndbufErrors;
449
- else if(unlikely(hash == hash_Udp6InCsumErrors && strcmp(name, "Udp6InCsumErrors") == 0)) ptr = &Udp6InCsumErrors;
450
- else if(unlikely(hash == hash_Udp6IgnoredMulti && strcmp(name, "Udp6IgnoredMulti") == 0)) ptr = &Udp6IgnoredMulti;
451
- else if(unlikely(hash == hash_UdpLite6InDatagrams && strcmp(name, "UdpLite6InDatagrams") == 0)) ptr = &UdpLite6InDatagrams;
452
- else if(unlikely(hash == hash_UdpLite6NoPorts && strcmp(name, "UdpLite6NoPorts") == 0)) ptr = &UdpLite6NoPorts;
453
- else if(unlikely(hash == hash_UdpLite6InErrors && strcmp(name, "UdpLite6InErrors") == 0)) ptr = &UdpLite6InErrors;
454
- else if(unlikely(hash == hash_UdpLite6OutDatagrams && strcmp(name, "UdpLite6OutDatagrams") == 0)) ptr = &UdpLite6OutDatagrams;
455
- else if(unlikely(hash == hash_UdpLite6RcvbufErrors && strcmp(name, "UdpLite6RcvbufErrors") == 0)) ptr = &UdpLite6RcvbufErrors;
456
- else if(unlikely(hash == hash_UdpLite6SndbufErrors && strcmp(name, "UdpLite6SndbufErrors") == 0)) ptr = &UdpLite6SndbufErrors;
457
- else if(unlikely(hash == hash_UdpLite6InCsumErrors && strcmp(name, "UdpLite6InCsumErrors") == 0)) ptr = &UdpLite6InCsumErrors;
365
+ if(unlikely(hash == hash_Ip6InReceives && strsame(name, "Ip6InReceives") == 0)) ptr = &Ip6InReceives;
366
+ else if(unlikely(hash == hash_Ip6InHdrErrors && strsame(name, "Ip6InHdrErrors") == 0)) ptr = &Ip6InHdrErrors;
367
+ else if(unlikely(hash == hash_Ip6InTooBigErrors && strsame(name, "Ip6InTooBigErrors") == 0)) ptr = &Ip6InTooBigErrors;
368
+ else if(unlikely(hash == hash_Ip6InNoRoutes && strsame(name, "Ip6InNoRoutes") == 0)) ptr = &Ip6InNoRoutes;
369
+ else if(unlikely(hash == hash_Ip6InAddrErrors && strsame(name, "Ip6InAddrErrors") == 0)) ptr = &Ip6InAddrErrors;
370
+ else if(unlikely(hash == hash_Ip6InUnknownProtos && strsame(name, "Ip6InUnknownProtos") == 0)) ptr = &Ip6InUnknownProtos;
371
+ else if(unlikely(hash == hash_Ip6InTruncatedPkts && strsame(name, "Ip6InTruncatedPkts") == 0)) ptr = &Ip6InTruncatedPkts;
372
+ else if(unlikely(hash == hash_Ip6InDiscards && strsame(name, "Ip6InDiscards") == 0)) ptr = &Ip6InDiscards;
373
+ else if(unlikely(hash == hash_Ip6InDelivers && strsame(name, "Ip6InDelivers") == 0)) ptr = &Ip6InDelivers;
374
+ else if(unlikely(hash == hash_Ip6OutForwDatagrams && strsame(name, "Ip6OutForwDatagrams") == 0)) ptr = &Ip6OutForwDatagrams;
375
+ else if(unlikely(hash == hash_Ip6OutRequests && strsame(name, "Ip6OutRequests") == 0)) ptr = &Ip6OutRequests;
376
+ else if(unlikely(hash == hash_Ip6OutDiscards && strsame(name, "Ip6OutDiscards") == 0)) ptr = &Ip6OutDiscards;
377
+ else if(unlikely(hash == hash_Ip6OutNoRoutes && strsame(name, "Ip6OutNoRoutes") == 0)) ptr = &Ip6OutNoRoutes;
378
+ else if(unlikely(hash == hash_Ip6ReasmTimeout && strsame(name, "Ip6ReasmTimeout") == 0)) ptr = &Ip6ReasmTimeout;
379
+ else if(unlikely(hash == hash_Ip6ReasmReqds && strsame(name, "Ip6ReasmReqds") == 0)) ptr = &Ip6ReasmReqds;
380
+ else if(unlikely(hash == hash_Ip6ReasmOKs && strsame(name, "Ip6ReasmOKs") == 0)) ptr = &Ip6ReasmOKs;
381
+ else if(unlikely(hash == hash_Ip6ReasmFails && strsame(name, "Ip6ReasmFails") == 0)) ptr = &Ip6ReasmFails;
382
+ else if(unlikely(hash == hash_Ip6FragOKs && strsame(name, "Ip6FragOKs") == 0)) ptr = &Ip6FragOKs;
383
+ else if(unlikely(hash == hash_Ip6FragFails && strsame(name, "Ip6FragFails") == 0)) ptr = &Ip6FragFails;
384
+ else if(unlikely(hash == hash_Ip6FragCreates && strsame(name, "Ip6FragCreates") == 0)) ptr = &Ip6FragCreates;
385
+ else if(unlikely(hash == hash_Ip6InMcastPkts && strsame(name, "Ip6InMcastPkts") == 0)) ptr = &Ip6InMcastPkts;
386
+ else if(unlikely(hash == hash_Ip6OutMcastPkts && strsame(name, "Ip6OutMcastPkts") == 0)) ptr = &Ip6OutMcastPkts;
387
+ else if(unlikely(hash == hash_Ip6InOctets && strsame(name, "Ip6InOctets") == 0)) ptr = &Ip6InOctets;
388
+ else if(unlikely(hash == hash_Ip6OutOctets && strsame(name, "Ip6OutOctets") == 0)) ptr = &Ip6OutOctets;
389
+ else if(unlikely(hash == hash_Ip6InMcastOctets && strsame(name, "Ip6InMcastOctets") == 0)) ptr = &Ip6InMcastOctets;
390
+ else if(unlikely(hash == hash_Ip6OutMcastOctets && strsame(name, "Ip6OutMcastOctets") == 0)) ptr = &Ip6OutMcastOctets;
391
+ else if(unlikely(hash == hash_Ip6InBcastOctets && strsame(name, "Ip6InBcastOctets") == 0)) ptr = &Ip6InBcastOctets;
392
+ else if(unlikely(hash == hash_Ip6OutBcastOctets && strsame(name, "Ip6OutBcastOctets") == 0)) ptr = &Ip6OutBcastOctets;
393
+ else if(unlikely(hash == hash_Ip6InNoECTPkts && strsame(name, "Ip6InNoECTPkts") == 0)) ptr = &Ip6InNoECTPkts;
394
+ else if(unlikely(hash == hash_Ip6InECT1Pkts && strsame(name, "Ip6InECT1Pkts") == 0)) ptr = &Ip6InECT1Pkts;
395
+ else if(unlikely(hash == hash_Ip6InECT0Pkts && strsame(name, "Ip6InECT0Pkts") == 0)) ptr = &Ip6InECT0Pkts;
396
+ else if(unlikely(hash == hash_Ip6InCEPkts && strsame(name, "Ip6InCEPkts") == 0)) ptr = &Ip6InCEPkts;
397
+ else if(unlikely(hash == hash_Icmp6InMsgs && strsame(name, "Icmp6InMsgs") == 0)) ptr = &Icmp6InMsgs;
398
+ else if(unlikely(hash == hash_Icmp6InErrors && strsame(name, "Icmp6InErrors") == 0)) ptr = &Icmp6InErrors;
399
+ else if(unlikely(hash == hash_Icmp6OutMsgs && strsame(name, "Icmp6OutMsgs") == 0)) ptr = &Icmp6OutMsgs;
400
+ else if(unlikely(hash == hash_Icmp6OutErrors && strsame(name, "Icmp6OutErrors") == 0)) ptr = &Icmp6OutErrors;
401
+ else if(unlikely(hash == hash_Icmp6InCsumErrors && strsame(name, "Icmp6InCsumErrors") == 0)) ptr = &Icmp6InCsumErrors;
402
+ else if(unlikely(hash == hash_Icmp6InDestUnreachs && strsame(name, "Icmp6InDestUnreachs") == 0)) ptr = &Icmp6InDestUnreachs;
403
+ else if(unlikely(hash == hash_Icmp6InPktTooBigs && strsame(name, "Icmp6InPktTooBigs") == 0)) ptr = &Icmp6InPktTooBigs;
404
+ else if(unlikely(hash == hash_Icmp6InTimeExcds && strsame(name, "Icmp6InTimeExcds") == 0)) ptr = &Icmp6InTimeExcds;
405
+ else if(unlikely(hash == hash_Icmp6InParmProblems && strsame(name, "Icmp6InParmProblems") == 0)) ptr = &Icmp6InParmProblems;
406
+ else if(unlikely(hash == hash_Icmp6InEchos && strsame(name, "Icmp6InEchos") == 0)) ptr = &Icmp6InEchos;
407
+ else if(unlikely(hash == hash_Icmp6InEchoReplies && strsame(name, "Icmp6InEchoReplies") == 0)) ptr = &Icmp6InEchoReplies;
408
+ else if(unlikely(hash == hash_Icmp6InGroupMembQueries && strsame(name, "Icmp6InGroupMembQueries") == 0)) ptr = &Icmp6InGroupMembQueries;
409
+ else if(unlikely(hash == hash_Icmp6InGroupMembResponses && strsame(name, "Icmp6InGroupMembResponses") == 0)) ptr = &Icmp6InGroupMembResponses;
410
+ else if(unlikely(hash == hash_Icmp6InGroupMembReductions && strsame(name, "Icmp6InGroupMembReductions") == 0)) ptr = &Icmp6InGroupMembReductions;
411
+ else if(unlikely(hash == hash_Icmp6InRouterSolicits && strsame(name, "Icmp6InRouterSolicits") == 0)) ptr = &Icmp6InRouterSolicits;
412
+ else if(unlikely(hash == hash_Icmp6InRouterAdvertisements && strsame(name, "Icmp6InRouterAdvertisements") == 0)) ptr = &Icmp6InRouterAdvertisements;
413
+ else if(unlikely(hash == hash_Icmp6InNeighborSolicits && strsame(name, "Icmp6InNeighborSolicits") == 0)) ptr = &Icmp6InNeighborSolicits;
414
+ else if(unlikely(hash == hash_Icmp6InNeighborAdvertisements && strsame(name, "Icmp6InNeighborAdvertisements") == 0)) ptr = &Icmp6InNeighborAdvertisements;
415
+ else if(unlikely(hash == hash_Icmp6InRedirects && strsame(name, "Icmp6InRedirects") == 0)) ptr = &Icmp6InRedirects;
416
+ else if(unlikely(hash == hash_Icmp6InMLDv2Reports && strsame(name, "Icmp6InMLDv2Reports") == 0)) ptr = &Icmp6InMLDv2Reports;
417
+ else if(unlikely(hash == hash_Icmp6OutDestUnreachs && strsame(name, "Icmp6OutDestUnreachs") == 0)) ptr = &Icmp6OutDestUnreachs;
418
+ else if(unlikely(hash == hash_Icmp6OutPktTooBigs && strsame(name, "Icmp6OutPktTooBigs") == 0)) ptr = &Icmp6OutPktTooBigs;
419
+ else if(unlikely(hash == hash_Icmp6OutTimeExcds && strsame(name, "Icmp6OutTimeExcds") == 0)) ptr = &Icmp6OutTimeExcds;
420
+ else if(unlikely(hash == hash_Icmp6OutParmProblems && strsame(name, "Icmp6OutParmProblems") == 0)) ptr = &Icmp6OutParmProblems;
421
+ else if(unlikely(hash == hash_Icmp6OutEchos && strsame(name, "Icmp6OutEchos") == 0)) ptr = &Icmp6OutEchos;
422
+ else if(unlikely(hash == hash_Icmp6OutEchoReplies && strsame(name, "Icmp6OutEchoReplies") == 0)) ptr = &Icmp6OutEchoReplies;
423
+ else if(unlikely(hash == hash_Icmp6OutGroupMembQueries && strsame(name, "Icmp6OutGroupMembQueries") == 0)) ptr = &Icmp6OutGroupMembQueries;
424
+ else if(unlikely(hash == hash_Icmp6OutGroupMembResponses && strsame(name, "Icmp6OutGroupMembResponses") == 0)) ptr = &Icmp6OutGroupMembResponses;
425
+ else if(unlikely(hash == hash_Icmp6OutGroupMembReductions && strsame(name, "Icmp6OutGroupMembReductions") == 0)) ptr = &Icmp6OutGroupMembReductions;
426
+ else if(unlikely(hash == hash_Icmp6OutRouterSolicits && strsame(name, "Icmp6OutRouterSolicits") == 0)) ptr = &Icmp6OutRouterSolicits;
427
+ else if(unlikely(hash == hash_Icmp6OutRouterAdvertisements && strsame(name, "Icmp6OutRouterAdvertisements") == 0)) ptr = &Icmp6OutRouterAdvertisements;
428
+ else if(unlikely(hash == hash_Icmp6OutNeighborSolicits && strsame(name, "Icmp6OutNeighborSolicits") == 0)) ptr = &Icmp6OutNeighborSolicits;
429
+ else if(unlikely(hash == hash_Icmp6OutNeighborAdvertisements && strsame(name, "Icmp6OutNeighborAdvertisements") == 0)) ptr = &Icmp6OutNeighborAdvertisements;
430
+ else if(unlikely(hash == hash_Icmp6OutRedirects && strsame(name, "Icmp6OutRedirects") == 0)) ptr = &Icmp6OutRedirects;
431
+ else if(unlikely(hash == hash_Icmp6OutMLDv2Reports && strsame(name, "Icmp6OutMLDv2Reports") == 0)) ptr = &Icmp6OutMLDv2Reports;
432
+ else if(unlikely(hash == hash_Icmp6InType1 && strsame(name, "Icmp6InType1") == 0)) ptr = &Icmp6InType1;
433
+ else if(unlikely(hash == hash_Icmp6InType128 && strsame(name, "Icmp6InType128") == 0)) ptr = &Icmp6InType128;
434
+ else if(unlikely(hash == hash_Icmp6InType129 && strsame(name, "Icmp6InType129") == 0)) ptr = &Icmp6InType129;
435
+ else if(unlikely(hash == hash_Icmp6InType136 && strsame(name, "Icmp6InType136") == 0)) ptr = &Icmp6InType136;
436
+ else if(unlikely(hash == hash_Icmp6OutType1 && strsame(name, "Icmp6OutType1") == 0)) ptr = &Icmp6OutType1;
437
+ else if(unlikely(hash == hash_Icmp6OutType128 && strsame(name, "Icmp6OutType128") == 0)) ptr = &Icmp6OutType128;
438
+ else if(unlikely(hash == hash_Icmp6OutType129 && strsame(name, "Icmp6OutType129") == 0)) ptr = &Icmp6OutType129;
439
+ else if(unlikely(hash == hash_Icmp6OutType133 && strsame(name, "Icmp6OutType133") == 0)) ptr = &Icmp6OutType133;
440
+ else if(unlikely(hash == hash_Icmp6OutType135 && strsame(name, "Icmp6OutType135") == 0)) ptr = &Icmp6OutType135;
441
+ else if(unlikely(hash == hash_Icmp6OutType143 && strsame(name, "Icmp6OutType143") == 0)) ptr = &Icmp6OutType143;
442
+ else if(unlikely(hash == hash_Udp6InDatagrams && strsame(name, "Udp6InDatagrams") == 0)) ptr = &Udp6InDatagrams;
443
+ else if(unlikely(hash == hash_Udp6NoPorts && strsame(name, "Udp6NoPorts") == 0)) ptr = &Udp6NoPorts;
444
+ else if(unlikely(hash == hash_Udp6InErrors && strsame(name, "Udp6InErrors") == 0)) ptr = &Udp6InErrors;
445
+ else if(unlikely(hash == hash_Udp6OutDatagrams && strsame(name, "Udp6OutDatagrams") == 0)) ptr = &Udp6OutDatagrams;
446
+ else if(unlikely(hash == hash_Udp6RcvbufErrors && strsame(name, "Udp6RcvbufErrors") == 0)) ptr = &Udp6RcvbufErrors;
447
+ else if(unlikely(hash == hash_Udp6SndbufErrors && strsame(name, "Udp6SndbufErrors") == 0)) ptr = &Udp6SndbufErrors;
448
+ else if(unlikely(hash == hash_Udp6InCsumErrors && strsame(name, "Udp6InCsumErrors") == 0)) ptr = &Udp6InCsumErrors;
449
+ else if(unlikely(hash == hash_Udp6IgnoredMulti && strsame(name, "Udp6IgnoredMulti") == 0)) ptr = &Udp6IgnoredMulti;
450
+ else if(unlikely(hash == hash_UdpLite6InDatagrams && strsame(name, "UdpLite6InDatagrams") == 0)) ptr = &UdpLite6InDatagrams;
451
+ else if(unlikely(hash == hash_UdpLite6NoPorts && strsame(name, "UdpLite6NoPorts") == 0)) ptr = &UdpLite6NoPorts;
452
+ else if(unlikely(hash == hash_UdpLite6InErrors && strsame(name, "UdpLite6InErrors") == 0)) ptr = &UdpLite6InErrors;
453
+ else if(unlikely(hash == hash_UdpLite6OutDatagrams && strsame(name, "UdpLite6OutDatagrams") == 0)) ptr = &UdpLite6OutDatagrams;
454
+ else if(unlikely(hash == hash_UdpLite6RcvbufErrors && strsame(name, "UdpLite6RcvbufErrors") == 0)) ptr = &UdpLite6RcvbufErrors;
455
+ else if(unlikely(hash == hash_UdpLite6SndbufErrors && strsame(name, "UdpLite6SndbufErrors") == 0)) ptr = &UdpLite6SndbufErrors;
456
+ else if(unlikely(hash == hash_UdpLite6InCsumErrors && strsame(name, "UdpLite6InCsumErrors") == 0)) ptr = &UdpLite6InCsumErrors;
457
458
if(unlikely(ptr)) {
459
*ptr = str2ull(value);
src/proc_net_softnet_stat.c
+8
-7
@@ -1,6 +1,6 @@
1
#include "common.h"
2
3
-static inline char *softnet_column_name(uint32_t column) {
3
+static inline char *softnet_column_name(size_t column) {
4
switch(column) {
5
// https://github.com/torvalds/linux/blob/a7fd20d1c476af4563e66865213474a2f9f473a4/net/core/net-procfs.c#L161-L166
6
case 0: return "processed";
@@ -17,7 +17,8 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) {
17
18
static procfile *ff = NULL;
19
static int do_per_core = -1;
20
- static uint32_t allocated_lines = 0, allocated_columns = 0, *data = NULL;
20
+ static size_t allocated_lines = 0, allocated_columns = 0;
21
+ static uint32_t *data = NULL;
22
23
if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", 1);
24
@@ -31,11 +32,11 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) {
32
ff = procfile_readall(ff);
33
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
34
34
- uint32_t lines = procfile_lines(ff), l;
35
- uint32_t words = procfile_linewords(ff, 0), w;
35
+ size_t lines = procfile_lines(ff), l;
36
+ size_t words = procfile_linewords(ff, 0), w;
37
38
if(unlikely(!lines || !words)) {
38
- error("Cannot read /proc/net/softnet_stat, %u lines and %u columns reported.", lines, words);
39
+ error("Cannot read /proc/net/softnet_stat, %zu lines and %zu columns reported.", lines, words);
40
return 1;
41
}
42
@@ -94,12 +95,12 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) {
95
if(do_per_core) {
96
for(l = 0; l < lines ;l++) {
97
char id[50+1];
97
- snprintfz(id, 50, "cpu%u_softnet_stat", l);
98
+ snprintfz(id, 50, "cpu%zu_softnet_stat", l);
99
100
st = rrdset_find_bytype("cpu", id);
101
if(unlikely(!st)) {
102
char title[100+1];
102
- snprintfz(title, 100, "CPU%u softnet_stat", l);
103
+ snprintfz(title, 100, "CPU%zu softnet_stat", l);
104
105
st = rrdset_create("cpu", id, NULL, "softnet_stat", NULL, title, "events/s", 4101 + l, update_every, RRDSET_TYPE_LINE);
106
for(w = 0; w < allocated_columns ;w++)
src/proc_net_stat_conntrack.c
+3
-3
@@ -61,12 +61,12 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) {
61
if(unlikely(!ff))
62
return 0; // we return 0, so that we will retry to open it next time
63
64
- uint32_t lines = procfile_lines(ff), l;
64
+ size_t lines = procfile_lines(ff), l;
65
66
for(l = 1; l < lines ;l++) {
67
- uint32_t words = procfile_linewords(ff, l);
67
+ size_t words = procfile_linewords(ff, l);
68
if(unlikely(words < 17)) {
69
- if(unlikely(words)) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
69
+ if(unlikely(words)) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %zu.", words);
70
continue;
71
}
72
src/proc_net_stat_synproxy.c
+1
-1
@@ -39,7 +39,7 @@ int do_proc_net_stat_synproxy(int update_every, usec_t dt) {
39
40
// synproxy gives its values per CPU
41
for(l = 1; l < lines ;l++) {
42
- int words = procfile_linewords(ff, l);
42
+ size_t words = procfile_linewords(ff, l);
43
if(unlikely(words < 6))
44
continue;
45
src/proc_self_mountinfo.c
+30
-30
@@ -7,39 +7,39 @@
7
/* A file system is "remote" if its Fs_name contains a ':'
8
or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
9
or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). */
10
-# define ME_REMOTE(Fs_name, Fs_type) \
11
- (strchr (Fs_name, ':') != NULL \
12
- || ((Fs_name)[0] == '/' \
13
- && (Fs_name)[1] == '/' \
14
- && (strcmp (Fs_type, "smbfs") == 0 \
15
- || strcmp (Fs_type, "cifs") == 0)) \
16
- || (strcmp("-hosts", Fs_name) == 0))
10
+# define ME_REMOTE(Fs_name, Fs_type) \
11
+ (strchr (Fs_name, ':') != NULL \
12
+ || ((Fs_name)[0] == '/' \
13
+ && (Fs_name)[1] == '/' \
14
+ && (strsame (Fs_type, "smbfs") == 0 \
15
+ || strsame (Fs_type, "cifs") == 0)) \
16
+ || (strsame("-hosts", Fs_name) == 0))
17
#endif
18
19
-#define ME_DUMMY_0(Fs_name, Fs_type) \
20
- (strcmp (Fs_type, "autofs") == 0 \
21
- || strcmp (Fs_type, "proc") == 0 \
22
- || strcmp (Fs_type, "subfs") == 0 \
23
- /* for Linux 2.6/3.x */ \
24
- || strcmp (Fs_type, "debugfs") == 0 \
25
- || strcmp (Fs_type, "devpts") == 0 \
26
- || strcmp (Fs_type, "fusectl") == 0 \
27
- || strcmp (Fs_type, "mqueue") == 0 \
28
- || strcmp (Fs_type, "rpc_pipefs") == 0 \
29
- || strcmp (Fs_type, "sysfs") == 0 \
30
- /* FreeBSD, Linux 2.4 */ \
31
- || strcmp (Fs_type, "devfs") == 0 \
32
- /* for NetBSD 3.0 */ \
33
- || strcmp (Fs_type, "kernfs") == 0 \
34
- /* for Irix 6.5 */ \
35
- || strcmp (Fs_type, "ignore") == 0)
19
+#define ME_DUMMY_0(Fs_name, Fs_type) \
20
+ (strsame (Fs_type, "autofs") == 0 \
21
+ || strsame (Fs_type, "proc") == 0 \
22
+ || strsame (Fs_type, "subfs") == 0 \
23
+ /* for Linux 2.6/3.x */ \
24
+ || strsame (Fs_type, "debugfs") == 0 \
25
+ || strsame (Fs_type, "devpts") == 0 \
26
+ || strsame (Fs_type, "fusectl") == 0 \
27
+ || strsame (Fs_type, "mqueue") == 0 \
28
+ || strsame (Fs_type, "rpc_pipefs") == 0 \
29
+ || strsame (Fs_type, "sysfs") == 0 \
30
+ /* FreeBSD, Linux 2.4 */ \
31
+ || strsame (Fs_type, "devfs") == 0 \
32
+ /* for NetBSD 3.0 */ \
33
+ || strsame (Fs_type, "kernfs") == 0 \
34
+ /* for Irix 6.5 */ \
35
+ || strsame (Fs_type, "ignore") == 0)
36
37
/* Historically, we have marked as "dummy" any file system of type "none",
38
but now that programs like du need to know about bind-mounted directories,
39
we grant an exception to any with "bind" in its list of mount options.
40
I.e., those are *not* dummy entries. */
41
# define ME_DUMMY(Fs_name, Fs_type) \
42
- (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
42
+ (ME_DUMMY_0 (Fs_name, Fs_type) || strsame (Fs_type, "none") == 0)
43
44
// ----------------------------------------------------------------------------
45
@@ -66,8 +66,8 @@ struct mountinfo *mountinfo_find_by_filesystem_mount_source(struct mountinfo *ro
66
&& mi->mount_source
67
&& mi->filesystem_hash == filesystem_hash
68
&& mi->mount_source_hash == mount_source_hash
69
- && !strcmp(mi->filesystem, filesystem)
70
- && !strcmp(mi->mount_source, mount_source)))
69
+ && !strsame(mi->filesystem, filesystem)
70
+ && !strsame(mi->mount_source, mount_source)))
71
return mi;
72
73
return NULL;
@@ -83,7 +83,7 @@ struct mountinfo *mountinfo_find_by_filesystem_super_option(struct mountinfo *ro
83
if(unlikely(mi->filesystem
84
&& mi->super_options
85
&& mi->filesystem_hash == filesystem_hash
86
- && !strcmp(mi->filesystem, filesystem))) {
86
+ && !strsame(mi->filesystem, filesystem))) {
87
88
// super_options is a comma separated list
89
char *s = mi->super_options, *e;
@@ -163,7 +163,7 @@ static inline int is_read_only(const char *s) {
163
size_t len = strlen(s);
164
if(len < 2) return 0;
165
if(len == 2) {
166
- if(!strcmp(s, "ro")) return 1;
166
+ if(!strsame(s, "ro")) return 1;
167
return 0;
168
}
169
if(!strncmp(s, "ro,", 3)) return 1;
@@ -376,7 +376,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
376
if(unlikely(bind)) {
377
struct mountinfo *mi;
378
for(mi = root; mi ; mi = mi->next) {
379
- if(unlikely(strcmp(mnt->mnt_dir, mi->mount_point) == 0)) {
379
+ if(unlikely(strsame(mnt->mnt_dir, mi->mount_point) == 0)) {
380
fprintf(stderr, "Mount point '%s' is BIND\n", mi->mount_point);
381
mi->flags |= MOUNTINFO_IS_BIND;
382
break;
src/proc_softirqs.c
+6
-6
@@ -23,9 +23,9 @@ struct interrupt {
23
// given a base, get a pointer to each record
24
#define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[line * recordsize(cpus)])
25
26
-static inline struct interrupt *get_interrupts_array(uint32_t lines, int cpus) {
26
+static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) {
27
static struct interrupt *irrs = NULL;
28
- static uint32_t allocated = 0;
28
+ static size_t allocated = 0;
29
30
if(unlikely(lines != allocated)) {
31
uint32_t l;
@@ -66,8 +66,8 @@ int do_proc_softirqs(int update_every, usec_t dt) {
66
ff = procfile_readall(ff);
67
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
68
69
- uint32_t lines = procfile_lines(ff), l;
70
- uint32_t words = procfile_linewords(ff, 0);
69
+ size_t lines = procfile_lines(ff), l;
70
+ size_t words = procfile_linewords(ff, 0);
71
72
if(unlikely(!lines)) {
73
error("Cannot read /proc/softirqs, zero lines reported.");
@@ -105,8 +105,8 @@ int do_proc_softirqs(int update_every, usec_t dt) {
105
irr->id = procfile_lineword(ff, l, 0);
106
if(unlikely(!irr->id || !irr->id[0])) continue;
107
108
- int idlen = strlen(irr->id);
109
- if(unlikely(irr->id[idlen - 1] == ':'))
108
+ size_t idlen = strlen(irr->id);
109
+ if(unlikely(idlen && irr->id[idlen - 1] == ':'))
110
irr->id[idlen - 1] = '\0';
111
112
int c;
src/proc_stat.c
+9
-9
@@ -32,8 +32,8 @@ int do_proc_stat(int update_every, usec_t dt) {
32
ff = procfile_readall(ff);
33
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
34
35
- uint32_t lines = procfile_lines(ff), l;
36
- uint32_t words;
35
+ size_t lines = procfile_lines(ff), l;
36
+ size_t words;
37
38
unsigned long long processes = 0, running = 0 , blocked = 0;
39
RRDSET *st;
@@ -46,7 +46,7 @@ int do_proc_stat(int update_every, usec_t dt) {
46
if(likely(row_key[0] == 'c' && row_key[1] == 'p' && row_key[2] == 'u')) {
47
words = procfile_linewords(ff, l);
48
if(unlikely(words < 9)) {
49
- error("Cannot read /proc/stat cpu line. Expected 9 params, read %u.", words);
49
+ error("Cannot read /proc/stat cpu line. Expected 9 params, read %zu.", words);
50
continue;
51
}
52
@@ -73,7 +73,7 @@ int do_proc_stat(int update_every, usec_t dt) {
73
long priority;
74
int isthistotal;
75
76
- if(unlikely(strcmp(id, "cpu")) == 0) {
76
+ if(unlikely(strsame(id, "cpu")) == 0) {
77
title = "Total CPU utilization";
78
type = "system";
79
context = "system.cpu";
@@ -126,7 +126,7 @@ int do_proc_stat(int update_every, usec_t dt) {
126
rrdset_done(st);
127
}
128
}
129
- else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) {
129
+ else if(unlikely(hash == hash_intr && strsame(row_key, "intr") == 0)) {
130
unsigned long long value = str2ull(procfile_lineword(ff, l, 1));
131
132
// --------------------------------------------------------------------
@@ -145,7 +145,7 @@ int do_proc_stat(int update_every, usec_t dt) {
145
rrdset_done(st);
146
}
147
}
148
- else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) {
148
+ else if(unlikely(hash == hash_ctxt && strsame(row_key, "ctxt") == 0)) {
149
unsigned long long value = str2ull(procfile_lineword(ff, l, 1));
150
151
// --------------------------------------------------------------------
@@ -163,13 +163,13 @@ int do_proc_stat(int update_every, usec_t dt) {
163
rrdset_done(st);
164
}
165
}
166
- else if(unlikely(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0)) {
166
+ else if(unlikely(hash == hash_processes && !processes && strsame(row_key, "processes") == 0)) {
167
processes = str2ull(procfile_lineword(ff, l, 1));
168
}
169
- else if(unlikely(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0)) {
169
+ else if(unlikely(hash == hash_procs_running && !running && strsame(row_key, "procs_running") == 0)) {
170
running = str2ull(procfile_lineword(ff, l, 1));
171
}
172
- else if(unlikely(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0)) {
172
+ else if(unlikely(hash == hash_procs_blocked && !blocked && strsame(row_key, "procs_blocked") == 0)) {
173
blocked = str2ull(procfile_lineword(ff, l, 1));
174
}
175
}
src/proc_vmstat.c
+3
-3
@@ -71,13 +71,13 @@ int do_proc_vmstat(int update_every, usec_t dt) {
71
ff = procfile_readall(ff);
72
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
73
74
- uint32_t lines = procfile_lines(ff), l;
74
+ size_t lines = procfile_lines(ff), l;
75
76
arl_begin(arl_base);
77
for(l = 0; l < lines ;l++) {
78
- uint32_t words = procfile_linewords(ff, l);
78
+ size_t words = procfile_linewords(ff, l);
79
if(unlikely(words < 2)) {
80
- if(unlikely(words)) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
80
+ if(unlikely(words)) error("Cannot read /proc/vmstat line %zu. Expected 2 params, read %zu.", l, words);
81
continue;
82
}
83
src/procfile.c
+39
-61
@@ -1,4 +1,5 @@
1
#include "common.h"
2
+#include "procfile.h"
3
4
#define PF_PREFIX "PROCFILE"
5
@@ -10,15 +11,15 @@ int procfile_adaptive_initial_allocation = 0;
11
12
// if adaptive allocation is set, these store the
13
// max values we have seen so far
13
-uint32_t procfile_max_lines = PFLINES_INCREASE_STEP;
14
-uint32_t procfile_max_words = PFWORDS_INCREASE_STEP;
14
+size_t procfile_max_lines = PFLINES_INCREASE_STEP;
15
+size_t procfile_max_words = PFWORDS_INCREASE_STEP;
16
size_t procfile_max_allocation = PROCFILE_INCREMENT_BUFFER;
17
18
// ----------------------------------------------------------------------------
19
// An array of words
20
20
-
21
-pfwords *pfwords_add(pfwords *fw, char *str) {
21
+static inline pfwords *pfwords_add(pfwords *fw, char *str) NEVERNULL;
22
+static inline pfwords *pfwords_add(pfwords *fw, char *str) {
23
// debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str);
24
25
if(unlikely(fw->len == fw->size)) {
@@ -33,10 +34,11 @@ pfwords *pfwords_add(pfwords *fw, char *str) {
34
return fw;
35
}
36
36
-pfwords *pfwords_new(void) {
37
+static inline pfwords *pfwords_new(void) NEVERNULL;
38
+static inline pfwords *pfwords_new(void) {
39
// debug(D_PROCFILE, PF_PREFIX ": initializing words");
40
39
- uint32_t size = (procfile_adaptive_initial_allocation) ? procfile_max_words : PFWORDS_INCREASE_STEP;
41
+ size_t size = (procfile_adaptive_initial_allocation) ? procfile_max_words : PFWORDS_INCREASE_STEP;
42
43
pfwords *new = mallocz(sizeof(pfwords) + size * sizeof(char *));
44
new->len = 0;
@@ -44,12 +46,12 @@ pfwords *pfwords_new(void) {
46
return new;
47
}
48
47
-void pfwords_reset(pfwords *fw) {
49
+static inline void pfwords_reset(pfwords *fw) {
50
// debug(D_PROCFILE, PF_PREFIX ": reseting words");
51
fw->len = 0;
52
}
53
52
-void pfwords_free(pfwords *fw) {
54
+static inline void pfwords_free(pfwords *fw) {
55
// debug(D_PROCFILE, PF_PREFIX ": freeing words");
56
57
freez(fw);
@@ -59,7 +61,8 @@ void pfwords_free(pfwords *fw) {
61
// ----------------------------------------------------------------------------
62
// An array of lines
63
62
-pflines *pflines_add(pflines *fl, uint32_t first_word) {
64
+static inline pflines *pflines_add(pflines *fl, size_t first_word) NEVERNULL;
65
+static inline pflines *pflines_add(pflines *fl, size_t first_word) {
66
// debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word);
67
68
if(unlikely(fl->len == fl->size)) {
@@ -75,10 +78,11 @@ pflines *pflines_add(pflines *fl, uint32_t first_word) {
78
return fl;
79
}
80
78
-pflines *pflines_new(void) {
81
+static inline pflines *pflines_new(void) NEVERNULL;
82
+static inline pflines *pflines_new(void) {
83
// debug(D_PROCFILE, PF_PREFIX ": initializing lines");
84
81
- uint32_t size = (unlikely(procfile_adaptive_initial_allocation)) ? procfile_max_words : PFLINES_INCREASE_STEP;
85
+ size_t size = (unlikely(procfile_adaptive_initial_allocation)) ? procfile_max_words : PFLINES_INCREASE_STEP;
86
87
pflines *new = mallocz(sizeof(pflines) + size * sizeof(ffline));
88
new->len = 0;
@@ -86,13 +90,13 @@ pflines *pflines_new(void) {
90
return new;
91
}
92
89
-void pflines_reset(pflines *fl) {
93
+static inline void pflines_reset(pflines *fl) {
94
// debug(D_PROCFILE, PF_PREFIX ": reseting lines");
95
96
fl->len = 0;
97
}
98
95
-void pflines_free(pflines *fl) {
99
+static inline void pflines_free(pflines *fl) {
100
// debug(D_PROCFILE, PF_PREFIX ": freeing lines");
101
102
freez(fl);
@@ -119,20 +123,20 @@ void procfile_close(procfile *ff) {
123
freez(ff);
124
}
125
122
-procfile *procfile_parser(procfile *ff) {
123
- debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
126
+static inline void procfile_parser(procfile *ff) {
127
+ // debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
128
125
- char *s = ff->data, *e = &ff->data[ff->len], *t = ff->data, quote = 0;
126
- uint32_t l = 0, w = 0;
127
- int opened = 0;
129
+ register char *s = ff->data, *e = &ff->data[ff->len], *t = ff->data;
130
+ register char *separators = ff->separators;
131
+ char quote = 0;
132
+ size_t l = 0, w = 0, opened = 0;
133
134
ff->lines = pflines_add(ff->lines, w);
130
- if(unlikely(!ff->lines)) goto cleanup;
135
136
while(likely(s < e)) {
137
// we are not at the end
138
135
- switch(ff->separators[(uint8_t)(*s)]) {
139
+ switch(separators[(unsigned char)(*s)]) {
140
case PF_CHAR_IS_OPEN:
141
if(s == t) {
142
opened++;
@@ -144,7 +148,7 @@ procfile *procfile_parser(procfile *ff) {
148
}
149
else
150
s++;
147
- continue;
151
+ break;
152
153
case PF_CHAR_IS_CLOSE:
154
if(opened) {
@@ -153,8 +157,6 @@ procfile *procfile_parser(procfile *ff) {
157
if(!opened) {
158
*s = '\0';
159
ff->words = pfwords_add(ff->words, t);
156
- if(unlikely(!ff->words)) goto cleanup;
157
-
160
ff->lines->lines[l].words++;
161
w++;
162
@@ -165,7 +167,7 @@ procfile *procfile_parser(procfile *ff) {
167
}
168
else
169
s++;
168
- continue;
170
+ break;
171
172
case PF_CHAR_IS_QUOTE:
173
if(unlikely(!quote && s == t)) {
@@ -179,8 +181,6 @@ procfile *procfile_parser(procfile *ff) {
181
182
*s = '\0';
183
ff->words = pfwords_add(ff->words, t);
182
- if(unlikely(!ff->words)) goto cleanup;
183
-
184
ff->lines->lines[l].words++;
185
w++;
186
@@ -188,55 +188,50 @@ procfile *procfile_parser(procfile *ff) {
188
}
189
else
190
s++;
191
- continue;
191
+ break;
192
193
case PF_CHAR_IS_SEPARATOR:
194
if(unlikely(quote || opened)) {
195
// we are inside a quote
196
s++;
197
- continue;
197
+ break;
198
}
199
200
if(unlikely(s == t)) {
201
// skip all leading white spaces
202
t = ++s;
203
- continue;
203
+ break;
204
}
205
206
// end of word
207
*s = '\0';
208
209
ff->words = pfwords_add(ff->words, t);
210
- if(unlikely(!ff->words)) goto cleanup;
211
-
210
ff->lines->lines[l].words++;
211
w++;
212
213
t = ++s;
216
- continue;
214
+ break;
215
216
case PF_CHAR_IS_NEWLINE:
217
// end of line
218
*s = '\0';
219
220
ff->words = pfwords_add(ff->words, t);
223
- if(unlikely(!ff->words)) goto cleanup;
224
-
221
ff->lines->lines[l].words++;
222
w++;
223
224
// debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words);
225
226
ff->lines = pflines_add(ff->lines, w);
231
- if(unlikely(!ff->lines)) goto cleanup;
227
l++;
228
229
t = ++s;
235
- continue;
230
+ break;
231
232
default:
233
s++;
239
- continue;
234
+ break;
235
}
236
}
237
@@ -250,18 +245,8 @@ procfile *procfile_parser(procfile *ff) {
245
}
246
247
ff->words = pfwords_add(ff->words, t);
253
- if(unlikely(!ff->words)) goto cleanup;
254
-
248
ff->lines->lines[l].words++;
256
- w++;
249
}
258
-
259
- return ff;
260
-
261
-cleanup:
262
- error(PF_PREFIX ": Failed to parse file '%s'", ff->filename);
263
- procfile_close(ff);
264
- return NULL;
250
}
251
252
procfile *procfile_readall(procfile *ff) {
@@ -301,8 +286,7 @@ procfile *procfile_readall(procfile *ff) {
286
287
pflines_reset(ff->lines);
288
pfwords_reset(ff->words);
304
-
305
- ff = procfile_parser(ff);
289
+ procfile_parser(ff);
290
291
if(unlikely(procfile_adaptive_initial_allocation)) {
292
if(unlikely(ff->len > procfile_max_allocation)) procfile_max_allocation = ff->len;
@@ -405,12 +389,6 @@ procfile *procfile_open(const char *filename, const char *separators, uint32_t f
389
ff->lines = pflines_new();
390
ff->words = pfwords_new();
391
408
- if(unlikely(!ff->lines || !ff->words)) {
409
- error(PF_PREFIX ": Cannot initialize parser for file '%s'", filename);
410
- procfile_close(ff);
411
- return NULL;
412
- }
413
-
392
procfile_set_separators(ff, separators);
393
394
debug(D_PROCFILE, "File '%s' opened.", filename);
@@ -442,20 +420,20 @@ procfile *procfile_reopen(procfile *ff, const char *filename, const char *separa
420
// example parsing of procfile data
421
422
void procfile_print(procfile *ff) {
445
- uint32_t lines = procfile_lines(ff), l;
423
+ size_t lines = procfile_lines(ff), l;
424
char *s;
425
448
- debug(D_PROCFILE, "File '%s' with %u lines and %u words", ff->filename, ff->lines->len, ff->words->len);
426
+ debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", ff->filename, ff->lines->len, ff->words->len);
427
428
for(l = 0; likely(l < lines) ;l++) {
451
- uint32_t words = procfile_linewords(ff, l);
429
+ size_t words = procfile_linewords(ff, l);
430
453
- debug(D_PROCFILE, " line %u starts at word %u and has %u words", l, ff->lines->lines[l].first, ff->lines->lines[l].words);
431
+ debug(D_PROCFILE, " line %zu starts at word %zu and has %zu words", l, ff->lines->lines[l].first, ff->lines->lines[l].words);
432
455
- uint32_t w;
433
+ size_t w;
434
for(w = 0; likely(w < words) ;w++) {
435
s = procfile_lineword(ff, l, w);
458
- debug(D_PROCFILE, " [%u.%u] '%s'", l, w, s);
436
+ debug(D_PROCFILE, " [%zu.%zu] '%s'", l, w, s);
437
}
438
}
439
}
src/procfile.h
+12
-12
@@ -30,8 +30,8 @@
30
// An array of words
31
32
typedef struct {
33
- uint32_t len; // used entries
34
- uint32_t size; // capacity
33
+ size_t len; // used entries
34
+ size_t size; // capacity
35
char *words[]; // array of pointers
36
} pfwords;
37
@@ -40,15 +40,15 @@ typedef struct {
40
// An array of lines
41
42
typedef struct {
43
- uint32_t words; // how many words this line has
44
- uint32_t first; // the id of the first word of this line
45
- // in the words array
43
+ size_t words; // how many words this line has
44
+ size_t first; // the id of the first word of this line
45
+ // in the words array
46
} ffline;
47
48
typedef struct {
49
- uint32_t len; // used entries
50
- uint32_t size; // capacity
51
- ffline lines[]; // array of lines
49
+ size_t len; // used entries
50
+ size_t size; // capacity
51
+ ffline lines[]; // array of lines
52
} pflines;
53
54
@@ -61,13 +61,13 @@ typedef struct {
61
typedef struct {
62
char filename[FILENAME_MAX + 1];
63
uint32_t flags;
64
- int fd; // the file desriptor
65
- size_t len; // the bytes we have placed into data
66
- size_t size; // the bytes we have allocated for data
64
+ int fd; // the file desriptor
65
+ size_t len; // the bytes we have placed into data
66
+ size_t size; // the bytes we have allocated for data
67
pflines *lines;
68
pfwords *words;
69
char separators[256];
70
- char data[]; // allocated buffer to keep file contents
70
+ char data[]; // allocated buffer to keep file contents
71
} procfile;
72
73
// close the proc file and free all related memory
src/registry.c
+1
-1
@@ -158,7 +158,7 @@ int registry_request_access_json(struct web_client *w, char *person_guid, char *
158
return 200;
159
}
160
161
- if(unlikely(person_guid[0] && !strcmp(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
161
+ if(unlikely(person_guid[0] && !strsame(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
162
person_guid[0] = '\0';
163
164
// ------------------------------------------------------------------------
src/registry_internals.c
+4
-4
@@ -17,7 +17,7 @@ int registry_regenerate_guid(const char *guid, char *result) {
17
uuid_unparse_lower(uuid, result);
18
19
#ifdef NETDATA_INTERNAL_CHECKS
20
- if(strcmp(guid, result))
20
+ if(strsame(guid, result))
21
info("Registry: source GUID '%s' and re-generated GUID '%s' differ!", guid, result);
22
#endif /* NETDATA_INTERNAL_CHECKS */
23
}
@@ -175,7 +175,7 @@ REGISTRY_PERSON *registry_request_delete(char *person_guid, char *machine_guid,
175
delete_url = registry_fix_url(delete_url, NULL);
176
177
// make sure the user is not deleting the url it uses
178
- if(!strcmp(delete_url, pu->url->url)) {
178
+ if(!strsame(delete_url, pu->url->url)) {
179
info("Registry Delete Request: delete URL is the one currently accessed, person: '%s', machine '%s', url '%s', delete url '%s'"
180
, p->guid, m->guid, pu->url->url, delete_url);
181
return NULL;
@@ -264,8 +264,8 @@ static inline int is_machine_guid_blacklisted(const char *guid) {
264
// we blacklist them here, so that the next version of netdata will generate
265
// new ones.
266
267
- if(!strcmp(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
268
- || !strcmp(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
267
+ if(!strsame(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
268
+ || !strsame(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
269
) {
270
error("Blacklisted machine GUID '%s' found.", guid);
271
return 1;
src/registry_person.c
+2
-2
@@ -9,7 +9,7 @@ int person_url_compare(void *a, void *b) {
9
10
if(hash1 < hash2) return -1;
11
else if(hash1 > hash2) return 1;
12
- else return strcmp(((REGISTRY_PERSON_URL *)a)->url->url, ((REGISTRY_PERSON_URL *)b)->url->url);
12
+ else return strsame(((REGISTRY_PERSON_URL *)a)->url->url, ((REGISTRY_PERSON_URL *)b)->url->url);
13
}
14
15
inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, const char *url) {
@@ -242,7 +242,7 @@ REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MA
242
pu->machine = m;
243
}
244
245
- if(strcmp(pu->machine_name, name)) {
245
+ if(strsame(pu->machine_name, name)) {
246
// the name of the PERSON_URL has changed !
247
pu = registry_person_url_reallocate(p, m, u, name, namelen, when, pu);
248
}
src/registry_url.c
+1
-1
@@ -6,7 +6,7 @@
6
int registry_url_compare(void *a, void *b) {
7
if(((REGISTRY_URL *)a)->hash < ((REGISTRY_URL *)b)->hash) return -1;
8
else if(((REGISTRY_URL *)a)->hash > ((REGISTRY_URL *)b)->hash) return 1;
9
- else return strcmp(((REGISTRY_URL *)a)->url, ((REGISTRY_URL *)b)->url);
9
+ else return strsame(((REGISTRY_URL *)a)->url, ((REGISTRY_URL *)b)->url);
10
}
11
12
inline REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) {
src/rrd.c
+21
-21
@@ -91,7 +91,7 @@ void rrdhost_check_wrlock_int(RRDHOST *host, const char *file, const char *funct
91
static int rrdfamily_compare(void *a, void *b) {
92
if(((RRDFAMILY *)a)->hash_family < ((RRDFAMILY *)b)->hash_family) return -1;
93
else if(((RRDFAMILY *)a)->hash_family > ((RRDFAMILY *)b)->hash_family) return 1;
94
- else return strcmp(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
94
+ else return strsame(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
95
}
96
97
#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
@@ -146,7 +146,7 @@ void rrdfamily_free(RRDFAMILY *rc) {
146
static int rrdset_compare(void* a, void* b) {
147
if(((RRDSET *)a)->hash < ((RRDSET *)b)->hash) return -1;
148
else if(((RRDSET *)a)->hash > ((RRDSET *)b)->hash) return 1;
149
- else return strcmp(((RRDSET *)a)->id, ((RRDSET *)b)->id);
149
+ else return strsame(((RRDSET *)a)->id, ((RRDSET *)b)->id);
150
}
151
152
#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
@@ -173,7 +173,7 @@ static int rrdset_compare_name(void* a, void* b) {
173
174
if(A->hash_name < B->hash_name) return -1;
175
else if(A->hash_name > B->hash_name) return 1;
176
- else return strcmp(A->name, B->name);
176
+ else return strsame(A->name, B->name);
177
}
178
179
RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
@@ -202,7 +202,7 @@ static RRDSET *rrdset_index_find_name(RRDHOST *host, const char *name, uint32_t
202
result = avl_search_lock(&host->rrdset_root_index_name, (avl *) (&(tmp.avlname)));
203
if(result) {
204
RRDSET *st = rrdset_from_avlname(result);
205
- if(strcmp(st->magic, RRDSET_MAGIC))
205
+ if(strsame(st->magic, RRDSET_MAGIC))
206
error("Search for RRDSET %s returned an invalid RRDSET %s (name %s)", name, st->id, st->name);
207
208
// fprintf(stderr, "FOUND: %s\n", name);
@@ -219,7 +219,7 @@ static RRDSET *rrdset_index_find_name(RRDHOST *host, const char *name, uint32_t
219
static int rrddim_compare(void* a, void* b) {
220
if(((RRDDIM *)a)->hash < ((RRDDIM *)b)->hash) return -1;
221
else if(((RRDDIM *)a)->hash > ((RRDDIM *)b)->hash) return 1;
222
- else return strcmp(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
222
+ else return strsame(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
223
}
224
225
#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl *)(rd))
@@ -238,9 +238,9 @@ static RRDDIM *rrddim_index_find(RRDSET *st, const char *id, uint32_t hash) {
238
239
int rrdset_type_id(const char *name)
240
{
241
- if(unlikely(strcmp(name, RRDSET_TYPE_AREA_NAME) == 0)) return RRDSET_TYPE_AREA;
242
- else if(unlikely(strcmp(name, RRDSET_TYPE_STACKED_NAME) == 0)) return RRDSET_TYPE_STACKED;
243
- else if(unlikely(strcmp(name, RRDSET_TYPE_LINE_NAME) == 0)) return RRDSET_TYPE_LINE;
241
+ if(unlikely(strsame(name, RRDSET_TYPE_AREA_NAME) == 0)) return RRDSET_TYPE_AREA;
242
+ else if(unlikely(strsame(name, RRDSET_TYPE_STACKED_NAME) == 0)) return RRDSET_TYPE_STACKED;
243
+ else if(unlikely(strsame(name, RRDSET_TYPE_LINE_NAME) == 0)) return RRDSET_TYPE_LINE;
244
return RRDSET_TYPE_LINE;
245
}
246
@@ -289,9 +289,9 @@ const char *rrd_memory_mode_name(int id)
289
290
int rrd_memory_mode_id(const char *name)
291
{
292
- if(unlikely(!strcmp(name, RRD_MEMORY_MODE_RAM_NAME)))
292
+ if(unlikely(!strsame(name, RRD_MEMORY_MODE_RAM_NAME)))
293
return RRD_MEMORY_MODE_RAM;
294
- else if(unlikely(!strcmp(name, RRD_MEMORY_MODE_MAP_NAME)))
294
+ else if(unlikely(!strsame(name, RRD_MEMORY_MODE_MAP_NAME)))
295
return RRD_MEMORY_MODE_MAP;
296
297
return RRD_MEMORY_MODE_SAVE;
@@ -302,10 +302,10 @@ int rrd_memory_mode_id(const char *name)
302
303
int rrddim_algorithm_id(const char *name)
304
{
305
- if(strcmp(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
306
- if(strcmp(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
307
- if(strcmp(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
308
- if(strcmp(name, RRDDIM_PCENT_OVER_DIFF_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_DIFF_TOTAL;
305
+ if(strsame(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
306
+ if(strsame(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
307
+ if(strsame(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
308
+ if(strsame(name, RRDDIM_PCENT_OVER_DIFF_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_DIFF_TOTAL;
309
return RRDDIM_ABSOLUTE;
310
}
311
@@ -353,7 +353,7 @@ char *rrdset_strncpyz_name(char *to, const char *from, size_t length)
353
354
void rrdset_set_name(RRDSET *st, const char *name)
355
{
356
- if(unlikely(st->name && !strcmp(st->name, name)))
356
+ if(unlikely(st->name && !strsame(st->name, name)))
357
return;
358
359
debug(D_RRD_CALLS, "rrdset_set_name() old: %s, new: %s", st->name, name);
@@ -504,12 +504,12 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
504
snprintfz(fullfilename, FILENAME_MAX, "%s/main.db", cache_dir);
505
if(rrd_memory_mode != RRD_MEMORY_MODE_RAM) st = (RRDSET *)mymmap(fullfilename, size, ((rrd_memory_mode == RRD_MEMORY_MODE_MAP)?MAP_SHARED:MAP_PRIVATE), 0);
506
if(st) {
507
- if(strcmp(st->magic, RRDSET_MAGIC) != 0) {
507
+ if(strsame(st->magic, RRDSET_MAGIC) != 0) {
508
errno = 0;
509
info("Initializing file %s.", fullfilename);
510
memset(st, 0, size);
511
}
512
- else if(strcmp(st->id, fullid) != 0) {
512
+ else if(strsame(st->id, fullid) != 0) {
513
errno = 0;
514
error("File %s contents are not for chart %s. Clearing it.", fullfilename, fullid);
515
// munmap(st, size);
@@ -588,7 +588,7 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
588
st->isdetail = 0;
589
st->debug = 0;
590
591
- // if(!strcmp(st->id, "disk_util.dm-0")) {
591
+ // if(!strsame(st->id, "disk_util.dm-0")) {
592
// st->debug = 1;
593
// error("enabled debugging for '%s'", st->id);
594
// }
@@ -672,7 +672,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
672
struct timeval now;
673
now_realtime_timeval(&now);
674
675
- if(strcmp(rd->magic, RRDDIMENSION_MAGIC) != 0) {
675
+ if(strsame(rd->magic, RRDDIMENSION_MAGIC) != 0) {
676
errno = 0;
677
info("Initializing file %s.", fullfilename);
678
memset(rd, 0, size);
@@ -707,7 +707,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
707
error("File %s is too old. Clearing it.", fullfilename);
708
memset(rd, 0, size);
709
}
710
- else if(strcmp(rd->id, id) != 0) {
710
+ else if(strsame(rd->id, id) != 0) {
711
errno = 0;
712
error("File %s contents are not for dimension %s. Clearing it.", fullfilename, id);
713
// munmap(rd, size);
@@ -795,7 +795,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
795
796
void rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name)
797
{
798
- if(unlikely(rd->name && !strcmp(rd->name, name)))
798
+ if(unlikely(rd->name && !strsame(rd->name, name)))
799
return;
800
801
debug(D_RRD_CALLS, "rrddim_set_name() from %s.%s to %s.%s", st->name, rd->name, st->name, name);
src/rrd2json.c
+1
-1
@@ -561,7 +561,7 @@ void rrdr_disable_not_selected_dimensions(RRDR *r, const char *dims)
561
562
// find it and enable it
563
for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
564
- if(unlikely((hash == d->hash && !strcmp(d->id, tok)) || !strcmp(d->name, tok))) {
564
+ if(unlikely((hash == d->hash && !strsame(d->id, tok)) || !strsame(d->name, tok))) {
565
r->od[c] &= ~RRDR_HIDDEN;
566
567
// since the user needs this dimension
src/simple_pattern.c
+2
-2
@@ -147,7 +147,7 @@ static inline int match_pattern(struct simple_pattern *m, const char *str, size_
147
break;
148
149
case SIMPLE_PATTERN_SUFFIX:
150
- if(unlikely(strcmp(&str[len - m->len], m->match) == 0)) {
150
+ if(unlikely(strsame(&str[len - m->len], m->match) == 0)) {
151
if(!m->child) return 1;
152
return 0;
153
}
@@ -155,7 +155,7 @@ static inline int match_pattern(struct simple_pattern *m, const char *str, size_
155
156
case SIMPLE_PATTERN_EXACT:
157
default:
158
- if(unlikely(strcmp(str, m->match) == 0)) {
158
+ if(unlikely(strsame(str, m->match) == 0)) {
159
if(!m->child) return 1;
160
return 0;
161
}
src/sys_fs_cgroup.c
+11
-85
@@ -54,88 +54,16 @@ static char *cgroups_rename_script = PLUGINS_DIR "/cgroup-name.sh";
54
55
static uint32_t Read_hash = 0;
56
static uint32_t Write_hash = 0;
57
-static uint32_t Sync_hash = 0;
58
-static uint32_t Async_hash = 0;
59
-static uint32_t Total_hash = 0;
57
static uint32_t user_hash = 0;
58
static uint32_t system_hash = 0;
62
-static uint32_t cache_hash = 0;
63
-static uint32_t rss_hash = 0;
64
-static uint32_t rss_huge_hash = 0;
65
-static uint32_t mapped_file_hash = 0;
66
-static uint32_t writeback_hash = 0;
67
-static uint32_t dirty_hash = 0;
68
-static uint32_t swap_hash = 0;
69
-static uint32_t pgpgin_hash = 0;
70
-static uint32_t pgpgout_hash = 0;
71
-static uint32_t pgfault_hash = 0;
72
-static uint32_t pgmajfault_hash = 0;
73
-static uint32_t inactive_anon_hash = 0;
74
-static uint32_t active_anon_hash = 0;
75
-static uint32_t inactive_file_hash = 0;
76
-static uint32_t active_file_hash = 0;
77
-static uint32_t unevictable_hash = 0;
78
-static uint32_t hierarchical_memory_limit_hash = 0;
79
-static uint32_t total_cache_hash = 0;
80
-static uint32_t total_rss_hash = 0;
81
-static uint32_t total_rss_huge_hash = 0;
82
-static uint32_t total_mapped_file_hash = 0;
83
-static uint32_t total_writeback_hash = 0;
84
-static uint32_t total_dirty_hash = 0;
85
-static uint32_t total_swap_hash = 0;
86
-static uint32_t total_pgpgin_hash = 0;
87
-static uint32_t total_pgpgout_hash = 0;
88
-static uint32_t total_pgfault_hash = 0;
89
-static uint32_t total_pgmajfault_hash = 0;
90
-static uint32_t total_inactive_anon_hash = 0;
91
-static uint32_t total_active_anon_hash = 0;
92
-static uint32_t total_inactive_file_hash = 0;
93
-static uint32_t total_active_file_hash = 0;
94
-static uint32_t total_unevictable_hash = 0;
59
60
void read_cgroup_plugin_configuration() {
61
system_page_size = sysconf(_SC_PAGESIZE);
62
63
Read_hash = simple_hash("Read");
64
Write_hash = simple_hash("Write");
101
- Sync_hash = simple_hash("Sync");
102
- Async_hash = simple_hash("Async");
103
- Total_hash = simple_hash("Total");
65
user_hash = simple_hash("user");
66
system_hash = simple_hash("system");
106
- cache_hash = simple_hash("cache");
107
- rss_hash = simple_hash("rss");
108
- rss_huge_hash = simple_hash("rss_huge");
109
- mapped_file_hash = simple_hash("mapped_file");
110
- writeback_hash = simple_hash("writeback");
111
- dirty_hash = simple_hash("dirty");
112
- swap_hash = simple_hash("swap");
113
- pgpgin_hash = simple_hash("pgpgin");
114
- pgpgout_hash = simple_hash("pgpgout");
115
- pgfault_hash = simple_hash("pgfault");
116
- pgmajfault_hash = simple_hash("pgmajfault");
117
- inactive_anon_hash = simple_hash("inactive_anon");
118
- active_anon_hash = simple_hash("active_anon");
119
- inactive_file_hash = simple_hash("inactive_file");
120
- active_file_hash = simple_hash("active_file");
121
- unevictable_hash = simple_hash("unevictable");
122
- hierarchical_memory_limit_hash = simple_hash("hierarchical_memory_limit");
123
- total_cache_hash = simple_hash("total_cache");
124
- total_rss_hash = simple_hash("total_rss");
125
- total_rss_huge_hash = simple_hash("total_rss_huge");
126
- total_mapped_file_hash = simple_hash("total_mapped_file");
127
- total_writeback_hash = simple_hash("total_writeback");
128
- total_dirty_hash = simple_hash("total_dirty");
129
- total_swap_hash = simple_hash("total_swap");
130
- total_pgpgin_hash = simple_hash("total_pgpgin");
131
- total_pgpgout_hash = simple_hash("total_pgpgout");
132
- total_pgfault_hash = simple_hash("total_pgfault");
133
- total_pgmajfault_hash = simple_hash("total_pgmajfault");
134
- total_inactive_anon_hash = simple_hash("total_inactive_anon");
135
- total_active_anon_hash = simple_hash("total_active_anon");
136
- total_inactive_file_hash = simple_hash("total_inactive_file");
137
- total_active_file_hash = simple_hash("total_active_file");
138
- total_unevictable_hash = simple_hash("total_unevictable");
67
68
cgroup_update_every = (int)config_get_number("plugin:cgroups", "update every", rrd_update_every);
69
if(cgroup_update_every < rrd_update_every)
@@ -443,8 +371,6 @@ struct cgroup {
371
RRDDIM *rd_mem_detailed_rss;
372
RRDDIM *rd_mem_detailed_mapped;
373
RRDDIM *rd_mem_detailed_writeback;
446
- RRDDIM *rd_mem_detailed_dirty;
447
- RRDDIM *rd_mem_detailed_swap;
374
RRDDIM *rd_mem_detailed_pgpgin;
375
RRDDIM *rd_mem_detailed_pgpgout;
376
RRDDIM *rd_mem_detailed_pgfault;
@@ -499,10 +425,10 @@ static inline void cgroup_read_cpuacct_stat(struct cpuacct_stat *cp) {
425
char *s = procfile_lineword(ff, i, 0);
426
uint32_t hash = simple_hash(s);
427
502
- if(unlikely(hash == user_hash && !strcmp(s, "user")))
428
+ if(unlikely(hash == user_hash && !strsame(s, "user")))
429
cp->user = str2ull(procfile_lineword(ff, i, 1));
430
505
- else if(unlikely(hash == system_hash && !strcmp(s, "system")))
431
+ else if(unlikely(hash == system_hash && !strsame(s, "system")))
432
cp->system = str2ull(procfile_lineword(ff, i, 1));
433
}
434
@@ -530,7 +456,7 @@ static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
456
}
457
458
if(unlikely(procfile_lines(ff) < 1)) {
533
- error("File '%s' should have 1+ lines but has %u.", ca->filename, procfile_lines(ff));
459
+ error("File '%s' should have 1+ lines but has %zu.", ca->filename, procfile_lines(ff));
460
ca->updated = 0;
461
return;
462
}
@@ -609,20 +535,20 @@ static inline void cgroup_read_blkio(struct blkio *io) {
535
char *s = procfile_lineword(ff, i, 1);
536
uint32_t hash = simple_hash(s);
537
612
- if(unlikely(hash == Read_hash && !strcmp(s, "Read")))
538
+ if(unlikely(hash == Read_hash && !strsame(s, "Read")))
539
io->Read += str2ull(procfile_lineword(ff, i, 2));
540
615
- else if(unlikely(hash == Write_hash && !strcmp(s, "Write")))
541
+ else if(unlikely(hash == Write_hash && !strsame(s, "Write")))
542
io->Write += str2ull(procfile_lineword(ff, i, 2));
543
544
/*
619
- else if(unlikely(hash == Sync_hash && !strcmp(s, "Sync")))
545
+ else if(unlikely(hash == Sync_hash && !strsame(s, "Sync")))
546
io->Sync += str2ull(procfile_lineword(ff, i, 2));
547
622
- else if(unlikely(hash == Async_hash && !strcmp(s, "Async")))
548
+ else if(unlikely(hash == Async_hash && !strsame(s, "Async")))
549
io->Async += str2ull(procfile_lineword(ff, i, 2));
550
625
- else if(unlikely(hash == Total_hash && !strcmp(s, "Total")))
551
+ else if(unlikely(hash == Total_hash && !strsame(s, "Total")))
552
io->Total += str2ull(procfile_lineword(ff, i, 2));
553
*/
554
}
@@ -921,7 +847,7 @@ static inline struct cgroup *cgroup_add(const char *id) {
847
if(cg->enabled) {
848
struct cgroup *t;
849
for (t = cgroup_root; t; t = t->next) {
924
- if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
850
+ if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
851
if (!strncmp(t->chart_id, "/system.slice/", 14) && !strncmp(cg->chart_id, "/init.scope/system.slice/", 25)) {
852
error("Control group with chart id '%s' already exists with id '%s' and is enabled. Swapping them by enabling cgroup with id '%s' and disabling cgroup with id '%s'.",
853
cg->chart_id, t->id, cg->id, t->id);
@@ -989,7 +915,7 @@ static inline struct cgroup *cgroup_find(const char *id) {
915
916
struct cgroup *cg;
917
for(cg = cgroup_root; cg ; cg = cg->next) {
992
- if(hash == cg->hash && strcmp(id, cg->id) == 0)
918
+ if(hash == cg->hash && strsame(id, cg->id) == 0)
919
break;
920
}
921
@@ -1109,7 +1035,7 @@ static inline void cleanup_all_cgroups() {
1035
{
1036
struct cgroup *t;
1037
for(t = cgroup_root; t ; t = t->next) {
1112
- if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
1038
+ if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
1039
debug(D_CGROUP, "Enabling duplicate of cgroup '%s' with id '%s', because the original with id '%s' stopped.", t->chart_id, t->id, cg->id);
1040
t->enabled = 1;
1041
t->options &= ~CGROUP_OPTIONS_DISABLED_DUPLICATE;
src/web_buffer.c
+1
-1
@@ -21,7 +21,7 @@ static inline void _buffer_overflow_check(BUFFER *b, const char *file, const cha
21
b->len = b->size;
22
}
23
24
- if(b->buffer[b->size] != '\0' || strcmp(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
24
+ if(b->buffer[b->size] != '\0' || strsame(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
25
error("BUFFER: detected overflow at line %lu, at function %s() of file '%s'.", line, function, file);
26
buffer_overflow_init(b);
27
}
src/web_buffer_svg.c
+18
-18
@@ -290,7 +290,7 @@ static inline int verdana11_width(char *s) {
290
*d = '\0';
291
w -= VERDANA_KERNING;
292
w += VERDANA_PADDING;
293
- return ceil(w);
293
+ return (int)ceil(w);
294
}
295
296
static inline size_t escape_xmlz(char *dst, const char *src, size_t len) {
@@ -369,25 +369,25 @@ cleanup:
369
}
370
371
static inline const char *fix_units(const char *units) {
372
- if(!units || !*units || !strcmp(units, "empty") || !strcmp(units, "null")) return "";
373
- if(!strcmp(units, "percentage") || !strcmp(units, "percent") || !strcmp(units, "pcent")) return "%";
372
+ if(!units || !*units || !strsame(units, "empty") || !strsame(units, "null")) return "";
373
+ if(!strsame(units, "percentage") || !strsame(units, "percent") || !strsame(units, "pcent")) return "%";
374
return units;
375
}
376
377
static inline const char *color_map(const char *color) {
378
// colors from:
379
// https://github.com/badges/shields/blob/master/colorscheme.json
380
- if(!strcmp(color, "brightgreen")) return "#4c1";
381
- else if(!strcmp(color, "green")) return "#97CA00";
382
- else if(!strcmp(color, "yellow")) return "#dfb317";
383
- else if(!strcmp(color, "yellowgreen")) return "#a4a61d";
384
- else if(!strcmp(color, "orange")) return "#fe7d37";
385
- else if(!strcmp(color, "red")) return "#e05d44";
386
- else if(!strcmp(color, "blue")) return "#007ec6";
387
- else if(!strcmp(color, "grey")) return "#555";
388
- else if(!strcmp(color, "gray")) return "#555";
389
- else if(!strcmp(color, "lightgrey")) return "#9f9f9f";
390
- else if(!strcmp(color, "lightgray")) return "#9f9f9f";
380
+ if(!strsame(color, "brightgreen")) return "#4c1";
381
+ else if(!strsame(color, "green")) return "#97CA00";
382
+ else if(!strsame(color, "yellow")) return "#dfb317";
383
+ else if(!strsame(color, "yellowgreen")) return "#a4a61d";
384
+ else if(!strsame(color, "orange")) return "#fe7d37";
385
+ else if(!strsame(color, "red")) return "#e05d44";
386
+ else if(!strsame(color, "blue")) return "#007ec6";
387
+ else if(!strsame(color, "grey")) return "#555";
388
+ else if(!strsame(color, "gray")) return "#555";
389
+ else if(!strsame(color, "lightgrey")) return "#9f9f9f";
390
+ else if(!strsame(color, "lightgray")) return "#9f9f9f";
391
return color;
392
}
393
@@ -466,7 +466,7 @@ static inline void calc_colorz(const char *color, char *final, size_t len, calcu
466
*dv = '\0';
467
468
if(value_is_null) {
469
- if(!*value_buffer || !strcmp(value_buffer, "null"))
469
+ if(!*value_buffer || !strsame(value_buffer, "null"))
470
break;
471
}
472
else {
@@ -525,7 +525,7 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
525
if(unlikely(isalnum(*units)))
526
separator = " ";
527
528
- if(unlikely(!strcmp(units, "seconds"))) {
528
+ if(unlikely(!strsame(units, "seconds"))) {
529
size_t s = (size_t)value;
530
size_t d = s / 86400;
531
s = s % 86400;
@@ -542,7 +542,7 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
542
snprintfz(value_string, VALUE_STRING_SIZE, "%02zu:%02zu:%02zu", h, m, s);
543
}
544
545
- else if(unlikely(!strcmp(units, "minutes"))) {
545
+ else if(unlikely(!strsame(units, "minutes"))) {
546
size_t m = (size_t)value;
547
size_t d = m / (60 * 24);
548
m = m % (60 * 24);
@@ -556,7 +556,7 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
556
snprintfz(value_string, VALUE_STRING_SIZE, "%zuh %zum", h, m);
557
}
558
559
- else if(unlikely(!strcmp(units, "hours"))) {
559
+ else if(unlikely(!strsame(units, "hours"))) {
560
size_t h = (size_t)value;
561
size_t d = h / 24;
562
h = h % 24;
src/web_client.c
+118
-118
@@ -544,29 +544,29 @@ uint32_t web_client_api_request_v1_data_options(char *o)
544
while(o && *o && (tok = mystrsep(&o, ", |"))) {
545
if(!*tok) continue;
546
547
- if(!strcmp(tok, "nonzero"))
547
+ if(!strsame(tok, "nonzero"))
548
ret |= RRDR_OPTION_NONZERO;
549
- else if(!strcmp(tok, "flip") || !strcmp(tok, "reversed") || !strcmp(tok, "reverse"))
549
+ else if(!strsame(tok, "flip") || !strsame(tok, "reversed") || !strsame(tok, "reverse"))
550
ret |= RRDR_OPTION_REVERSED;
551
- else if(!strcmp(tok, "jsonwrap"))
551
+ else if(!strsame(tok, "jsonwrap"))
552
ret |= RRDR_OPTION_JSON_WRAP;
553
- else if(!strcmp(tok, "min2max"))
553
+ else if(!strsame(tok, "min2max"))
554
ret |= RRDR_OPTION_MIN2MAX;
555
- else if(!strcmp(tok, "ms") || !strcmp(tok, "milliseconds"))
555
+ else if(!strsame(tok, "ms") || !strsame(tok, "milliseconds"))
556
ret |= RRDR_OPTION_MILLISECONDS;
557
- else if(!strcmp(tok, "abs") || !strcmp(tok, "absolute") || !strcmp(tok, "absolute_sum") || !strcmp(tok, "absolute-sum"))
557
+ else if(!strsame(tok, "abs") || !strsame(tok, "absolute") || !strsame(tok, "absolute_sum") || !strsame(tok, "absolute-sum"))
558
ret |= RRDR_OPTION_ABSOLUTE;
559
- else if(!strcmp(tok, "seconds"))
559
+ else if(!strsame(tok, "seconds"))
560
ret |= RRDR_OPTION_SECONDS;
561
- else if(!strcmp(tok, "null2zero"))
561
+ else if(!strsame(tok, "null2zero"))
562
ret |= RRDR_OPTION_NULL2ZERO;
563
- else if(!strcmp(tok, "objectrows"))
563
+ else if(!strsame(tok, "objectrows"))
564
ret |= RRDR_OPTION_OBJECTSROWS;
565
- else if(!strcmp(tok, "google_json"))
565
+ else if(!strsame(tok, "google_json"))
566
ret |= RRDR_OPTION_GOOGLE_JSON;
567
- else if(!strcmp(tok, "percentage"))
567
+ else if(!strsame(tok, "percentage"))
568
ret |= RRDR_OPTION_PERCENTAGE;
569
- else if(!strcmp(tok, "unaligned"))
569
+ else if(!strsame(tok, "unaligned"))
570
ret |= RRDR_OPTION_NOT_ALIGNED;
571
}
572
@@ -575,37 +575,37 @@ uint32_t web_client_api_request_v1_data_options(char *o)
575
576
uint32_t web_client_api_request_v1_data_format(char *name)
577
{
578
- if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
578
+ if(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
579
return DATASOURCE_DATATABLE_JSON;
580
581
- else if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
581
+ else if(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
582
return DATASOURCE_DATATABLE_JSONP;
583
584
- else if(!strcmp(name, DATASOURCE_FORMAT_JSON)) // json
584
+ else if(!strsame(name, DATASOURCE_FORMAT_JSON)) // json
585
return DATASOURCE_JSON;
586
587
- else if(!strcmp(name, DATASOURCE_FORMAT_JSONP)) // jsonp
587
+ else if(!strsame(name, DATASOURCE_FORMAT_JSONP)) // jsonp
588
return DATASOURCE_JSONP;
589
590
- else if(!strcmp(name, DATASOURCE_FORMAT_SSV)) // ssv
590
+ else if(!strsame(name, DATASOURCE_FORMAT_SSV)) // ssv
591
return DATASOURCE_SSV;
592
593
- else if(!strcmp(name, DATASOURCE_FORMAT_CSV)) // csv
593
+ else if(!strsame(name, DATASOURCE_FORMAT_CSV)) // csv
594
return DATASOURCE_CSV;
595
596
- else if(!strcmp(name, DATASOURCE_FORMAT_TSV) || !strcmp(name, "tsv-excel")) // tsv
596
+ else if(!strsame(name, DATASOURCE_FORMAT_TSV) || !strsame(name, "tsv-excel")) // tsv
597
return DATASOURCE_TSV;
598
599
- else if(!strcmp(name, DATASOURCE_FORMAT_HTML)) // html
599
+ else if(!strsame(name, DATASOURCE_FORMAT_HTML)) // html
600
return DATASOURCE_HTML;
601
602
- else if(!strcmp(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
602
+ else if(!strsame(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
603
return DATASOURCE_JS_ARRAY;
604
605
- else if(!strcmp(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
605
+ else if(!strsame(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
606
return DATASOURCE_SSV_COMMA;
607
608
- else if(!strcmp(name, DATASOURCE_FORMAT_CSV_JSON_ARRAY)) // csvjsonarray
608
+ else if(!strsame(name, DATASOURCE_FORMAT_CSV_JSON_ARRAY)) // csvjsonarray
609
return DATASOURCE_CSV_JSON_ARRAY;
610
611
return DATASOURCE_JSON;
@@ -613,16 +613,16 @@ uint32_t web_client_api_request_v1_data_format(char *name)
613
614
uint32_t web_client_api_request_v1_data_google_format(char *name)
615
{
616
- if(!strcmp(name, "json"))
616
+ if(!strsame(name, "json"))
617
return DATASOURCE_DATATABLE_JSONP;
618
619
- else if(!strcmp(name, "html"))
619
+ else if(!strsame(name, "html"))
620
return DATASOURCE_HTML;
621
622
- else if(!strcmp(name, "csv"))
622
+ else if(!strsame(name, "csv"))
623
return DATASOURCE_CSV;
624
625
- else if(!strcmp(name, "tsv-excel"))
625
+ else if(!strsame(name, "tsv-excel"))
626
return DATASOURCE_TSV;
627
628
return DATASOURCE_JSON;
@@ -655,19 +655,19 @@ const char *group_method2string(int group) {
655
656
int web_client_api_request_v1_data_group(char *name, int def)
657
{
658
- if(!strcmp(name, "average"))
658
+ if(!strsame(name, "average"))
659
return GROUP_AVERAGE;
660
661
- else if(!strcmp(name, "min"))
661
+ else if(!strsame(name, "min"))
662
return GROUP_MIN;
663
664
- else if(!strcmp(name, "max"))
664
+ else if(!strsame(name, "max"))
665
return GROUP_MAX;
666
667
- else if(!strcmp(name, "sum"))
667
+ else if(!strsame(name, "sum"))
668
return GROUP_SUM;
669
670
- else if(!strcmp(name, "incremental-sum"))
670
+ else if(!strsame(name, "incremental-sum"))
671
return GROUP_INCREMENTAL_SUM;
672
673
return def;
@@ -681,8 +681,8 @@ int web_client_api_request_v1_alarms(struct web_client *w, char *url)
681
char *value = mystrsep(&url, "?&");
682
if (!value || !*value) continue;
683
684
- if(!strcmp(value, "all")) all = 1;
685
- else if(!strcmp(value, "active")) all = 0;
684
+ if(!strsame(value, "all")) all = 1;
685
+ else if(!strsame(value, "active")) all = 0;
686
}
687
688
buffer_flush(w->response.data);
@@ -703,7 +703,7 @@ int web_client_api_request_v1_alarm_log(struct web_client *w, char *url)
703
if(!name || !*name) continue;
704
if(!value || !*value) continue;
705
706
- if(!strcmp(name, "after")) after = strtoul(value, NULL, 0);
706
+ if(!strsame(name, "after")) after = strtoul(value, NULL, 0);
707
}
708
709
buffer_flush(w->response.data);
@@ -730,7 +730,7 @@ int web_client_api_request_single_chart(struct web_client *w, char *url, void ca
730
// name and value are now the parameters
731
// they are not null and not empty
732
733
- if(!strcmp(name, "chart")) chart = value;
733
+ if(!strsame(name, "chart")) chart = value;
734
//else {
735
/// buffer_sprintf(w->response.data, "Unknown parameter '%s' in request.", name);
736
// goto cleanup;
@@ -786,10 +786,10 @@ int web_client_api_request_v1_allmetrics(struct web_client *w, char *url)
786
if(!name || !*name) continue;
787
if(!value || !*value) continue;
788
789
- if(!strcmp(name, "format")) {
790
- if(!strcmp(value, ALLMETRICS_FORMAT_SHELL))
789
+ if(!strsame(name, "format")) {
790
+ if(!strsame(value, ALLMETRICS_FORMAT_SHELL))
791
format = ALLMETRICS_SHELL;
792
- else if(!strcmp(value, ALLMETRICS_FORMAT_PROMETHEUS))
792
+ else if(!strsame(value, ALLMETRICS_FORMAT_PROMETHEUS))
793
format = ALLMETRICS_PROMETHEUS;
794
else
795
format = 0;
@@ -858,32 +858,32 @@ int web_client_api_request_v1_badge(struct web_client *w, char *url) {
858
// name and value are now the parameters
859
// they are not null and not empty
860
861
- if(!strcmp(name, "chart")) chart = value;
862
- else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
861
+ if(!strsame(name, "chart")) chart = value;
862
+ else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
863
if(!dimensions)
864
dimensions = buffer_create(100);
865
866
buffer_strcat(dimensions, "|");
867
buffer_strcat(dimensions, value);
868
}
869
- else if(!strcmp(name, "after")) after_str = value;
870
- else if(!strcmp(name, "before")) before_str = value;
871
- else if(!strcmp(name, "points")) points_str = value;
872
- else if(!strcmp(name, "group")) {
869
+ else if(!strsame(name, "after")) after_str = value;
870
+ else if(!strsame(name, "before")) before_str = value;
871
+ else if(!strsame(name, "points")) points_str = value;
872
+ else if(!strsame(name, "group")) {
873
group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
874
}
875
- else if(!strcmp(name, "options")) {
875
+ else if(!strsame(name, "options")) {
876
options |= web_client_api_request_v1_data_options(value);
877
}
878
- else if(!strcmp(name, "label")) label = value;
879
- else if(!strcmp(name, "units")) units = value;
880
- else if(!strcmp(name, "label_color")) label_color = value;
881
- else if(!strcmp(name, "value_color")) value_color = value;
882
- else if(!strcmp(name, "multiply")) multiply_str = value;
883
- else if(!strcmp(name, "divide")) divide_str = value;
884
- else if(!strcmp(name, "refresh")) refresh_str = value;
885
- else if(!strcmp(name, "precision")) precision_str = value;
886
- else if(!strcmp(name, "alarm")) alarm = value;
878
+ else if(!strsame(name, "label")) label = value;
879
+ else if(!strsame(name, "units")) units = value;
880
+ else if(!strsame(name, "label_color")) label_color = value;
881
+ else if(!strsame(name, "value_color")) value_color = value;
882
+ else if(!strsame(name, "multiply")) multiply_str = value;
883
+ else if(!strsame(name, "divide")) divide_str = value;
884
+ else if(!strsame(name, "refresh")) refresh_str = value;
885
+ else if(!strsame(name, "precision")) precision_str = value;
886
+ else if(!strsame(name, "alarm")) alarm = value;
887
}
888
889
if(!chart || !*chart) {
@@ -924,7 +924,7 @@ int web_client_api_request_v1_badge(struct web_client *w, char *url) {
924
925
int refresh = 0;
926
if(refresh_str && *refresh_str) {
927
- if(!strcmp(refresh_str, "auto")) {
927
+ if(!strsame(refresh_str, "auto")) {
928
if(rc) refresh = rc->update_every;
929
else if(options & RRDR_OPTION_NOT_ALIGNED)
930
refresh = st->update_every;
@@ -1121,31 +1121,31 @@ int web_client_api_request_v1_data(struct web_client *w, char *url)
1121
// name and value are now the parameters
1122
// they are not null and not empty
1123
1124
- if(!strcmp(name, "chart")) chart = value;
1125
- else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
1124
+ if(!strsame(name, "chart")) chart = value;
1125
+ else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
1126
if(!dimensions) dimensions = buffer_create(100);
1127
buffer_strcat(dimensions, "|");
1128
buffer_strcat(dimensions, value);
1129
}
1130
- else if(!strcmp(name, "after")) after_str = value;
1131
- else if(!strcmp(name, "before")) before_str = value;
1132
- else if(!strcmp(name, "points")) points_str = value;
1133
- else if(!strcmp(name, "group")) {
1130
+ else if(!strsame(name, "after")) after_str = value;
1131
+ else if(!strsame(name, "before")) before_str = value;
1132
+ else if(!strsame(name, "points")) points_str = value;
1133
+ else if(!strsame(name, "group")) {
1134
group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
1135
}
1136
- else if(!strcmp(name, "format")) {
1136
+ else if(!strsame(name, "format")) {
1137
format = web_client_api_request_v1_data_format(value);
1138
}
1139
- else if(!strcmp(name, "options")) {
1139
+ else if(!strsame(name, "options")) {
1140
options |= web_client_api_request_v1_data_options(value);
1141
}
1142
- else if(!strcmp(name, "callback")) {
1142
+ else if(!strsame(name, "callback")) {
1143
responseHandler = value;
1144
}
1145
- else if(!strcmp(name, "filename")) {
1145
+ else if(!strsame(name, "filename")) {
1146
outFileName = value;
1147
}
1148
- else if(!strcmp(name, "tqx")) {
1148
+ else if(!strsame(name, "tqx")) {
1149
// parse Google Visualization API options
1150
// https://developers.google.com/chart/interactive/docs/dev/implementing_data_source
1151
char *tqx_name, *tqx_value;
@@ -1158,21 +1158,21 @@ int web_client_api_request_v1_data(struct web_client *w, char *url)
1158
if(!tqx_name || !*tqx_name) continue;
1159
if(!tqx_value || !*tqx_value) continue;
1160
1161
- if(!strcmp(tqx_name, "version"))
1161
+ if(!strsame(tqx_name, "version"))
1162
google_version = tqx_value;
1163
- else if(!strcmp(tqx_name, "reqId"))
1163
+ else if(!strsame(tqx_name, "reqId"))
1164
google_reqId = tqx_value;
1165
- else if(!strcmp(tqx_name, "sig")) {
1165
+ else if(!strsame(tqx_name, "sig")) {
1166
google_sig = tqx_value;
1167
google_timestamp = strtoul(google_sig, NULL, 0);
1168
}
1169
- else if(!strcmp(tqx_name, "out")) {
1169
+ else if(!strsame(tqx_name, "out")) {
1170
google_out = tqx_value;
1171
format = web_client_api_request_v1_data_google_format(google_out);
1172
}
1173
- else if(!strcmp(tqx_name, "responseHandler"))
1173
+ else if(!strsame(tqx_name, "responseHandler"))
1174
responseHandler = tqx_value;
1175
- else if(!strcmp(tqx_name, "outFileName"))
1175
+ else if(!strsame(tqx_name, "outFileName"))
1176
outFileName = tqx_value;
1177
}
1178
}
@@ -1314,42 +1314,42 @@ int web_client_api_request_v1_registry(struct web_client *w, char *url)
1314
1315
uint32_t hash = simple_hash(name);
1316
1317
- if(hash == hash_action && !strcmp(name, "action")) {
1317
+ if(hash == hash_action && !strsame(name, "action")) {
1318
uint32_t vhash = simple_hash(value);
1319
1320
- if(vhash == hash_access && !strcmp(value, "access")) action = 'A';
1321
- else if(vhash == hash_hello && !strcmp(value, "hello")) action = 'H';
1322
- else if(vhash == hash_delete && !strcmp(value, "delete")) action = 'D';
1323
- else if(vhash == hash_search && !strcmp(value, "search")) action = 'S';
1324
- else if(vhash == hash_switch && !strcmp(value, "switch")) action = 'W';
1320
+ if(vhash == hash_access && !strsame(value, "access")) action = 'A';
1321
+ else if(vhash == hash_hello && !strsame(value, "hello")) action = 'H';
1322
+ else if(vhash == hash_delete && !strsame(value, "delete")) action = 'D';
1323
+ else if(vhash == hash_search && !strsame(value, "search")) action = 'S';
1324
+ else if(vhash == hash_switch && !strsame(value, "switch")) action = 'W';
1325
#ifdef NETDATA_INTERNAL_CHECKS
1326
else error("unknown registry action '%s'", value);
1327
#endif /* NETDATA_INTERNAL_CHECKS */
1328
}
1329
/*
1330
- else if(hash == hash_redirects && !strcmp(name, "redirects"))
1330
+ else if(hash == hash_redirects && !strsame(name, "redirects"))
1331
redirects = atoi(value);
1332
*/
1333
- else if(hash == hash_machine && !strcmp(name, "machine"))
1333
+ else if(hash == hash_machine && !strsame(name, "machine"))
1334
machine_guid = value;
1335
1336
- else if(hash == hash_url && !strcmp(name, "url"))
1336
+ else if(hash == hash_url && !strsame(name, "url"))
1337
machine_url = value;
1338
1339
else if(action == 'A') {
1340
- if(hash == hash_name && !strcmp(name, "name"))
1340
+ if(hash == hash_name && !strsame(name, "name"))
1341
url_name = value;
1342
}
1343
else if(action == 'D') {
1344
- if(hash == hash_delete_url && !strcmp(name, "delete_url"))
1344
+ if(hash == hash_delete_url && !strsame(name, "delete_url"))
1345
delete_url = value;
1346
}
1347
else if(action == 'S') {
1348
- if(hash == hash_for && !strcmp(name, "for"))
1348
+ if(hash == hash_for && !strsame(name, "for"))
1349
search_machine_guid = value;
1350
}
1351
else if(action == 'W') {
1352
- if(hash == hash_to && !strcmp(name, "to"))
1352
+ if(hash == hash_to && !strsame(name, "to"))
1353
to_person_guid = value;
1354
}
1355
#ifdef NETDATA_INTERNAL_CHECKS
@@ -1440,31 +1440,31 @@ int web_client_api_request_v1(struct web_client *w, char *url) {
1440
debug(D_WEB_CLIENT, "%llu: Searching for API v1 command '%s'.", w->id, tok);
1441
uint32_t hash = simple_hash(tok);
1442
1443
- if(hash == hash_data && !strcmp(tok, "data"))
1443
+ if(hash == hash_data && !strsame(tok, "data"))
1444
return web_client_api_request_v1_data(w, url);
1445
1446
- else if(hash == hash_chart && !strcmp(tok, "chart"))
1446
+ else if(hash == hash_chart && !strsame(tok, "chart"))
1447
return web_client_api_request_v1_chart(w, url);
1448
1449
- else if(hash == hash_charts && !strcmp(tok, "charts"))
1449
+ else if(hash == hash_charts && !strsame(tok, "charts"))
1450
return web_client_api_request_v1_charts(w, url);
1451
1452
- else if(hash == hash_registry && !strcmp(tok, "registry"))
1452
+ else if(hash == hash_registry && !strsame(tok, "registry"))
1453
return web_client_api_request_v1_registry(w, url);
1454
1455
- else if(hash == hash_badge && !strcmp(tok, "badge.svg"))
1455
+ else if(hash == hash_badge && !strsame(tok, "badge.svg"))
1456
return web_client_api_request_v1_badge(w, url);
1457
1458
- else if(hash == hash_alarms && !strcmp(tok, "alarms"))
1458
+ else if(hash == hash_alarms && !strsame(tok, "alarms"))
1459
return web_client_api_request_v1_alarms(w, url);
1460
1461
- else if(hash == hash_alarm_log && !strcmp(tok, "alarm_log"))
1461
+ else if(hash == hash_alarm_log && !strsame(tok, "alarm_log"))
1462
return web_client_api_request_v1_alarm_log(w, url);
1463
1464
- else if(hash == hash_alarm_variables && !strcmp(tok, "alarm_variables"))
1464
+ else if(hash == hash_alarm_variables && !strsame(tok, "alarm_variables"))
1465
return web_client_api_request_v1_alarm_variables(w, url);
1466
1467
- else if(hash == hash_raw && !strcmp(tok, "allmetrics"))
1467
+ else if(hash == hash_raw && !strsame(tok, "allmetrics"))
1468
return web_client_api_request_v1_allmetrics(w, url);
1469
1470
else {
@@ -1487,7 +1487,7 @@ int web_client_api_request(struct web_client *w, char *url)
1487
char *tok = mystrsep(&url, "/?&");
1488
if(tok && *tok) {
1489
debug(D_WEB_CLIENT, "%llu: Searching for API version '%s'.", w->id, tok);
1490
- if(strcmp(tok, "v1") == 0)
1490
+ if(strsame(tok, "v1") == 0)
1491
return web_client_api_request_v1(w, url);
1492
else {
1493
buffer_flush(w->response.data);
@@ -1564,9 +1564,9 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
1564
// parse the grouping method required
1565
tok = mystrsep(&url, "/");
1566
if(tok && *tok) {
1567
- if(strcmp(tok, "max") == 0) group_method = GROUP_MAX;
1568
- else if(strcmp(tok, "average") == 0) group_method = GROUP_AVERAGE;
1569
- else if(strcmp(tok, "sum") == 0) group_method = GROUP_SUM;
1567
+ if(strsame(tok, "max") == 0) group_method = GROUP_MAX;
1568
+ else if(strsame(tok, "average") == 0) group_method = GROUP_AVERAGE;
1569
+ else if(strsame(tok, "sum") == 0) group_method = GROUP_SUM;
1570
else debug(D_WEB_CLIENT, "%llu: Unknown group method '%s'", w->id, tok);
1571
}
1572
}
@@ -1585,7 +1585,7 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
1585
if(url) {
1586
// parse nonzero
1587
tok = mystrsep(&url, "/");
1588
- if(tok && *tok && strcmp(tok, "nonzero") == 0) nonzero = 1;
1588
+ if(tok && *tok && strsame(tok, "nonzero") == 0) nonzero = 1;
1589
}
1590
1591
w->response.data->contenttype = CT_APPLICATION_JSON;
@@ -1606,26 +1606,26 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
1606
tok = mystrsep(&args, "&");
1607
if(tok && *tok) {
1608
char *name = mystrsep(&tok, "=");
1609
- if(name && *name && strcmp(name, "tqx") == 0) {
1609
+ if(name && *name && strsame(name, "tqx") == 0) {
1610
char *key = mystrsep(&tok, ":");
1611
char *value = mystrsep(&tok, ";");
1612
if(key && value && *key && *value) {
1613
- if(strcmp(key, "version") == 0)
1613
+ if(strsame(key, "version") == 0)
1614
google_version = value;
1615
1616
- else if(strcmp(key, "reqId") == 0)
1616
+ else if(strsame(key, "reqId") == 0)
1617
google_reqId = value;
1618
1619
- else if(strcmp(key, "sig") == 0)
1619
+ else if(strsame(key, "sig") == 0)
1620
google_sig = value;
1621
1622
- else if(strcmp(key, "out") == 0)
1622
+ else if(strsame(key, "out") == 0)
1623
google_out = value;
1624
1625
- else if(strcmp(key, "responseHandler") == 0)
1625
+ else if(strsame(key, "responseHandler") == 0)
1626
google_responseHandler = value;
1627
1628
- else if(strcmp(key, "outFileName") == 0)
1628
+ else if(strsame(key, "outFileName") == 0)
1629
google_outFileName = value;
1630
}
1631
}
@@ -1640,7 +1640,7 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
1640
last_timestamp_in_data = strtoul(google_sig, NULL, 0);
1641
1642
// check the client wants json
1643
- if(strcmp(google_out, "json") != 0) {
1643
+ if(strsame(google_out, "json") != 0) {
1644
buffer_sprintf(w->response.data,
1645
"%s({version:'%s',reqId:'%s',status:'error',errors:[{reason:'invalid_query',message:'output format is not supported',detailed_message:'the format %s requested is not supported by netdata.'}]});",
1646
google_responseHandler, google_version, google_reqId, google_out);
@@ -2012,11 +2012,11 @@ void web_client_process(struct web_client *w) {
2012
uint32_t hash = simple_hash(tok);
2013
debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok);
2014
2015
- if(hash == hash_api && strcmp(tok, "api") == 0) {
2015
+ if(hash == hash_api && strsame(tok, "api") == 0) {
2016
// the client is requesting api access
2017
code = web_client_api_request(w, url);
2018
}
2019
- else if(hash == hash_netdata_conf && strcmp(tok, "netdata.conf") == 0) {
2019
+ else if(hash == hash_netdata_conf && strsame(tok, "netdata.conf") == 0) {
2020
code = 200;
2021
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending netdata.conf ...", w->id);
2022
@@ -2024,15 +2024,15 @@ void web_client_process(struct web_client *w) {
2024
buffer_flush(w->response.data);
2025
generate_config(w->response.data, 0);
2026
}
2027
- else if(hash == hash_data && strcmp(tok, WEB_PATH_DATA) == 0) { // "data"
2027
+ else if(hash == hash_data && strsame(tok, WEB_PATH_DATA) == 0) { // "data"
2028
// the client is requesting rrd data -- OLD API
2029
code = web_client_api_old_data_request(w, url, DATASOURCE_JSON);
2030
}
2031
- else if(hash == hash_datasource && strcmp(tok, WEB_PATH_DATASOURCE) == 0) { // "datasource"
2031
+ else if(hash == hash_datasource && strsame(tok, WEB_PATH_DATASOURCE) == 0) { // "datasource"
2032
// the client is requesting google datasource -- OLD API
2033
code = web_client_api_old_data_request(w, url, DATASOURCE_DATATABLE_JSONP);
2034
}
2035
- else if(hash == hash_graph && strcmp(tok, WEB_PATH_GRAPH) == 0) { // "graph"
2035
+ else if(hash == hash_graph && strsame(tok, WEB_PATH_GRAPH) == 0) { // "graph"
2036
// the client is requesting an rrd graph -- OLD API
2037
2038
// get the name of the data to show
@@ -2063,7 +2063,7 @@ void web_client_process(struct web_client *w) {
2063
buffer_strcat(w->response.data, "Graph name?\r\n");
2064
}
2065
}
2066
- else if(hash == hash_list && strcmp(tok, "list") == 0) {
2066
+ else if(hash == hash_list && strsame(tok, "list") == 0) {
2067
// OLD API
2068
code = 200;
2069
@@ -2075,7 +2075,7 @@ void web_client_process(struct web_client *w) {
2075
for ( ; st ; st = st->next )
2076
buffer_sprintf(w->response.data, "%s\n", st->name);
2077
}
2078
- else if(hash == hash_all_json && strcmp(tok, "all.json") == 0) {
2078
+ else if(hash == hash_all_json && strsame(tok, "all.json") == 0) {
2079
// OLD API
2080
code = 200;
2081
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending JSON list of all monitors of RRD_STATS...", w->id);
@@ -2085,7 +2085,7 @@ void web_client_process(struct web_client *w) {
2085
rrd_stats_all_json(w->response.data);
2086
}
2087
#ifdef NETDATA_INTERNAL_CHECKS
2088
- else if(hash == hash_exit && strcmp(tok, "exit") == 0) {
2088
+ else if(hash == hash_exit && strsame(tok, "exit") == 0) {
2089
code = 200;
2090
w->response.data->contenttype = CT_TEXT_PLAIN;
2091
buffer_flush(w->response.data);
@@ -2098,7 +2098,7 @@ void web_client_process(struct web_client *w) {
2098
error("web request to exit received.");
2099
netdata_cleanup_and_exit(0);
2100
}
2101
- else if(hash == hash_debug && strcmp(tok, "debug") == 0) {
2101
+ else if(hash == hash_debug && strsame(tok, "debug") == 0) {
2102
buffer_flush(w->response.data);
2103
2104
// get the name of the data to show
@@ -2130,7 +2130,7 @@ void web_client_process(struct web_client *w) {
2130
buffer_strcat(w->response.data, "debug which chart?\r\n");
2131
}
2132
}
2133
- else if(hash == hash_mirror && strcmp(tok, "mirror") == 0) {
2133
+ else if(hash == hash_mirror && strsame(tok, "mirror") == 0) {
2134
code = 200;
2135
2136
debug(D_WEB_CLIENT_ACCESS, "%llu: Mirroring...", w->id);
src/web_server.c
+1
-1
@@ -256,7 +256,7 @@ static inline int bind_to_one(const char *definition, int default_port, int list
256
*e = '\0';
257
}
258
259
- if(!*ip || *ip == '*' || !strcmp(ip, "any") || !strcmp(ip, "all"))
259
+ if(!*ip || *ip == '*' || !strsame(ip, "any") || !strsame(ip, "all"))
260
ip = NULL;
261
if(!*port)
262
port = buffer2;