summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
65739dd)
As per the coverty reports, there was some issues in my code :
- Some structures were not properly freed before returning.
- Some file descriptors were not properly closed
- Testing with 'if (!int)' isn't a good way to test if the value is negative
Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>
/* %n is replaced by the name of the running job */
expanded_name = str_replace(expanded_runtime, "%n", o->name);
/* %n is replaced by the name of the running job */
expanded_name = str_replace(expanded_runtime, "%n", o->name);
+ free(expanded_runtime);
/* Creating the stderr & stdout output files */
outfd = open(outfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
/* Creating the stderr & stdout output files */
outfd = open(outfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
log_err("fio: cannot open output file %s : %s\n",
outfilename, strerror(errno));
free(outfilename);
free(errfilename);
log_err("fio: cannot open output file %s : %s\n",
outfilename, strerror(errno));
free(outfilename);
free(errfilename);
+ free(expanded_arguments);
return -1;
}
errfd = open(errfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
return -1;
}
errfd = open(errfilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
log_err("fio: cannot open output file %s : %s\n",
errfilename, strerror(errno));
free(outfilename);
free(errfilename);
log_err("fio: cannot open output file %s : %s\n",
errfilename, strerror(errno));
free(outfilename);
free(errfilename);
+ free(expanded_arguments);
+ close(outfd);
free(outfilename);
free(errfilename);
}
free(outfilename);
free(errfilename);
}
+ free(expanded_arguments);
free(outfilename);
free(errfilename);
}
free(outfilename);
free(errfilename);
}
+ free(expanded_arguments);
* at all.
*/
if (expanded_arguments != NULL) {
* at all.
*/
if (expanded_arguments != NULL) {
- if (asprintf(&exec_cmd, "%s %s", eo->program, expanded_arguments) < 0)
+ if (asprintf(&exec_cmd, "%s %s", eo->program, expanded_arguments) < 0) {
+ free(expanded_arguments);
} else {
if (asprintf(&exec_cmd, "%s", eo->program) < 0)
return -1;
} else {
if (asprintf(&exec_cmd, "%s", eo->program) < 0)
return -1;
execvp(arguments_array[0], arguments_array);
}
/* We never reach this place */
execvp(arguments_array[0], arguments_array);
}
/* We never reach this place */
+ /* Let's free the malloc'ed structures to make static checkers happy */
+ if (expanded_arguments)
+ free(expanded_arguments);
+ if (arguments_array)
+ free(arguments_array);