diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2019-10-15 20:04:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-15 20:04:09 +0000 |
commit | ad8b796621e457a3eb5f5bb47518881fa100b470 (patch) | |
tree | 80a131ea7c7e2b2ecf0d97f900011d6fe7435080 | |
parent | 16d40fbb14f29e51902434a5da69932c4b0353a0 (diff) |
Clang warnings (#7090)
* clang_warnings: Fix unecessary comparison
Netdata was verifying whether a pointer that will never be NULL could be NULL.
This commit removes this
* clang_warnings: Fix unecessary comparison
Netdata was doing another unecessary comparison in other file
* clang_warnings: Unecessary parenthesis
This commit removes the excess of parenthesis in a file
* clang_warnings: Remove unecessary initialization
Remove from json file a initial set that is overwritten few lines late
* clang_warnings: Comments
Fix comments on top of the function
* clang_warnings: Missing Cast
Volatile variable generates warnings with Clang sometimes, so it
was necessary to cast variables
* clang_warnings: Return from previous
Considering the possible problems given by the solution,
I am returning for the previous stage
-rw-r--r-- | libnetdata/health/health.c | 2 | ||||
-rw-r--r-- | libnetdata/json/json.c | 11 | ||||
-rw-r--r-- | web/api/queries/query.c | 2 |
3 files changed, 5 insertions, 10 deletions
diff --git a/libnetdata/health/health.c b/libnetdata/health/health.c index a70f284b1f..e03538db3f 100644 --- a/libnetdata/health/health.c +++ b/libnetdata/health/health.c @@ -112,7 +112,7 @@ int health_silencers_json_read_callback(JSON_ENTRY *e) case JSON_OBJECT: #ifndef ENABLE_JSONC e->callback_function = health_silencers_json_read_callback; - if(e->name && strcmp(e->name,"")) { + if(strcmp(e->name,"")) { // init silencer debug(D_HEALTH, "JSON: Got object with a name, initializing new silencer for %s",e->name); #endif diff --git a/libnetdata/json/json.c b/libnetdata/json/json.c index 7c5adca3db..3ccc561c6f 100644 --- a/libnetdata/json/json.c +++ b/libnetdata/json/json.c @@ -284,18 +284,13 @@ size_t json_walk_primitive(char *js, jsmntok_t *t, size_t start, JSON_ENTRY *e) * @param t the tokens * @param nest the length of structure t * @param start the first position - * @param e the output structure. + * @param e the structure with values and callback to be used inside the function. * * @return It returns the array length */ size_t json_walk_array(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_ENTRY *e) { - JSON_ENTRY ne = { - .name = "", - .fullname = "", - .callback_data = NULL, - .callback_function = NULL - }; + JSON_ENTRY ne; char old = js[t[start].end]; js[t[start].end] = '\0'; @@ -315,7 +310,7 @@ size_t json_walk_array(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_E start++; for(i = 0; i < size ; i++) { ne.pos = i; - if (!e->name || !e->fullname || strlen(e->name) > JSON_NAME_LEN - 24 || strlen(e->fullname) > JSON_FULLNAME_LEN -24) { + if (strlen(e->name) > JSON_NAME_LEN - 24 || strlen(e->fullname) > JSON_FULLNAME_LEN -24) { info("JSON: JSON walk_array ignoring element with name:%s fullname:%s",e->name, e->fullname); continue; } diff --git a/web/api/queries/query.c b/web/api/queries/query.c index 6f186d3ac7..b0eb826d6b 100644 --- a/web/api/queries/query.c +++ b/web/api/queries/query.c @@ -1559,7 +1559,7 @@ RRDR *rrd2rrdr( rrd_update_every, first_entry_t, last_entry_t); #ifdef ENABLE_DBENGINE - if ((st->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE)) { + if (st->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) { struct rrdeng_region_info *region_info_array; unsigned regions, max_interval; |