[LTP] [PATCH v1] Refactoring aio-stress.c using LTP API
Petr Vorel
pvorel@suse.cz
Mon Jan 3 13:00:43 CET 2022
Hi Andrea,
quite big changeset, but it probably could not be separated into more commits as
runtest file changes are related to LTP API change.
Good work, LGTM.
This is worth to be fixed:
> + ret = pthread_join(t[i].tid, &retval);
> + if (ret)
> + tst_brk(TBROK, "pthread_join: %s", tst_strerrno(ret));
> +
> + ret = ((int *) retval);
ret = *((int *) retval);
Both compiler and make check warns about it:
aio-stress.c:1252:21: warning: assignment to ‘int’ from ‘int *’ makes integer from pointer without a cast [-Wint-conversion]
make check-aio-stress
CHECK testcases/kernel/io/ltp-aiodio/aio-stress.c
aio-stress.c:1252:21: warning: incorrect type in assignment (different base types)
aio-stress.c:1252:21: expected int [assigned] ret
aio-stress.c:1252:21: got int *
It'd be great if you could fix at least some of other compiler warnings:
aio-stress.c: In function ‘check_finished_io’:
aio-stress.c:338:13: warning: unused variable ‘length’ [-Wunused-variable]
338 | int length;
| ^~~~~~
aio-stress.c: In function ‘create_oper’:
aio-stress.c:690:63: warning: unused parameter ‘iter’ [-Wunused-parameter]
690 | int reclen, int depth, int iter,
| ~~~~^~~~
aio-stress.c: In function ‘oper_runnable’:
aio-stress.c:848:13: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
848 | int ret;
| ^~~
aio-stress.c: In function ‘setup_shared_mem’:
aio-stress.c:1013:38: warning: unused parameter ‘max_io_submit’ [-Wunused-parameter]
1013 | int reclen, int max_io_submit)
| ~~~~^~~~~~~~~~~~~
aio-stress.c: In function ‘run_workers’:
aio-stress.c:1242:55: warning: cast between incompatible function types from ‘int (*)(struct thread_info *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
1242 | ret = pthread_create(&t[i].tid, NULL, (start_routine) worker, t + i);
| ^
aio-stress.c:1252:21: warning: assignment to ‘int’ from ‘int *’ makes integer from pointer without a cast [-Wint-conversion]
1252 | ret = ((int *) retval);
| ^
aio-stress.c: In function ‘setup’:
aio-stress.c:1269:42: warning: integer overflow in expression of type ‘int’ results in ‘-2147483648’ [-Woverflow]
1269 | context_offset = 2 * 1024 * 1024 * 1024;
| ^
aio-stress.c: In function ‘check_finished_io’:
aio-stress.c:372:41: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
372 | asprintf(&msg, "%d:%c:%c ", i, io->buf[i], verify_buf[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aio-stress.c: In function ‘print_lat’:
aio-stress.c:441:17: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
441 | asprintf(&msg, " %.0f < %d", lat->deviations[i], deviations[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aio-stress.c:447:17: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
447 | asprintf(&msg, " < %.0f", lat->total_io - total_counted);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aio-stress.c: In function ‘restart_oper’:
aio-stress.c:817:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
817 | if (stages & (1 << READ))
| ^
aio-stress.c:819:9: note: here
819 | case READ:
| ^~~~
aio-stress.c:820:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
820 | if (!new_rw && stages & (1 << RWRITE))
| ^
aio-stress.c:822:9: note: here
822 | case RWRITE:
| ^~~~
I'd also sort alphabetically getopts and help, but that's just me looking into
unimportant details.
Kind regards,
Petr
More information about the ltp
mailing list