[LTP] [PATCH v2 1/1] aio-stress.c: Remove useless iteration variable

Richard Palethorpe rpalethorpe@suse.de
Mon Jan 9 15:11:01 CET 2023


Hello,

Petr Vorel <pvorel@suse.cz> writes:

> local iteration variable in worker() was probably left over from
> previous version before rewrite because clang correctly reported also on
> this old version:
>
>     aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
>     int iteration = 0;
>
> Whole restart label was not used.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Changes v1->v2:
> * remove whole restart label.
>
>  testcases/kernel/io/ltp-aiodio/aio-stress.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> index 2fdbb84e87..2946ac1f47 100644
> --- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
> +++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> @@ -1039,12 +1039,10 @@ static int *worker(struct thread_info *t)
>  	char *this_stage = NULL;
>  	struct timeval stage_time;
>  	int status = 0;
> -	int iteration = 0;
>  	int cnt;
>  
>  	aio_setup(&t->io_ctx, 512);
>  
> -restart:
>  	if (num_threads > 1) {
>  		if (pthread_barrier_wait(&worker_barrier))
>  			gettimeofday(&global_stage_start_time, NULL);
> @@ -1115,12 +1113,6 @@ restart:
>  			global_thread_throughput(t, this_stage);
>  	}
>  
> -	/* someone got restarted, go back to the beginning */
> -	if (t->active_opers && cnt < iterations) {

In this case, shouldn't we remove all the restart code? It seems
active_opers can be added to and cnt could be less than iterations. So
the label could be used.

I think you are safe to remove only the iteration variable.

Personally I would not touch this code except to fix a major issue or
rewrite it altogether.

> -		iteration++;
> -		goto restart;
> -	}
> -
>  	/* finally, free all the ram */
>  	while (t->finished_opers) {
>  		oper = t->finished_opers;
> -- 
> 2.39.0


-- 
Thank you,
Richard.


More information about the ltp mailing list