Various fixes reported by Clang
Hey,
I had the curiosity to check how fio was considered by clang. The "--analyze" option of clang is something levering interesting bugs.
In fact, there is many false positive but some were real.
I've been pushing a branch featuring the associated fixes. That's almost nothing but I cannot close my eyes on it ;o)
Cheers,
Erwan
The following changes since commit d7e30e61f2c1d9c6101cc6896009750aae2e2bcf:
fio2gnuplot: Don't plot fake data (2013-07-22 19:39:24 +0200)
are available in the git repository at:
[email protected]:enovance/fio.git clang
for you to fetch changes up to 2fdbefdd43968f3bf354a488288b9794b5f5c6bb:
core: Insure "il" is initialized in all cases (2013-07-22 23:48:48 +0200)
----------------------------------------------------------------
Erwan Velu (3):
core: Removing duplicated code
core: Don't leak memory if error is unknown
core: Insure "il" is initialized in all cases
init.c | 2 -- options.c | 1 + parse.c | 2 +- stat.c | 6 ++---- 4 files changed, 4 insertions(+), 7 deletions(-)
init.c +0 -2
@@ -1755,8 +1755,6 @@ int parse_cmd_line(int argc, char *argv[], int client_type)case FIO_GETOPT_IOENGINE : {const char *opt = l_opts[lidx].name;char *val = optarg; - opt = l_opts[lidx].name; - val = optarg; ret =fio_cmd_ioengine_option_parse (td, opt, val);break ; }
options.c +1 -0
@@ -271,6 +271,7 @@ static int ignore_error_type(struct thread_data *td, int etype, char *str)if (!error[i]) {log_err ("Unknown error %s, please use number value \n" , fname); +free (error);return 1 ; } i++;
parse.c +0 -0
@@ -380,7 +380,7 @@ static int str_match_len(const struct value_pair *vp, const char *str) static int __handle_option(struct fio_option *o, const char *ptr, void
*data,
int first, int more, int curr)
{
- int il, *ilp;
+ int il=0, *ilp;
fio_fp64_t *flp;
long long ull, *ullp;
long ul1, ul2;stat.c +2 -4
@@ -243,15 +243,13 @@ out:int calc_lat (struct io_stat *is,unsigned long *min,unsigned long *max,double *mean,double *dev) { -double n = is->samples; +double n = (double ) is->samples; -if (is->samples ==0 ) +if (n ==0 )return 0 ; *min = is->min_val; *max = is->max_val; - - n = (double ) is->samples; *mean = is->mean.u.f;if (n >1.0 )
Quoted 8 lines · Erwan Velu
Hey,
I had the curiosity to check how fio was considered by clang. The "--analyze" option of clang is something levering interesting bugs.
In fact, there is many false positive but some were real. I've been pushing a branch featuring the associated fixes. That's almost nothing but I cannot close my eyes on it ;o)
Thanks, all three look good. Thanks for wading through the false positives to find the gold :-)
Signature · 1 line
Jens Axboe