Commit 44c2ea6b authored by Vladimír Čunát's avatar Vladimír Čunát

fix two nitpicks from clang-scan

- utils.c: overflowing size_t is basically impossible, but well...
- stats.c: NULL would probably not cause a problem with zero length passed
parent bf5f6e1b
...@@ -143,7 +143,10 @@ char* kr_strcatdup(unsigned n, ...) ...@@ -143,7 +143,10 @@ char* kr_strcatdup(unsigned n, ...)
for (unsigned i = 0; i < n; ++i) { for (unsigned i = 0; i < n; ++i) {
char *item = va_arg(vl, char *); char *item = va_arg(vl, char *);
const size_t new_len = total_len + strlen_safe(item); const size_t new_len = total_len + strlen_safe(item);
if (unlikely(new_len < total_len)) return NULL; if (unlikely(new_len < total_len)) {
va_end(vl);
return NULL;
}
total_len = new_len; total_len = new_len;
} }
va_end(vl); va_end(vl);
......
...@@ -313,7 +313,7 @@ static char* stats_list(void *env, struct kr_module *module, const char *args) ...@@ -313,7 +313,7 @@ static char* stats_list(void *env, struct kr_module *module, const char *args)
size_t args_len = args ? strlen(args) : 0; size_t args_len = args ? strlen(args) : 0;
for (unsigned i = 0; i < metric_const_end; ++i) { for (unsigned i = 0; i < metric_const_end; ++i) {
struct const_metric_elm *elm = &const_metrics[i]; struct const_metric_elm *elm = &const_metrics[i];
if (strncmp(elm->key, args, args_len) == 0) { if (args && strncmp(elm->key, args, args_len) == 0) {
json_append_member(root, elm->key, json_mknumber(elm->val)); json_append_member(root, elm->key, json_mknumber(elm->val));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment