[PATCH] tests: Remove unused "wcount" from linux-test.c

Brian Cain posted 1 patch 1 year, 11 months ago
tests/tcg/multiarch/linux/linux-test.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] tests: Remove unused "wcount" from linux-test.c
Posted by Brian Cain 1 year, 11 months ago
clang reports this variable as 'set but not used'.

Signed-off-by: Brian Cain <bcain@quicinc.com>	
---
 tests/tcg/multiarch/linux/linux-test.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/tcg/multiarch/linux/linux-test.c b/tests/tcg/multiarch/linux/linux-test.c
index 019d8175ca..d5781bb476 100644
--- a/tests/tcg/multiarch/linux/linux-test.c
+++ b/tests/tcg/multiarch/linux/linux-test.c
@@ -332,12 +332,11 @@ static void test_pipe(void)
     fd_set rfds, wfds;
     int fds[2], fd_max, ret;
     uint8_t ch;
-    int wcount, rcount;
+    int rcount;
 
     chk_error(pipe(fds));
     chk_error(fcntl(fds[0], F_SETFL, O_NONBLOCK));
     chk_error(fcntl(fds[1], F_SETFL, O_NONBLOCK));
-    wcount = 0;
     rcount = 0;
     for(;;) {
         FD_ZERO(&rfds);
@@ -360,7 +359,6 @@ static void test_pipe(void)
             if (FD_ISSET(fds[1], &wfds)) {
                 ch = 'a';
                 chk_error(write(fds[1], &ch, 1));
-                wcount++;
             }
         }
     }
-- 
2.35.3
Re: [PATCH] tests: Remove unused "wcount" from linux-test.c
Posted by Peter Maydell 1 year, 11 months ago
On Fri, 20 May 2022 at 14:16, Brian Cain <bcain@quicinc.com> wrote:
>
> clang reports this variable as 'set but not used'.
>
> Signed-off-by: Brian Cain <bcain@quicinc.com>
> ---
>  tests/tcg/multiarch/linux/linux-test.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/tests/tcg/multiarch/linux/linux-test.c b/tests/tcg/multiarch/linux/linux-test.c
> index 019d8175ca..d5781bb476 100644
> --- a/tests/tcg/multiarch/linux/linux-test.c
> +++ b/tests/tcg/multiarch/linux/linux-test.c
> @@ -332,12 +332,11 @@ static void test_pipe(void)
>      fd_set rfds, wfds;
>      int fds[2], fd_max, ret;
>      uint8_t ch;
> -    int wcount, rcount;
> +    int rcount;
>
>      chk_error(pipe(fds));
>      chk_error(fcntl(fds[0], F_SETFL, O_NONBLOCK));
>      chk_error(fcntl(fds[1], F_SETFL, O_NONBLOCK));
> -    wcount = 0;
>      rcount = 0;
>      for(;;) {
>          FD_ZERO(&rfds);
> @@ -360,7 +359,6 @@ static void test_pipe(void)
>              if (FD_ISSET(fds[1], &wfds)) {
>                  ch = 'a';
>                  chk_error(write(fds[1], &ch, 1));
> -                wcount++;
>              }
>          }
>      }

Another 'count' related oddity in this test code:

                if (rcount >= WCOUNT_MAX)
                    break;
why do we compare _r_count against _W_COUNT_MAX ?

-- PMM
RE: [PATCH] tests: Remove unused "wcount" from linux-test.c
Posted by Brian Cain 1 year, 11 months ago
> -----Original Message-----
> From: Peter Maydell <peter.maydell@linaro.org>
> Sent: Friday, May 20, 2022 8:21 AM
> To: Brian Cain <bcain@quicinc.com>
> Cc: Daniel P. Berrangé <berrange@redhat.com>; qemu-devel@nongnu.org;
> Alex Bennée <alex.bennee@linaro.org>
> Subject: Re: [PATCH] tests: Remove unused "wcount" from linux-test.c
> 
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
> 
> On Fri, 20 May 2022 at 14:16, Brian Cain <bcain@quicinc.com> wrote:
> >
> > clang reports this variable as 'set but not used'.
> >
> > Signed-off-by: Brian Cain <bcain@quicinc.com>
> > ---
> >  tests/tcg/multiarch/linux/linux-test.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/tests/tcg/multiarch/linux/linux-test.c
> b/tests/tcg/multiarch/linux/linux-test.c
> > index 019d8175ca..d5781bb476 100644
> > --- a/tests/tcg/multiarch/linux/linux-test.c
> > +++ b/tests/tcg/multiarch/linux/linux-test.c
> > @@ -332,12 +332,11 @@ static void test_pipe(void)
> >      fd_set rfds, wfds;
> >      int fds[2], fd_max, ret;
> >      uint8_t ch;
> > -    int wcount, rcount;
> > +    int rcount;
> >
> >      chk_error(pipe(fds));
> >      chk_error(fcntl(fds[0], F_SETFL, O_NONBLOCK));
> >      chk_error(fcntl(fds[1], F_SETFL, O_NONBLOCK));
> > -    wcount = 0;
> >      rcount = 0;
> >      for(;;) {
> >          FD_ZERO(&rfds);
> > @@ -360,7 +359,6 @@ static void test_pipe(void)
> >              if (FD_ISSET(fds[1], &wfds)) {
> >                  ch = 'a';
> >                  chk_error(write(fds[1], &ch, 1));
> > -                wcount++;
> >              }
> >          }
> >      }
> 
> Another 'count' related oddity in this test code:
> 
>                 if (rcount >= WCOUNT_MAX)
>                     break;
> why do we compare _r_count against _W_COUNT_MAX ?

I thought it was peculiar myself but *possibly* intentional.  Or maybe wcount should be compared with WCOUNT_MAX and rcount could be omitted?

-Brian