@cryptotaxi247 / netdata-1 / commits / 27a1dbbe6

reverted strcmp()

Costa Tsaousis (ktsaou) committed Jan 21, 2017 at 18:10 UTC 27a1dbbe6ee89eb04cc6f6865974b71ba57a120d
33 files changed +389 -381
src/adaptive_resortable_list.c
+1 -1
@@ -130,7 +130,7 @@ int arl_find_or_create_and_relink(ARL_BASE *base, const char *s, const char *val
130
131 // find if it already exists in the data
132 for(e = base->head; e ; e = e->next)
133 - if(e->hash == hash && !strsame(e->name, s))
133 + if(e->hash == hash && !strcmp(e->name, s))
134 break;
135
136 #ifdef NETDATA_INTERNAL_CHECKS
src/adaptive_resortable_list.h
+1 -1
@@ -117,7 +117,7 @@ static inline int arl_check(ARL_BASE *base, const char *keyword, const char *val
117 ARL_ENTRY *e = base->next_keyword;
118
119 // it should be the first entry (pointed by base->next_keyword)
120 - if(likely(!strsame(keyword, e->name))) {
120 + if(likely(!strcmp(keyword, e->name))) {
121 // it is
122
123 #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 strsame(((struct config_value *)a)->name, ((struct config_value *)b)->name);
72 + else return strcmp(((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 strsame(((struct config *)a)->name, ((struct config *)b)->name);
93 + else return strcmp(((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(strsame(cv->value, default_value) != 0) cv->flags |= CONFIG_VALUE_CHANGED;
241 + if(strcmp(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(!strsame(s, "yes") || !strsame(s, "auto") || !strsame(s, "on demand")) return 1;
269 + if(!strcmp(s, "yes") || !strcmp(s, "auto") || !strcmp(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(!strsame(s, "yes"))
289 + if(!strcmp(s, "yes"))
290 return CONFIG_ONDEMAND_YES;
291 - else if(!strsame(s, "no"))
291 + else if(!strcmp(s, "no"))
292 return CONFIG_ONDEMAND_NO;
293 - else if(!strsame(s, "auto") || !strsame(s, "on demand"))
293 + else if(!strcmp(s, "auto") || !strcmp(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(strsame(cv->value, value) != 0) {
316 + if(strcmp(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(strsame(cv->value, value) != 0) {
339 + if(strcmp(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(!strsame(co->name, "global") ||
496 - !strsame(co->name, "plugins") ||
497 - !strsame(co->name, "registry") ||
498 - !strsame(co->name, "health") ||
499 - !strsame(co->name, "backend"))
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"))
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 && strsame(name, target->name) == 0)
221 + if(!target->target && strcmp(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 strsame(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
950 + return strcmp(((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(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;
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;
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(strsame(de->d_name, ".") == 0 || strsame(de->d_name, "..") == 0)
1176 + if(strcmp(de->d_name, ".") == 0 || strcmp(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 && !strsame(w->compare, p->comm))
1650 + if( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strcmp(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 && !strsame(w->compare, &p->comm[pclen - w->comparelen]))
1652 + || (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strcmp(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(strsame("version", argv[i]) == 0 || strsame("-v", argv[i]) == 0) {
2687 + if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
2688 printf("apps.plugin %s\n", VERSION);
2689 exit(0);
2690 }
2691
2692 - if(strsame("debug", argv[i]) == 0) {
2692 + if(strcmp("debug", argv[i]) == 0) {
2693 debug = 1;
2694 // debug_flags = 0xffffffff;
2695 continue;
2696 }
2697
2698 - if(strsame("no-childs", argv[i]) == 0 || strsame("without-childs", argv[i]) == 0) {
2698 + if(strcmp("no-childs", argv[i]) == 0 || strcmp("without-childs", argv[i]) == 0) {
2699 include_exited_childs = 0;
2700 continue;
2701 }
2702
2703 - if(strsame("with-childs", argv[i]) == 0) {
2703 + if(strcmp("with-childs", argv[i]) == 0) {
2704 include_exited_childs = 1;
2705 continue;
2706 }
2707
2708 - if(strsame("with-guest", argv[i]) == 0) {
2708 + if(strcmp("with-guest", argv[i]) == 0) {
2709 enable_guest_charts = 1;
2710 continue;
2711 }
2712
2713 - if(strsame("no-guest", argv[i]) == 0 || strsame("without-guest", argv[i]) == 0) {
2713 + if(strcmp("no-guest", argv[i]) == 0 || strcmp("without-guest", argv[i]) == 0) {
2714 enable_guest_charts = 0;
2715 continue;
2716 }
2717
2718 - if(strsame("with-files", argv[i]) == 0) {
2718 + if(strcmp("with-files", argv[i]) == 0) {
2719 enable_file_charts = 1;
2720 continue;
2721 }
2722
2723 - if(strsame("no-files", argv[i]) == 0 || strsame("without-files", argv[i]) == 0) {
2723 + if(strcmp("no-files", argv[i]) == 0 || strcmp("without-files", argv[i]) == 0) {
2724 enable_file_charts = 0;
2725 continue;
2726 }
2727
2728 - if(strsame("no-users", argv[i]) == 0 || strsame("without-users", argv[i]) == 0) {
2728 + if(strcmp("no-users", argv[i]) == 0 || strcmp("without-users", argv[i]) == 0) {
2729 enable_users_charts = 0;
2730 continue;
2731 }
2732
2733 - if(strsame("no-groups", argv[i]) == 0 || strsame("without-groups", argv[i]) == 0) {
2733 + if(strcmp("no-groups", argv[i]) == 0 || strcmp("without-groups", argv[i]) == 0) {
2734 enable_groups_charts = 0;
2735 continue;
2736 }
2737
2738 - if(strsame("-h", argv[i]) == 0 || strsame("--help", argv[i]) == 0) {
2738 + if(strcmp("-h", argv[i]) == 0 || strcmp("--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(!strsame(source, "as collected")) {
172 + if(!strcmp(source, "as collected")) {
173 options = BACKEND_SOURCE_DATA_AS_COLLECTED;
174 }
175 - else if(!strsame(source, "average")) {
175 + else if(!strcmp(source, "average")) {
176 options = BACKEND_SOURCE_DATA_AVERAGE;
177 }
178 - else if(!strsame(source, "sum") || !strsame(source, "volume")) {
178 + else if(!strcmp(source, "sum") || !strcmp(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(!strsame(type, "graphite") || !strsame(type, "graphite:plaintext")) {
186 + if(!strcmp(type, "graphite") || !strcmp(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(!strsame(type, "opentsdb") || !strsame(type, "opentsdb:telnet")) {
195 + else if(!strcmp(type, "opentsdb") || !strcmp(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 strsame(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
59 + else return strcmp(((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 && !strsame(v->name, "this"))) {
80 + if(unlikely(v->hash == this_hash && !strcmp(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 && !strsame(v->name, "after"))) {
88 + if(unlikely(v->hash == after_hash && !strcmp(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 && !strsame(v->name, "before"))) {
96 + if(unlikely(v->hash == before_hash && !strcmp(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 && !strsame(v->name, "now"))) {
104 + if(unlikely(v->hash == now_hash && !strcmp(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 && !strsame(v->name, "status"))) {
112 + if(unlikely(v->hash == status_hash && !strcmp(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 && !strsame(v->name, "REMOVED"))) {
120 + if(unlikely(v->hash == removed_hash && !strcmp(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 && !strsame(v->name, "UNINITIALIZED"))) {
128 + if(unlikely(v->hash == uninitialized_hash && !strcmp(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 && !strsame(v->name, "UNDEFINED"))) {
136 + if(unlikely(v->hash == undefined_hash && !strcmp(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 && !strsame(v->name, "CLEAR"))) {
144 + if(unlikely(v->hash == clear_hash && !strcmp(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 && !strsame(v->name, "WARNING"))) {
152 + if(unlikely(v->hash == warning_hash && !strcmp(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 && !strsame(v->name, "CRITICAL"))) {
160 + if(unlikely(v->hash == critical_hash && !strcmp(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/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(strsame(pointers[1], host->hostname))
235 + //if(strcmp(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 strsame(((RRDVAR *)a)->name, ((RRDVAR *)b)->name);
456 + else return strcmp(((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 && !strsame(rc->chart, st->id)) ||
1104 - (rc->hash_chart == st->hash_name && !strsame(rc->chart, st->name)))
1103 + if( (rc->hash_chart == st->hash && !strcmp(rc->chart, st->id)) ||
1104 + (rc->hash_chart == st->hash_name && !strcmp(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 && !strsame(rc->name, name)))
1179 + if(unlikely(rc->hash == hash && !strcmp(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 && !strsame(name, rc->name) && !strsame(chart, rc->chart))) {
1199 + if (unlikely(rc->chart && rc->hash == hash_name && rc->hash_chart == hash_chart && !strcmp(name, rc->name) && !strcmp(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 && !strsame(name, ae->name) && !strsame(chart, ae->chart))) {
1217 + if(unlikely(ae->hash_name == hash_name && ae->hash_chart == hash_chart && !strcmp(name, ae->name) && !strcmp(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 && !strsame(rt->context, st->context)
1403 + if(rt->hash_context == st->hash_context && !strcmp(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 && !strsame(t->name, rt->name))) {
1543 + if(unlikely(t->hash_name == rt->hash_name && !strcmp(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(strsame(rc->chart, value))
1958 + if(strcmp(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(strsame(rc->exec, value))
2022 + if(strcmp(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(strsame(rc->recipient, value))
2032 + if(strcmp(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(strsame(rc->units, value))
2042 + if(strcmp(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(strsame(rc->info, value))
2053 + if(strcmp(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(strsame(rt->context, value))
2073 + if(strcmp(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(strsame(rt->exec, value))
2143 + if(strcmp(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(strsame(rt->recipient, value))
2153 + if(strcmp(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(strsame(rt->units, value))
2163 + if(strcmp(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(strsame(rt->info, value))
2174 + if(strcmp(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 && !strsame(&de->d_name[len - 5], ".conf")) {
2242 + len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) {
2243 health_readfile(path, de->d_name);
2244 }
2245
src/inlined.h
+15 -4
@@ -27,6 +27,19 @@ static inline uint32_t simple_uhash(const char *name) {
27 return hval;
28 }
29
30 +static inline int simple_hash_strcmp(const char *name, const char *b, uint32_t *hash) {
31 + unsigned char *s = (unsigned char *) name;
32 + uint32_t hval = 0x811c9dc5;
33 + int ret = 0;
34 + while (*s) {
35 + if(!ret) ret = *s - *b++;
36 + hval *= 16777619;
37 + hval ^= (uint32_t) *s++;
38 + }
39 + *hash = hval;
40 + return ret;
41 +}
42 +
43 static inline int str2i(const char *s) {
44 int n = 0;
45 char c, negative = (*s == '-');
@@ -77,14 +90,12 @@ static inline unsigned long long str2ull(const char *s) {
90 return n;
91 }
92
80 -#ifdef NETDATA_STRSAME
81 -static inline int strsame(const char *a, const char *b) {
93 +#ifdef NETDATA_STRCMP_OVERRIDE
94 +static inline int strcmp(const char *a, const char *b) {
95 if(unlikely(a == b)) return 0;
96 while(*a && *a == *b) { a++; b++; }
97 return *a - *b;
98 }
86 -#else
87 -#define strsame(a, b) strcmp(a, b)
99 #endif // NETDATA_STRSAME
100
101 static inline int read_single_number_file(const char *filename, unsigned long long *result) {
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 || !strsame(filename, "none"))
29 + if(!filename || !*filename || !strcmp(filename, "none"))
30 filename = "/dev/null";
31
32 - if(!strsame(filename, "syslog")) {
32 + if(!strcmp(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(!strsame(filename, "system")) {
41 + if(!strcmp(filename, "system")) {
42 if(fd != -1) return fd;
43 filename = "stdout";
44 }
45
46 - if(!strsame(filename, "stdout"))
46 + if(!strcmp(filename, "stdout"))
47 f = STDOUT_FILENO;
48
49 - else if(!strsame(filename, "stderr"))
49 + else if(!strcmp(filename, "stderr"))
50 f = STDERR_FILENO;
51
52 else {
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(!strsame(s, "default"))
80 + if(!strcmp(s, "default"))
81 web_gzip_strategy = Z_DEFAULT_STRATEGY;
82 - else if(!strsame(s, "filtered"))
82 + else if(!strcmp(s, "filtered"))
83 web_gzip_strategy = Z_FILTERED;
84 - else if(!strsame(s, "huffman only"))
84 + else if(!strcmp(s, "huffman only"))
85 web_gzip_strategy = Z_HUFFMAN_ONLY;
86 - else if(!strsame(s, "rle"))
86 + else if(!strcmp(s, "rle"))
87 web_gzip_strategy = Z_RLE;
88 - else if(!strsame(s, "fixed"))
88 + else if(!strcmp(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(strsame(argv[i], "-pidfile") == 0 && (i+1) < argc) {
354 + if(strcmp(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(strsame(argv[i], "-nodaemon") == 0 || strsame(argv[i], "-nd") == 0) {
359 + else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(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(strsame(argv[i], "-ch") == 0 && (i+1) < argc) {
364 + else if(strcmp(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(strsame(argv[i], "-l") == 0 && (i+1) < argc) {
369 + else if(strcmp(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(strsame(optarg, "unittest") == 0) {
446 + if(strcmp(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(strsame(optarg, "simple-pattern") == 0) {
453 + else if(strcmp(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 strsame(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
95 + else return strcmp(((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 strsame(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
121 + else return strcmp(((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))
@@ -221,8 +221,8 @@ static inline void tc_device_commit(struct tc_device *d) {
221 if(unlikely(c == x)) continue;
222
223 if(x->parentid && (
224 - ( c->hash == x->parent_hash && strsame(c->id, x->parentid) == 0) ||
225 - (c->leafid && c->leaf_hash == x->parent_hash && strsame(c->leafid, x->parentid) == 0))) {
224 + ( c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
225 + (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0))) {
226 // 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);
227 c->isleaf = 0;
228 x->hasparent = 1;
@@ -314,7 +314,7 @@ static inline void tc_device_commit(struct tc_device *d) {
314 debug(D_TC_LOOP, "TC: Updating chart for device '%s'", d->name?d->name:d->id);
315 rrdset_next(d->st_bytes);
316
317 - if(unlikely(d->name_updated && d->name && strsame(d->id, d->name) != 0)) {
317 + if(unlikely(d->name_updated && d->name && strcmp(d->id, d->name) != 0)) {
318 rrdset_set_name(d->st_bytes, d->name);
319 d->name_updated = 0;
320 }
@@ -341,7 +341,7 @@ static inline void tc_device_commit(struct tc_device *d) {
341 rrddim_set_by_pointer(d->st_bytes, c->rd_bytes, c->bytes);
342
343 // if it has a name, different to the id
344 - if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
344 + if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
345 // update the rrd dimension with the new name
346 debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_bytes->id, c->rd_bytes->id, c->name);
347 rrddim_set_name(d->st_bytes, c->rd_bytes, c->name);
@@ -395,7 +395,7 @@ static inline void tc_device_commit(struct tc_device *d) {
395 rrddim_set_by_pointer(d->st_packets, c->rd_packets, c->packets);
396
397 // if it has a name, different to the id
398 - if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
398 + if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
399 // update the rrd dimension with the new name
400 debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_packets->id, c->rd_packets->id, c->name);
401 rrddim_set_name(d->st_packets, c->rd_packets, c->name);
@@ -449,7 +449,7 @@ static inline void tc_device_commit(struct tc_device *d) {
449 rrddim_set_by_pointer(d->st_dropped, c->rd_dropped, c->dropped);
450
451 // if it has a name, different to the id
452 - if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
452 + if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
453 // update the rrd dimension with the new name
454 debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_dropped->id, c->rd_dropped->id, c->name);
455 rrddim_set_name(d->st_dropped, c->rd_dropped, c->name);
@@ -503,7 +503,7 @@ static inline void tc_device_commit(struct tc_device *d) {
503 rrddim_set_by_pointer(d->st_tokens, c->rd_tokens, c->tokens);
504
505 // if it has a name, different to the id
506 - if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
506 + if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
507 // update the rrd dimension with the new name
508 debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_tokens->id, c->rd_tokens->id, c->name);
509 rrddim_set_name(d->st_tokens, c->rd_tokens, c->name);
@@ -557,7 +557,7 @@ static inline void tc_device_commit(struct tc_device *d) {
557 rrddim_set_by_pointer(d->st_ctokens, c->rd_ctokens, c->ctokens);
558
559 // if it has a name, different to the id
560 - if(unlikely(c->name_updated && c->name && strsame(c->id, c->name) != 0)) {
560 + if(unlikely(c->name_updated && c->name && strcmp(c->id, c->name) != 0)) {
561 // update the rrd dimension with the new name
562 debug(D_TC_LOOP, "TC: Setting chart '%s', dimension '%s' name to '%s'", d->st_ctokens->id, c->rd_ctokens->id, c->name);
563 rrddim_set_name(d->st_ctokens, c->rd_ctokens, c->name);
@@ -578,7 +578,7 @@ static inline void tc_device_set_class_name(struct tc_device *d, char *id, char
578 freez(c->name);
579 c->name = NULL;
580
581 - if(likely(name && *name && strsame(c->id, name) != 0)) {
581 + if(likely(name && *name && strcmp(c->id, name) != 0)) {
582 debug(D_TC_LOOP, "TC: Setting device '%s', class '%s' name to '%s'", d->id, id, name);
583 c->name = strdupz(name);
584 c->name_updated = 1;
@@ -590,7 +590,7 @@ static inline void tc_device_set_device_name(struct tc_device *d, char *name) {
590 freez(d->name);
591 d->name = NULL;
592
593 - if(likely(name && *name && strsame(d->id, name) != 0)) {
593 + if(likely(name && *name && strcmp(d->id, name) != 0)) {
594 debug(D_TC_LOOP, "TC: Setting device '%s' name to '%s'", d->id, name);
595 d->name = strdupz(name);
596 d->name_updated = 1;
@@ -601,7 +601,7 @@ static inline void tc_device_set_device_family(struct tc_device *d, char *family
601 freez(d->family);
602 d->family = NULL;
603
604 - if(likely(family && *family && strsame(d->id, family) != 0)) {
604 + if(likely(family && *family && strcmp(d->id, family) != 0)) {
605 debug(D_TC_LOOP, "TC: Setting device '%s' family to '%s'", d->id, family);
606 d->family = strdupz(family);
607 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 && strsame(words[0], "class") == 0)) {
818 + if(unlikely(device && first_hash == CLASS_HASH && strcmp(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] && (strsame(words[3], "parent") == 0 || strsame(words[3], "root") == 0))) {
824 + if(likely(words[1] && words[2] && words[3] && (strcmp(words[3], "parent") == 0 || strcmp(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(strsame(type, "htb") != 0) continue;
828 + //if(strcmp(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(strsame(parent, "root") == 0) {
836 + if(strcmp(parent, "root") == 0) {
837 parentid = NULL;
838 leafid = NULL;
839 }
840 - else if(!leaf || strsame(leaf, "leaf") != 0)
840 + else if(!leaf || strcmp(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 && strsame(words[0], "END") == 0)) {
857 + else if(unlikely(first_hash == END_HASH && strcmp(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 && strsame(words[0], "BEGIN") == 0)) {
874 + else if(unlikely(first_hash == BEGIN_HASH && strcmp(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 && strsame(words[0], "Sent") == 0)) {
887 + else if(unlikely(device && class && first_hash == SENT_HASH && strcmp(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 && strsame(words[0], "lended:") == 0)) {
909 + else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strcmp(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 && strsame(words[0], "tokens:") == 0)) {
920 + else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strcmp(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 && strsame(words[0], "SETDEVICENAME") == 0)) {
928 + else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strcmp(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 && strsame(words[0], "SETDEVICEGROUP") == 0)) {
933 + else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strcmp(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 && strsame(words[0], "SETCLASSNAME") == 0)) {
938 + else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strcmp(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 && strsame(words[0], "WORKTIME") == 0)) {
945 + else if(unlikely(first_hash == WORKTIME_HASH && strcmp(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 && (strsame(words[0], "MYPID") == 0))) {
973 + else if(unlikely(first_hash == MYPID_HASH && (strcmp(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 -16
@@ -97,7 +97,6 @@ void *pluginsd_worker_thread(void *arg)
97 #endif
98
99 char *words[MAX_WORDS] = { NULL };
100 - uint32_t SET_HASH = simple_hash("SET");
100 uint32_t BEGIN_HASH = simple_hash("BEGIN");
101 uint32_t END_HASH = simple_hash("END");
102 uint32_t FLUSH_HASH = simple_hash("FLUSH");
@@ -141,9 +140,7 @@ void *pluginsd_worker_thread(void *arg)
140
141 // debug(D_PLUGINSD, "PLUGINSD: words 0='%s' 1='%s' 2='%s' 3='%s' 4='%s' 5='%s' 6='%s' 7='%s' 8='%s' 9='%s'", words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
142
144 - hash = simple_hash(s);
145 -
146 - if(likely(hash == SET_HASH && !strsame(s, "SET"))) {
143 + if(likely(!simple_hash_strcmp(s, "SET", &hash))) {
144 char *dimension = words[1];
145 char *value = words[2];
146
@@ -167,7 +164,7 @@ void *pluginsd_worker_thread(void *arg)
164
165 if(value) rrddim_set(st, dimension, strtoll(value, NULL, 0));
166 }
170 - else if(likely(hash == BEGIN_HASH && !strsame(s, "BEGIN"))) {
167 + else if(likely(hash == BEGIN_HASH && !strcmp(s, "BEGIN"))) {
168 char *id = words[1];
169 char *microseconds_txt = words[2];
170
@@ -193,7 +190,7 @@ void *pluginsd_worker_thread(void *arg)
190 else rrdset_next(st);
191 }
192 }
196 - else if(likely(hash == END_HASH && !strsame(s, "END"))) {
193 + else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
194 if(unlikely(!st)) {
195 error("PLUGINSD: '%s' is requesting an END, without a BEGIN. Disabling it.", cd->fullfilename);
196 cd->enabled = 0;
@@ -208,15 +205,15 @@ void *pluginsd_worker_thread(void *arg)
205
206 count++;
207 }
211 - else if(likely(hash == FLUSH_HASH && !strsame(s, "FLUSH"))) {
208 + else if(likely(hash == FLUSH_HASH && !strcmp(s, "FLUSH"))) {
209 debug(D_PLUGINSD, "PLUGINSD: '%s' is requesting a FLUSH", cd->fullfilename);
210 st = NULL;
211 }
215 - else if(likely(hash == CHART_HASH && !strsame(s, "CHART"))) {
212 + else if(likely(hash == CHART_HASH && !strcmp(s, "CHART"))) {
213 int noname = 0;
214 st = NULL;
215
219 - if((words[1]) != NULL && (words[2]) != NULL && strsame(words[1], words[2]) == 0)
216 + if((words[1]) != NULL && (words[2]) != NULL && strcmp(words[1], words[2]) == 0)
217 noname = 1;
218
219 char *type = words[1];
@@ -272,7 +269,7 @@ void *pluginsd_worker_thread(void *arg)
269 }
270 else debug(D_PLUGINSD, "PLUGINSD: Chart '%s' already exists. Not adding it again.", st->id);
271 }
275 - else if(likely(hash == DIMENSION_HASH && !strsame(s, "DIMENSION"))) {
272 + else if(likely(hash == DIMENSION_HASH && !strcmp(s, "DIMENSION"))) {
273 char *id = words[1];
274 char *name = words[2];
275 char *algorithm = words[3];
@@ -326,21 +323,21 @@ void *pluginsd_worker_thread(void *arg)
323 }
324 else if(unlikely(st->debug)) debug(D_PLUGINSD, "PLUGINSD: dimension %s/%s already exists. Not adding it again.", st->id, id);
325 }
329 - else if(unlikely(hash == DISABLE_HASH && !strsame(s, "DISABLE"))) {
326 + else if(unlikely(hash == DISABLE_HASH && !strcmp(s, "DISABLE"))) {
327 info("PLUGINSD: '%s' called DISABLE. Disabling it.", cd->fullfilename);
328 cd->enabled = 0;
329 killpid(cd->pid, SIGTERM);
330 break;
331 }
332 #ifdef DETACH_PLUGINS_FROM_NETDATA
336 - else if(likely(hash == MYPID_HASH && !strsame(s, "MYPID"))) {
333 + else if(likely(hash == MYPID_HASH && !strcmp(s, "MYPID"))) {
334 char *pid_s = words[1];
335 pid_t pid = strtod(pid_s, NULL, 0);
336
337 if(likely(pid)) cd->pid = pid;
338 debug(D_PLUGINSD, "PLUGINSD: %s is on pid %d", cd->id, cd->pid);
339 }
343 - else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strsame(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
340 + else if(likely(hash == STOPPING_WAKE_ME_UP_PLEASE_HASH && !strcmp(s, "STOPPING_WAKE_ME_UP_PLEASE"))) {
341 error("PLUGINSD: '%s' (pid %d) called STOPPING_WAKE_ME_UP_PLEASE.", cd->fullfilename, cd->pid);
342
343 now_realtime_timeval(&now);
@@ -472,11 +469,11 @@ void *pluginsd_main(void *ptr) {
469
470 debug(D_PLUGINSD, "PLUGINSD: Examining file '%s'", file->d_name);
471
475 - if(unlikely(strsame(file->d_name, ".") == 0 || strsame(file->d_name, "..") == 0)) continue;
472 + if(unlikely(strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)) continue;
473
474 int len = (int) strlen(file->d_name);
475 if(unlikely(len <= (int)PLUGINSD_FILE_SUFFIX_LEN)) continue;
479 - if(unlikely(strsame(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
476 + if(unlikely(strcmp(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
477 debug(D_PLUGINSD, "PLUGINSD: File '%s' does not end in '%s'.", file->d_name, PLUGINSD_FILE_SUFFIX);
478 continue;
479 }
@@ -492,7 +489,7 @@ void *pluginsd_main(void *ptr) {
489
490 // check if it runs already
491 for(cd = pluginsd_root ; cd ; cd = cd->next)
495 - if(unlikely(strsame(cd->filename, file->d_name) == 0)) break;
492 + if(unlikely(strcmp(cd->filename, file->d_name) == 0)) break;
493
494 if(likely(cd && !cd->obsolete)) {
495 debug(D_PLUGINSD, "PLUGINSD: plugin '%s' is already running", cd->filename);
src/proc_diskstats.c
+1 -1
@@ -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(strsame(dp->d_name, ".") == 0 || strsame(dp->d_name, "..") == 0)) {
94 + if(unlikely(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)) {
95 continue;
96 }
97
src/proc_net_dev.c
+2 -2
@@ -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 && !strsame(name, d->name))) {
80 + if(unlikely(hash == d->hash && !strcmp(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 && !strsame(name, d->name))) {
88 + if(unlikely(hash == d->hash && !strcmp(name, d->name))) {
89 last = d->next;
90 return d;
91 }
src/proc_net_netstat.c
+2 -2
@@ -182,7 +182,7 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
182 char *key = procfile_lineword(ff, l, 0);
183 uint32_t hash = simple_hash(key);
184
185 - if(unlikely(hash == hash_ipext && strsame(key, "IpExt") == 0)) {
185 + if(unlikely(hash == hash_ipext && strcmp(key, "IpExt") == 0)) {
186 size_t h = l++;
187
188 words = procfile_linewords(ff, l);
@@ -334,7 +334,7 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
334 rrdset_done(st);
335 }
336 }
337 - else if(unlikely(hash == hash_tcpext && strsame(key, "TcpExt") == 0)) {
337 + else if(unlikely(hash == hash_tcpext && strcmp(key, "TcpExt") == 0)) {
338 size_t h = l++;
339
340 words = procfile_linewords(ff, l);
src/proc_net_rpc_nfs.c
+6 -6
@@ -151,7 +151,7 @@ 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 strsame() for all lines
154 + // later we do them =2 to avoid doing strcmp() for all lines
155 if(do_net) do_net = 1;
156 if(do_rpc) do_rpc = 1;
157 if(do_proc2) do_proc2 = 1;
@@ -170,7 +170,7 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
170
171 type = procfile_lineword(ff, l, 0);
172
173 - if(do_net == 1 && strsame(type, "net") == 0) {
173 + if(do_net == 1 && strcmp(type, "net") == 0) {
174 if(words < 5) {
175 error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 5);
176 continue;
@@ -185,7 +185,7 @@ 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 && strsame(type, "rpc") == 0) {
188 + else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
189 if(words < 4) {
190 error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 6);
191 continue;
@@ -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 && strsame(type, "proc2") == 0) {
202 + else if(do_proc2 == 1 && strcmp(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 && strsame(type, "proc3") == 0) {
223 + else if(do_proc3 == 1 && strcmp(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 && strsame(type, "proc4") == 0) {
244 + else if(do_proc4 == 1 && strcmp(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
+12 -12
@@ -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 strsame() for all lines
242 + // later we do them =2 to avoid doing strcmp() for all lines
243 if(do_rc) do_rc = 1;
244 if(do_fh) do_fh = 1;
245 if(do_io) do_io = 1;
@@ -269,7 +269,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
269
270 type = procfile_lineword(ff, l, 0);
271
272 - if(do_rc == 1 && strsame(type, "rc") == 0) {
272 + if(do_rc == 1 && strcmp(type, "rc") == 0) {
273 if(words < 4) {
274 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 4);
275 continue;
@@ -283,7 +283,7 @@ 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 && strsame(type, "fh") == 0) {
286 + else if(do_fh == 1 && strcmp(type, "fh") == 0) {
287 if(words < 6) {
288 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
289 continue;
@@ -299,7 +299,7 @@ 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 && strsame(type, "io") == 0) {
302 + else if(do_io == 1 && strcmp(type, "io") == 0) {
303 if(words < 3) {
304 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 3);
305 continue;
@@ -312,7 +312,7 @@ 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 && strsame(type, "th") == 0) {
315 + else if(do_th == 1 && strcmp(type, "th") == 0) {
316 if(words < 13) {
317 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
318 continue;
@@ -343,7 +343,7 @@ 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 && strsame(type, "ra") == 0) {
346 + else if(do_ra == 1 && strcmp(type, "ra") == 0) {
347 if(words < 13) {
348 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 13);
349 continue;
@@ -372,7 +372,7 @@ 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 && strsame(type, "net") == 0) {
375 + else if(do_net == 1 && strcmp(type, "net") == 0) {
376 if(words < 5) {
377 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 5);
378 continue;
@@ -387,7 +387,7 @@ 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 && strsame(type, "rpc") == 0) {
390 + else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
391 if(words < 6) {
392 error("%s line of /proc/net/rpc/nfsd has %zu words, expected %d", type, words, 6);
393 continue;
@@ -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 && strsame(type, "proc2") == 0) {
405 + else if(do_proc2 == 1 && strcmp(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 && strsame(type, "proc3") == 0) {
426 + else if(do_proc3 == 1 && strcmp(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 && strsame(type, "proc4") == 0) {
447 + else if(do_proc4 == 1 && strcmp(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 && strsame(type, "proc4ops") == 0) {
468 + else if(do_proc4ops == 1 && strcmp(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
+14 -14
@@ -165,7 +165,7 @@ 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++)
168 - if(unlikely(nc[i].hash == hash && !strsame(nc[i].name, name)))
168 + if(unlikely(nc[i].hash == hash && !strcmp(nc[i].name, name)))
169 return &nc[i].value;
170
171 fatal("Cannot find key '%s' in /proc/net/snmp internal array.", name);
@@ -186,7 +186,7 @@ static void parse_line_pair(procfile *ff, struct netstat_columns *nc, size_t hea
186 uint32_t hash = simple_hash(key);
187
188 for(i = 0 ; nc[i].name ;i++) {
189 - if(unlikely(hash == nc[i].hash && !strsame(key, nc[i].name))) {
189 + if(unlikely(hash == nc[i].hash && !strcmp(key, nc[i].name))) {
190 nc[i].value = str2ull(procfile_lineword(ff, values_line, w));
191 break;
192 }
@@ -372,10 +372,10 @@ 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
375 - if(unlikely(hash == hash_ip && strsame(key, "Ip") == 0)) {
375 + if(unlikely(hash == hash_ip && strcmp(key, "Ip") == 0)) {
376 size_t h = l++;
377
378 - if(strsame(procfile_lineword(ff, l, 0), "Ip") != 0) {
378 + if(strcmp(procfile_lineword(ff, l, 0), "Ip") != 0) {
379 error("Cannot read Ip line from /proc/net/snmp.");
380 break;
381 }
@@ -478,10 +478,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
478 rrdset_done(st);
479 }
480 }
481 - else if(unlikely(hash == hash_icmp && strsame(key, "Icmp") == 0)) {
481 + else if(unlikely(hash == hash_icmp && strcmp(key, "Icmp") == 0)) {
482 size_t h = l++;
483
484 - if(strsame(procfile_lineword(ff, l, 0), "Icmp") != 0) {
484 + if(strcmp(procfile_lineword(ff, l, 0), "Icmp") != 0) {
485 error("Cannot read Icmp line from /proc/net/snmp.");
486 break;
487 }
@@ -528,10 +528,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
528 rrdset_done(st);
529 }
530 }
531 - else if(unlikely(hash == hash_icmpmsg && strsame(key, "IcmpMsg") == 0)) {
531 + else if(unlikely(hash == hash_icmpmsg && strcmp(key, "IcmpMsg") == 0)) {
532 size_t h = l++;
533
534 - if(strsame(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
534 + if(strcmp(procfile_lineword(ff, l, 0), "IcmpMsg") != 0) {
535 error("Cannot read IcmpMsg line from /proc/net/snmp.");
536 break;
537 }
@@ -558,10 +558,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
558 rrdset_done(st);
559 }
560 }
561 - else if(unlikely(hash == hash_tcp && strsame(key, "Tcp") == 0)) {
561 + else if(unlikely(hash == hash_tcp && strcmp(key, "Tcp") == 0)) {
562 size_t h = l++;
563
564 - if(strsame(procfile_lineword(ff, l, 0), "Tcp") != 0) {
564 + if(strcmp(procfile_lineword(ff, l, 0), "Tcp") != 0) {
565 error("Cannot read Tcp line from /proc/net/snmp.");
566 break;
567 }
@@ -651,10 +651,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
651 rrdset_done(st);
652 }
653 }
654 - else if(unlikely(hash == hash_udp && strsame(key, "Udp") == 0)) {
654 + else if(unlikely(hash == hash_udp && strcmp(key, "Udp") == 0)) {
655 size_t h = l++;
656
657 - if(strsame(procfile_lineword(ff, l, 0), "Udp") != 0) {
657 + if(strcmp(procfile_lineword(ff, l, 0), "Udp") != 0) {
658 error("Cannot read Udp line from /proc/net/snmp.");
659 break;
660 }
@@ -711,10 +711,10 @@ int do_proc_net_snmp(int update_every, usec_t dt) {
711 rrdset_done(st);
712 }
713 }
714 - else if(unlikely(hash == hash_udplite && strsame(key, "UdpLite") == 0)) {
714 + else if(unlikely(hash == hash_udplite && strcmp(key, "UdpLite") == 0)) {
715 size_t h = l++;
716
717 - if(strsame(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
717 + if(strcmp(procfile_lineword(ff, l, 0), "UdpLite") != 0) {
718 error("Cannot read UdpLite line from /proc/net/snmp.");
719 break;
720 }
src/proc_self_mountinfo.c
+21 -21
@@ -11,35 +11,35 @@
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))
14 + && (strcmp (Fs_type, "smbfs") == 0 \
15 + || strcmp (Fs_type, "cifs") == 0)) \
16 + || (strcmp("-hosts", Fs_name) == 0))
17 #endif
18
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 \
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 - || 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 \
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 - || strsame (Fs_type, "devfs") == 0 \
31 + || strcmp (Fs_type, "devfs") == 0 \
32 /* for NetBSD 3.0 */ \
33 - || strsame (Fs_type, "kernfs") == 0 \
33 + || strcmp (Fs_type, "kernfs") == 0 \
34 /* for Irix 6.5 */ \
35 - || strsame (Fs_type, "ignore") == 0)
35 + || strcmp (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) || strsame (Fs_type, "none") == 0)
42 + (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (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 - && !strsame(mi->filesystem, filesystem)
70 - && !strsame(mi->mount_source, mount_source)))
69 + && !strcmp(mi->filesystem, filesystem)
70 + && !strcmp(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 - && !strsame(mi->filesystem, filesystem))) {
86 + && !strcmp(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(!strsame(s, "ro")) return 1;
166 + if(!strcmp(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(strsame(mnt->mnt_dir, mi->mount_point) == 0)) {
379 + if(unlikely(strcmp(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_stat.c
+6 -6
@@ -73,7 +73,7 @@ int do_proc_stat(int update_every, usec_t dt) {
73 long priority;
74 int isthistotal;
75
76 - if(unlikely(strsame(id, "cpu")) == 0) {
76 + if(unlikely(strcmp(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 && strsame(row_key, "intr") == 0)) {
129 + else if(unlikely(hash == hash_intr && strcmp(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 && strsame(row_key, "ctxt") == 0)) {
148 + else if(unlikely(hash == hash_ctxt && strcmp(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 && strsame(row_key, "processes") == 0)) {
166 + else if(unlikely(hash == hash_processes && !processes && strcmp(row_key, "processes") == 0)) {
167 processes = str2ull(procfile_lineword(ff, l, 1));
168 }
169 - else if(unlikely(hash == hash_procs_running && !running && strsame(row_key, "procs_running") == 0)) {
169 + else if(unlikely(hash == hash_procs_running && !running && strcmp(row_key, "procs_running") == 0)) {
170 running = str2ull(procfile_lineword(ff, l, 1));
171 }
172 - else if(unlikely(hash == hash_procs_blocked && !blocked && strsame(row_key, "procs_blocked") == 0)) {
172 + else if(unlikely(hash == hash_procs_blocked && !blocked && strcmp(row_key, "procs_blocked") == 0)) {
173 blocked = str2ull(procfile_lineword(ff, l, 1));
174 }
175 }
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] && !strsame(person_guid, REGISTRY_VERIFY_COOKIES_GUID)))
161 + if(unlikely(person_guid[0] && !strcmp(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(strsame(guid, result))
20 + if(strcmp(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(!strsame(delete_url, pu->url->url)) {
178 + if(!strcmp(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(!strsame(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
268 - || !strsame(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
267 + if(!strcmp(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
268 + || !strcmp(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 strsame(((REGISTRY_PERSON_URL *)a)->url->url, ((REGISTRY_PERSON_URL *)b)->url->url);
12 + else return strcmp(((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(strsame(pu->machine_name, name)) {
245 + if(strcmp(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 strsame(((REGISTRY_URL *)a)->url, ((REGISTRY_URL *)b)->url);
9 + else return strcmp(((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 strsame(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
94 + else return strcmp(((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 strsame(((RRDSET *)a)->id, ((RRDSET *)b)->id);
149 + else return strcmp(((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 strsame(A->name, B->name);
176 + else return strcmp(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(strsame(st->magic, RRDSET_MAGIC))
205 + if(strcmp(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 strsame(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
222 + else return strcmp(((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(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;
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;
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(!strsame(name, RRD_MEMORY_MODE_RAM_NAME)))
292 + if(unlikely(!strcmp(name, RRD_MEMORY_MODE_RAM_NAME)))
293 return RRD_MEMORY_MODE_RAM;
294 - else if(unlikely(!strsame(name, RRD_MEMORY_MODE_MAP_NAME)))
294 + else if(unlikely(!strcmp(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(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;
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;
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 && !strsame(st->name, name)))
356 + if(unlikely(st->name && !strcmp(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(strsame(st->magic, RRDSET_MAGIC) != 0) {
507 + if(strcmp(st->magic, RRDSET_MAGIC) != 0) {
508 errno = 0;
509 info("Initializing file %s.", fullfilename);
510 memset(st, 0, size);
511 }
512 - else if(strsame(st->id, fullid) != 0) {
512 + else if(strcmp(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(!strsame(st->id, "disk_util.dm-0")) {
591 + // if(!strcmp(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(strsame(rd->magic, RRDDIMENSION_MAGIC) != 0) {
675 + if(strcmp(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(strsame(rd->id, id) != 0) {
710 + else if(strcmp(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 && !strsame(rd->name, name)))
798 + if(unlikely(rd->name && !strcmp(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 && !strsame(d->id, tok)) || !strsame(d->name, tok))) {
564 + if(unlikely((hash == d->hash && !strcmp(d->id, tok)) || !strcmp(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(strsame(&str[len - m->len], m->match) == 0)) {
150 + if(unlikely(strcmp(&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(strsame(str, m->match) == 0)) {
158 + if(unlikely(strcmp(str, m->match) == 0)) {
159 if(!m->child) return 1;
160 return 0;
161 }
src/sys_fs_cgroup.c
+10 -10
@@ -424,10 +424,10 @@ static inline void cgroup_read_cpuacct_stat(struct cpuacct_stat *cp) {
424 char *s = procfile_lineword(ff, i, 0);
425 uint32_t hash = simple_hash(s);
426
427 - if(unlikely(hash == user_hash && !strsame(s, "user")))
427 + if(unlikely(hash == user_hash && !strcmp(s, "user")))
428 cp->user = str2ull(procfile_lineword(ff, i, 1));
429
430 - else if(unlikely(hash == system_hash && !strsame(s, "system")))
430 + else if(unlikely(hash == system_hash && !strcmp(s, "system")))
431 cp->system = str2ull(procfile_lineword(ff, i, 1));
432 }
433
@@ -534,20 +534,20 @@ static inline void cgroup_read_blkio(struct blkio *io) {
534 char *s = procfile_lineword(ff, i, 1);
535 uint32_t hash = simple_hash(s);
536
537 - if(unlikely(hash == Read_hash && !strsame(s, "Read")))
537 + if(unlikely(hash == Read_hash && !strcmp(s, "Read")))
538 io->Read += str2ull(procfile_lineword(ff, i, 2));
539
540 - else if(unlikely(hash == Write_hash && !strsame(s, "Write")))
540 + else if(unlikely(hash == Write_hash && !strcmp(s, "Write")))
541 io->Write += str2ull(procfile_lineword(ff, i, 2));
542
543 /*
544 - else if(unlikely(hash == Sync_hash && !strsame(s, "Sync")))
544 + else if(unlikely(hash == Sync_hash && !strcmp(s, "Sync")))
545 io->Sync += str2ull(procfile_lineword(ff, i, 2));
546
547 - else if(unlikely(hash == Async_hash && !strsame(s, "Async")))
547 + else if(unlikely(hash == Async_hash && !strcmp(s, "Async")))
548 io->Async += str2ull(procfile_lineword(ff, i, 2));
549
550 - else if(unlikely(hash == Total_hash && !strsame(s, "Total")))
550 + else if(unlikely(hash == Total_hash && !strcmp(s, "Total")))
551 io->Total += str2ull(procfile_lineword(ff, i, 2));
552 */
553 }
@@ -846,7 +846,7 @@ static inline struct cgroup *cgroup_add(const char *id) {
846 if(cg->enabled) {
847 struct cgroup *t;
848 for (t = cgroup_root; t; t = t->next) {
849 - if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
849 + if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
850 if (!strncmp(t->chart_id, "/system.slice/", 14) && !strncmp(cg->chart_id, "/init.scope/system.slice/", 25)) {
851 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'.",
852 cg->chart_id, t->id, cg->id, t->id);
@@ -914,7 +914,7 @@ static inline struct cgroup *cgroup_find(const char *id) {
914
915 struct cgroup *cg;
916 for(cg = cgroup_root; cg ; cg = cg->next) {
917 - if(hash == cg->hash && strsame(id, cg->id) == 0)
917 + if(hash == cg->hash && strcmp(id, cg->id) == 0)
918 break;
919 }
920
@@ -1034,7 +1034,7 @@ static inline void cleanup_all_cgroups() {
1034 {
1035 struct cgroup *t;
1036 for(t = cgroup_root; t ; t = t->next) {
1037 - 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)) {
1037 + 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 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);
1039 t->enabled = 1;
1040 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' || strsame(&b->buffer[b->size + 1], BUFFER_OVERFLOW_EOF)) {
24 + if(b->buffer[b->size] != '\0' || strcmp(&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
+17 -17
@@ -369,25 +369,25 @@ cleanup:
369 }
370
371 static inline const char *fix_units(const char *units) {
372 - if(!units || !*units || !strsame(units, "empty") || !strsame(units, "null")) return "";
373 - if(!strsame(units, "percentage") || !strsame(units, "percent") || !strsame(units, "pcent")) return "%";
372 + if(!units || !*units || !strcmp(units, "empty") || !strcmp(units, "null")) return "";
373 + if(!strcmp(units, "percentage") || !strcmp(units, "percent") || !strcmp(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(!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";
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";
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 || !strsame(value_buffer, "null"))
469 + if(!*value_buffer || !strcmp(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(!strsame(units, "seconds"))) {
528 + if(unlikely(!strcmp(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(!strsame(units, "minutes"))) {
545 + else if(unlikely(!strcmp(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(!strsame(units, "hours"))) {
559 + else if(unlikely(!strcmp(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(!strsame(tok, "nonzero"))
547 + if(!strcmp(tok, "nonzero"))
548 ret |= RRDR_OPTION_NONZERO;
549 - else if(!strsame(tok, "flip") || !strsame(tok, "reversed") || !strsame(tok, "reverse"))
549 + else if(!strcmp(tok, "flip") || !strcmp(tok, "reversed") || !strcmp(tok, "reverse"))
550 ret |= RRDR_OPTION_REVERSED;
551 - else if(!strsame(tok, "jsonwrap"))
551 + else if(!strcmp(tok, "jsonwrap"))
552 ret |= RRDR_OPTION_JSON_WRAP;
553 - else if(!strsame(tok, "min2max"))
553 + else if(!strcmp(tok, "min2max"))
554 ret |= RRDR_OPTION_MIN2MAX;
555 - else if(!strsame(tok, "ms") || !strsame(tok, "milliseconds"))
555 + else if(!strcmp(tok, "ms") || !strcmp(tok, "milliseconds"))
556 ret |= RRDR_OPTION_MILLISECONDS;
557 - else if(!strsame(tok, "abs") || !strsame(tok, "absolute") || !strsame(tok, "absolute_sum") || !strsame(tok, "absolute-sum"))
557 + else if(!strcmp(tok, "abs") || !strcmp(tok, "absolute") || !strcmp(tok, "absolute_sum") || !strcmp(tok, "absolute-sum"))
558 ret |= RRDR_OPTION_ABSOLUTE;
559 - else if(!strsame(tok, "seconds"))
559 + else if(!strcmp(tok, "seconds"))
560 ret |= RRDR_OPTION_SECONDS;
561 - else if(!strsame(tok, "null2zero"))
561 + else if(!strcmp(tok, "null2zero"))
562 ret |= RRDR_OPTION_NULL2ZERO;
563 - else if(!strsame(tok, "objectrows"))
563 + else if(!strcmp(tok, "objectrows"))
564 ret |= RRDR_OPTION_OBJECTSROWS;
565 - else if(!strsame(tok, "google_json"))
565 + else if(!strcmp(tok, "google_json"))
566 ret |= RRDR_OPTION_GOOGLE_JSON;
567 - else if(!strsame(tok, "percentage"))
567 + else if(!strcmp(tok, "percentage"))
568 ret |= RRDR_OPTION_PERCENTAGE;
569 - else if(!strsame(tok, "unaligned"))
569 + else if(!strcmp(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(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
578 + if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
579 return DATASOURCE_DATATABLE_JSON;
580
581 - else if(!strsame(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
581 + else if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
582 return DATASOURCE_DATATABLE_JSONP;
583
584 - else if(!strsame(name, DATASOURCE_FORMAT_JSON)) // json
584 + else if(!strcmp(name, DATASOURCE_FORMAT_JSON)) // json
585 return DATASOURCE_JSON;
586
587 - else if(!strsame(name, DATASOURCE_FORMAT_JSONP)) // jsonp
587 + else if(!strcmp(name, DATASOURCE_FORMAT_JSONP)) // jsonp
588 return DATASOURCE_JSONP;
589
590 - else if(!strsame(name, DATASOURCE_FORMAT_SSV)) // ssv
590 + else if(!strcmp(name, DATASOURCE_FORMAT_SSV)) // ssv
591 return DATASOURCE_SSV;
592
593 - else if(!strsame(name, DATASOURCE_FORMAT_CSV)) // csv
593 + else if(!strcmp(name, DATASOURCE_FORMAT_CSV)) // csv
594 return DATASOURCE_CSV;
595
596 - else if(!strsame(name, DATASOURCE_FORMAT_TSV) || !strsame(name, "tsv-excel")) // tsv
596 + else if(!strcmp(name, DATASOURCE_FORMAT_TSV) || !strcmp(name, "tsv-excel")) // tsv
597 return DATASOURCE_TSV;
598
599 - else if(!strsame(name, DATASOURCE_FORMAT_HTML)) // html
599 + else if(!strcmp(name, DATASOURCE_FORMAT_HTML)) // html
600 return DATASOURCE_HTML;
601
602 - else if(!strsame(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
602 + else if(!strcmp(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
603 return DATASOURCE_JS_ARRAY;
604
605 - else if(!strsame(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
605 + else if(!strcmp(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
606 return DATASOURCE_SSV_COMMA;
607
608 - else if(!strsame(name, DATASOURCE_FORMAT_CSV_JSON_ARRAY)) // csvjsonarray
608 + else if(!strcmp(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(!strsame(name, "json"))
616 + if(!strcmp(name, "json"))
617 return DATASOURCE_DATATABLE_JSONP;
618
619 - else if(!strsame(name, "html"))
619 + else if(!strcmp(name, "html"))
620 return DATASOURCE_HTML;
621
622 - else if(!strsame(name, "csv"))
622 + else if(!strcmp(name, "csv"))
623 return DATASOURCE_CSV;
624
625 - else if(!strsame(name, "tsv-excel"))
625 + else if(!strcmp(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(!strsame(name, "average"))
658 + if(!strcmp(name, "average"))
659 return GROUP_AVERAGE;
660
661 - else if(!strsame(name, "min"))
661 + else if(!strcmp(name, "min"))
662 return GROUP_MIN;
663
664 - else if(!strsame(name, "max"))
664 + else if(!strcmp(name, "max"))
665 return GROUP_MAX;
666
667 - else if(!strsame(name, "sum"))
667 + else if(!strcmp(name, "sum"))
668 return GROUP_SUM;
669
670 - else if(!strsame(name, "incremental-sum"))
670 + else if(!strcmp(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(!strsame(value, "all")) all = 1;
685 - else if(!strsame(value, "active")) all = 0;
684 + if(!strcmp(value, "all")) all = 1;
685 + else if(!strcmp(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(!strsame(name, "after")) after = strtoul(value, NULL, 0);
706 + if(!strcmp(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(!strsame(name, "chart")) chart = value;
733 + if(!strcmp(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(!strsame(name, "format")) {
790 - if(!strsame(value, ALLMETRICS_FORMAT_SHELL))
789 + if(!strcmp(name, "format")) {
790 + if(!strcmp(value, ALLMETRICS_FORMAT_SHELL))
791 format = ALLMETRICS_SHELL;
792 - else if(!strsame(value, ALLMETRICS_FORMAT_PROMETHEUS))
792 + else if(!strcmp(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(!strsame(name, "chart")) chart = value;
862 - else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
861 + if(!strcmp(name, "chart")) chart = value;
862 + else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
863 if(!dimensions)
864 dimensions = buffer_create(100);
865
866 buffer_strcat(dimensions, "|");
867 buffer_strcat(dimensions, value);
868 }
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")) {
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")) {
873 group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
874 }
875 - else if(!strsame(name, "options")) {
875 + else if(!strcmp(name, "options")) {
876 options |= web_client_api_request_v1_data_options(value);
877 }
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;
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;
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(!strsame(refresh_str, "auto")) {
927 + if(!strcmp(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(!strsame(name, "chart")) chart = value;
1125 - else if(!strsame(name, "dimension") || !strsame(name, "dim") || !strsame(name, "dimensions") || !strsame(name, "dims")) {
1124 + if(!strcmp(name, "chart")) chart = value;
1125 + else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
1126 if(!dimensions) dimensions = buffer_create(100);
1127 buffer_strcat(dimensions, "|");
1128 buffer_strcat(dimensions, value);
1129 }
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")) {
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")) {
1134 group = web_client_api_request_v1_data_group(value, GROUP_AVERAGE);
1135 }
1136 - else if(!strsame(name, "format")) {
1136 + else if(!strcmp(name, "format")) {
1137 format = web_client_api_request_v1_data_format(value);
1138 }
1139 - else if(!strsame(name, "options")) {
1139 + else if(!strcmp(name, "options")) {
1140 options |= web_client_api_request_v1_data_options(value);
1141 }
1142 - else if(!strsame(name, "callback")) {
1142 + else if(!strcmp(name, "callback")) {
1143 responseHandler = value;
1144 }
1145 - else if(!strsame(name, "filename")) {
1145 + else if(!strcmp(name, "filename")) {
1146 outFileName = value;
1147 }
1148 - else if(!strsame(name, "tqx")) {
1148 + else if(!strcmp(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(!strsame(tqx_name, "version"))
1161 + if(!strcmp(tqx_name, "version"))
1162 google_version = tqx_value;
1163 - else if(!strsame(tqx_name, "reqId"))
1163 + else if(!strcmp(tqx_name, "reqId"))
1164 google_reqId = tqx_value;
1165 - else if(!strsame(tqx_name, "sig")) {
1165 + else if(!strcmp(tqx_name, "sig")) {
1166 google_sig = tqx_value;
1167 google_timestamp = strtoul(google_sig, NULL, 0);
1168 }
1169 - else if(!strsame(tqx_name, "out")) {
1169 + else if(!strcmp(tqx_name, "out")) {
1170 google_out = tqx_value;
1171 format = web_client_api_request_v1_data_google_format(google_out);
1172 }
1173 - else if(!strsame(tqx_name, "responseHandler"))
1173 + else if(!strcmp(tqx_name, "responseHandler"))
1174 responseHandler = tqx_value;
1175 - else if(!strsame(tqx_name, "outFileName"))
1175 + else if(!strcmp(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 && !strsame(name, "action")) {
1317 + if(hash == hash_action && !strcmp(name, "action")) {
1318 uint32_t vhash = simple_hash(value);
1319
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';
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';
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 && !strsame(name, "redirects"))
1330 + else if(hash == hash_redirects && !strcmp(name, "redirects"))
1331 redirects = atoi(value);
1332 */
1333 - else if(hash == hash_machine && !strsame(name, "machine"))
1333 + else if(hash == hash_machine && !strcmp(name, "machine"))
1334 machine_guid = value;
1335
1336 - else if(hash == hash_url && !strsame(name, "url"))
1336 + else if(hash == hash_url && !strcmp(name, "url"))
1337 machine_url = value;
1338
1339 else if(action == 'A') {
1340 - if(hash == hash_name && !strsame(name, "name"))
1340 + if(hash == hash_name && !strcmp(name, "name"))
1341 url_name = value;
1342 }
1343 else if(action == 'D') {
1344 - if(hash == hash_delete_url && !strsame(name, "delete_url"))
1344 + if(hash == hash_delete_url && !strcmp(name, "delete_url"))
1345 delete_url = value;
1346 }
1347 else if(action == 'S') {
1348 - if(hash == hash_for && !strsame(name, "for"))
1348 + if(hash == hash_for && !strcmp(name, "for"))
1349 search_machine_guid = value;
1350 }
1351 else if(action == 'W') {
1352 - if(hash == hash_to && !strsame(name, "to"))
1352 + if(hash == hash_to && !strcmp(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 && !strsame(tok, "data"))
1443 + if(hash == hash_data && !strcmp(tok, "data"))
1444 return web_client_api_request_v1_data(w, url);
1445
1446 - else if(hash == hash_chart && !strsame(tok, "chart"))
1446 + else if(hash == hash_chart && !strcmp(tok, "chart"))
1447 return web_client_api_request_v1_chart(w, url);
1448
1449 - else if(hash == hash_charts && !strsame(tok, "charts"))
1449 + else if(hash == hash_charts && !strcmp(tok, "charts"))
1450 return web_client_api_request_v1_charts(w, url);
1451
1452 - else if(hash == hash_registry && !strsame(tok, "registry"))
1452 + else if(hash == hash_registry && !strcmp(tok, "registry"))
1453 return web_client_api_request_v1_registry(w, url);
1454
1455 - else if(hash == hash_badge && !strsame(tok, "badge.svg"))
1455 + else if(hash == hash_badge && !strcmp(tok, "badge.svg"))
1456 return web_client_api_request_v1_badge(w, url);
1457
1458 - else if(hash == hash_alarms && !strsame(tok, "alarms"))
1458 + else if(hash == hash_alarms && !strcmp(tok, "alarms"))
1459 return web_client_api_request_v1_alarms(w, url);
1460
1461 - else if(hash == hash_alarm_log && !strsame(tok, "alarm_log"))
1461 + else if(hash == hash_alarm_log && !strcmp(tok, "alarm_log"))
1462 return web_client_api_request_v1_alarm_log(w, url);
1463
1464 - else if(hash == hash_alarm_variables && !strsame(tok, "alarm_variables"))
1464 + else if(hash == hash_alarm_variables && !strcmp(tok, "alarm_variables"))
1465 return web_client_api_request_v1_alarm_variables(w, url);
1466
1467 - else if(hash == hash_raw && !strsame(tok, "allmetrics"))
1467 + else if(hash == hash_raw && !strcmp(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(strsame(tok, "v1") == 0)
1490 + if(strcmp(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(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;
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;
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 && strsame(tok, "nonzero") == 0) nonzero = 1;
1588 + if(tok && *tok && strcmp(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 && strsame(name, "tqx") == 0) {
1609 + if(name && *name && strcmp(name, "tqx") == 0) {
1610 char *key = mystrsep(&tok, ":");
1611 char *value = mystrsep(&tok, ";");
1612 if(key && value && *key && *value) {
1613 - if(strsame(key, "version") == 0)
1613 + if(strcmp(key, "version") == 0)
1614 google_version = value;
1615
1616 - else if(strsame(key, "reqId") == 0)
1616 + else if(strcmp(key, "reqId") == 0)
1617 google_reqId = value;
1618
1619 - else if(strsame(key, "sig") == 0)
1619 + else if(strcmp(key, "sig") == 0)
1620 google_sig = value;
1621
1622 - else if(strsame(key, "out") == 0)
1622 + else if(strcmp(key, "out") == 0)
1623 google_out = value;
1624
1625 - else if(strsame(key, "responseHandler") == 0)
1625 + else if(strcmp(key, "responseHandler") == 0)
1626 google_responseHandler = value;
1627
1628 - else if(strsame(key, "outFileName") == 0)
1628 + else if(strcmp(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(strsame(google_out, "json") != 0) {
1643 + if(strcmp(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 && strsame(tok, "api") == 0) {
2015 + if(hash == hash_api && strcmp(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 && strsame(tok, "netdata.conf") == 0) {
2019 + else if(hash == hash_netdata_conf && strcmp(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 && strsame(tok, WEB_PATH_DATA) == 0) { // "data"
2027 + else if(hash == hash_data && strcmp(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 && strsame(tok, WEB_PATH_DATASOURCE) == 0) { // "datasource"
2031 + else if(hash == hash_datasource && strcmp(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 && strsame(tok, WEB_PATH_GRAPH) == 0) { // "graph"
2035 + else if(hash == hash_graph && strcmp(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 && strsame(tok, "list") == 0) {
2066 + else if(hash == hash_list && strcmp(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 && strsame(tok, "all.json") == 0) {
2078 + else if(hash == hash_all_json && strcmp(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 && strsame(tok, "exit") == 0) {
2088 + else if(hash == hash_exit && strcmp(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 && strsame(tok, "debug") == 0) {
2101 + else if(hash == hash_debug && strcmp(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 && strsame(tok, "mirror") == 0) {
2133 + else if(hash == hash_mirror && strcmp(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 == '*' || !strsame(ip, "any") || !strsame(ip, "all"))
259 + if(!*ip || *ip == '*' || !strcmp(ip, "any") || !strcmp(ip, "all"))
260 ip = NULL;
261 if(!*port)
262 port = buffer2;