fixes issues found by coverity static code analysis
Costa Tsaousis committed
Aug 21, 2016 at 22:10 UTC
623474662654287a0949fc1a242a0b923deffc25
5 files changed
+14
-16
src/apps_plugin.c
+3
-9
@@ -57,10 +57,8 @@ long get_system_cpus(void) {
57
if(!ff) return 1;
58
59
ff = procfile_readall(ff);
60
- if(!ff) {
61
- procfile_close(ff);
60
+ if(!ff)
61
return 1;
63
- }
62
63
unsigned int i;
64
for(i = 0; i < procfile_lines(ff); i++) {
@@ -85,10 +83,8 @@ pid_t get_system_pid_max(void) {
83
if(!ff) return mpid;
84
85
ff = procfile_readall(ff);
88
- if(!ff) {
89
- procfile_close(ff);
86
+ if(!ff)
87
return mpid;
91
- }
88
89
mpid = (pid_t)atoi(procfile_lineword(ff, 0, 0));
90
if(!mpid) mpid = 32768;
@@ -324,10 +320,8 @@ int read_apps_groups_conf(const char *name)
320
procfile_set_quotes(ff, "'\"");
321
322
ff = procfile_readall(ff);
327
- if(!ff) {
328
- procfile_close(ff);
323
+ if(!ff)
324
return 1;
330
- }
325
326
unsigned long line, lines = procfile_lines(ff);
327
src/health.c
+3
-1
@@ -1055,7 +1055,9 @@ int health_readfile(const char *path, const char *filename) {
1055
append = &s[append] - buffer;
1056
if(append < HEALTH_CONF_MAX_LINE)
1057
continue;
1058
- continue;
1058
+ else {
1059
+ error("Health configuration has too long muli-line at line %zu of file '%s/%s'.", line, path, filename);
1060
+ }
1061
}
1062
append = 0;
1063
src/proc_self_mountinfo.c
+6
@@ -152,6 +152,12 @@ struct mountinfo *mountinfo_read() {
152
153
char *major = procfile_lineword(ff, l, w), *minor; w++;
154
for(minor = major; *minor && *minor != ':' ;minor++) ;
155
+
156
+ if(!*minor) {
157
+ error("Cannot parse major:minor on '%s' at line %lu of '%s'", major, l + 1, filename);
158
+ continue;
159
+ }
160
+
161
*minor = '\0';
162
minor++;
163
src/rrd.c
+1
-1
@@ -171,7 +171,7 @@ RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
171
RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st) {
172
void *result;
173
// fprintf(stderr, "DELETING: %s (name: %s)\n", st->id, st->name);
174
- return (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl *)(&st->avlname));
174
+ result = (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl *)(&st->avlname));
175
if(result) return rrdset_from_avlname(result);
176
return NULL;
177
}
src/web_client.c
+1
-5
@@ -1219,13 +1219,9 @@ int web_client_api_request_v1_registry(struct web_client *w, char *url)
1219
1220
default:
1221
buffer_flush(w->response.data);
1222
- buffer_sprintf(w->response.data, "Invalid registry request - you need to set an action: hello, access, delete, search");
1222
+ buffer_strcat(w->response.data, "Invalid registry request - you need to set an action: hello, access, delete, search");
1223
return 400;
1224
}
1225
-
1226
- buffer_flush(w->response.data);
1227
- buffer_sprintf(w->response.data, "Invalid or no registry action.");
1228
- return 400;
1225
}
1226
1227
int web_client_api_request_v1(struct web_client *w, char *url) {