public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations
@ 2022-12-12 16:03 Petr Vorel
  2022-12-12 16:31 ` Richard Palethorpe
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2022-12-12 16:03 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

local iteration variable in worker() was probably left over from
previous versions rewrite (maybe -i was not used in previous versions).

Clang correctly reported:
aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
int iteration = 0;

Fixes: 054d45390 ("Rewrite aio-stress test using LTP API")

Reported-by: Richard Palethorpe <rpalethorpe@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

reported by Richie [1], I got confused thus merge before this fix.

[1] https://lore.kernel.org/ltp/87h6yfifbr.fsf@suse.de/

 testcases/kernel/io/ltp-aiodio/aio-stress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index 39db14d65..29e679087 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -1046,7 +1046,6 @@ 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);
@@ -1151,7 +1150,7 @@ restart:
 
 	/* someone got restarted, go back to the beginning */
 	if (t->active_opers && cnt < iterations) {
-		iteration++;
+		iterations++;
 		goto restart;
 	}
 
-- 
2.38.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations
  2022-12-12 16:03 [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations Petr Vorel
@ 2022-12-12 16:31 ` Richard Palethorpe
  2022-12-12 18:29   ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Palethorpe @ 2022-12-12 16:31 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hello,

Petr Vorel <pvorel@suse.cz> writes:

> local iteration variable in worker() was probably left over from
> previous versions rewrite (maybe -i was not used in previous versions).
>
> Clang correctly reported:
> aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
> int iteration = 0;
>
> Fixes: 054d45390 ("Rewrite aio-stress test using LTP API")
>
> Reported-by: Richard Palethorpe <rpalethorpe@suse.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
>
> reported by Richie [1], I got confused thus merge before this fix.
>
> [1] https://lore.kernel.org/ltp/87h6yfifbr.fsf@suse.de/
>
>  testcases/kernel/io/ltp-aiodio/aio-stress.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> index 39db14d65..29e679087 100644
> --- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
> +++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> @@ -1046,7 +1046,6 @@ 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);
> @@ -1151,7 +1150,7 @@ restart:
>  
>  	/* someone got restarted, go back to the beginning */
>  	if (t->active_opers && cnt < iterations) {
> -		iteration++;
> +		iterations++;

Why is this correct?

>  		goto restart;
>  	}


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations
  2022-12-12 16:31 ` Richard Palethorpe
@ 2022-12-12 18:29   ` Petr Vorel
  2022-12-12 18:52     ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2022-12-12 18:29 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp

Hi Richie,

> Hello,

> Petr Vorel <pvorel@suse.cz> writes:

> > local iteration variable in worker() was probably left over from
> > previous versions rewrite (maybe -i was not used in previous versions).

> > Clang correctly reported:
> > aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
> > int iteration = 0;

> > Fixes: 054d45390 ("Rewrite aio-stress test using LTP API")

> > Reported-by: Richard Palethorpe <rpalethorpe@suse.com>
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > Hi,

> > reported by Richie [1], I got confused thus merge before this fix.

> > [1] https://lore.kernel.org/ltp/87h6yfifbr.fsf@suse.de/

> >  testcases/kernel/io/ltp-aiodio/aio-stress.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)

> > diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > index 39db14d65..29e679087 100644
> > --- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > +++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > @@ -1046,7 +1046,6 @@ 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);
> > @@ -1151,7 +1150,7 @@ restart:

> >  	/* someone got restarted, go back to the beginning */
> >  	if (t->active_opers && cnt < iterations) {
> > -		iteration++;
> > +		iterations++;

> Why is this correct?
OK, this is obviously wrong, we don't want to increase global iterations (-i).
iteration appeared in v6. In v8, the default changed to 500 and RUN_FOREVER -1
was not used any more.
The warning was on legacy version as well, IMHO code is dead and whole restart
label and iteration variable should go away. I'll send v2.
Thanks for catching my obvious error.

Kind regards,
Petr

> >  		goto restart;
> >  	}

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations
  2022-12-12 18:29   ` Petr Vorel
@ 2022-12-12 18:52     ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2022-12-12 18:52 UTC (permalink / raw)
  To: Richard Palethorpe, ltp, Cyril Hrubis, Andrea Cervesato

> Hi Richie,

> > Hello,

> > Petr Vorel <pvorel@suse.cz> writes:

> > > local iteration variable in worker() was probably left over from
> > > previous versions rewrite (maybe -i was not used in previous versions).

> > > Clang correctly reported:
> > > aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
> > > int iteration = 0;

> > > Fixes: 054d45390 ("Rewrite aio-stress test using LTP API")

> > > Reported-by: Richard Palethorpe <rpalethorpe@suse.com>
> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > Hi,

> > > reported by Richie [1], I got confused thus merge before this fix.

> > > [1] https://lore.kernel.org/ltp/87h6yfifbr.fsf@suse.de/

> > >  testcases/kernel/io/ltp-aiodio/aio-stress.c | 3 +--
> > >  1 file changed, 1 insertion(+), 2 deletions(-)

> > > diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > > index 39db14d65..29e679087 100644
> > > --- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > > +++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> > > @@ -1046,7 +1046,6 @@ 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);
> > > @@ -1151,7 +1150,7 @@ restart:

> > >  	/* someone got restarted, go back to the beginning */
> > >  	if (t->active_opers && cnt < iterations) {
> > > -		iteration++;
> > > +		iterations++;

> > Why is this correct?
> OK, this is obviously wrong, we don't want to increase global iterations (-i).
> iteration appeared in v6. In v8, the default changed to 500 and RUN_FOREVER -1
> was not used any more.
> The warning was on legacy version as well, IMHO code is dead and whole restart
> label and iteration variable should go away. I'll send v2.
> Thanks for catching my obvious error.

Actually, thinking about it twice, I'm not sure if restart should be really
handled and thus only iteration variable should be removed (but restart label
kept) or it's so unlikely that it happen so that also restart label should be
deleted.

Kind regards,
Petr

> Kind regards,
> Petr

> > >  		goto restart;
> > >  	}

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-12 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-12 16:03 [LTP] [PATCH 1/1] aio-stress.c: Use static variable iterations Petr Vorel
2022-12-12 16:31 ` Richard Palethorpe
2022-12-12 18:29   ` Petr Vorel
2022-12-12 18:52     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox