Skip to content

Commit

Permalink
Coverity 20190924 (netdata#6941)
Browse files Browse the repository at this point in the history
* coverity_20190924: Fix 215633

In the switch the library stops case this pointer is NULL, so
there is not necessity to processed with tests

* coverity_20190924: Fix 338067

The current code tries to copy the same size of the variable, another possible
solution would be to use a function to sanitize the code, I will try this first

* coverity_20190924: Fix 348638

Considering that we are testing the variable value one line above
The division will always happen

* coverity_20190924: Fix 348640

For this specific case we do not have the possibility to have memory
leak, valgrind confirms this, but I am adding a new variable here to the
stack to discard the warning
  • Loading branch information
thiagoftsm authored and jackyhuang85 committed Jan 1, 2020
1 parent 27d0373 commit b277dd7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion collectors/apps.plugin/apps_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3521,7 +3521,7 @@ static void send_collected_data_to_netdata(struct target *root, const char *type
send_BEGIN(type, "uptime_avg", dt);
for (w = root; w ; w = w->next) {
if(unlikely(w->exposed && w->processes))
send_SET(w->name, w->processes?(w->uptime_sum / w->processes):0);
send_SET(w->name, w->uptime_sum / w->processes);
}
send_END();

Expand Down
2 changes: 1 addition & 1 deletion daemon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ int get_system_info(struct rrdhost_system_info *system_info) {
}
char n[51], v[101];
snprintfz(n, 50,"%s",name);
snprintfz(v, 101,"%s",value);
snprintfz(v, 100,"%s",value);
if(unlikely(rrdhost_set_system_info_variable(system_info, n, v))) {
info("Unexpected environment variable %s=%s", n, v);
}
Expand Down
3 changes: 2 additions & 1 deletion libnetdata/health/health.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ int health_silencers_json_read_callback(JSON_ENTRY *e)
else if (!strcmp(e->data.string,"DISABLE")) silencers->stype = STYPE_DISABLE_ALARMS;
} else {
debug(D_HEALTH, "JSON: Adding %s=%s", e->name, e->data.string);
health_silencers_addparam(e->callback_data, e->name, e->data.string);
SILENCER *test = health_silencers_addparam(e->callback_data, e->name, e->data.string);
(void)test;
}
break;

Expand Down
10 changes: 6 additions & 4 deletions libnetdata/json/jsmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,12 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
}
}

for (i = parser->toknext - 1; i >= 0; i--) {
/* Unmatched opened object or array */
if (tokens[i].start != -1 && tokens[i].end == -1) {
return JSMN_ERROR_PART;
if (tokens) {
for (i = parser->toknext - 1; i >= 0; i--) {
/* Unmatched opened object or array */
if (tokens[i].start != -1 && tokens[i].end == -1) {
return JSMN_ERROR_PART;
}
}
}

Expand Down

0 comments on commit b277dd7

Please sign in to comment.