mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: wuyonggang001@208suo.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org, w@1wt.eu
Subject: [PATCH] selftests/nolibc: Remove unneeded variable
Date: Fri, 16 Jun 2023 14:34:48 +0800	[thread overview]
Message-ID: <20230616063448.14099-1-falcon@tinylab.org> (raw)
In-Reply-To: <f964d3dbc6362c2cae56bdbdc05befea@208suo.com>

Hi, Yonggang

The 'ret' variable is extractly used by the macros to record the
failures, removing it would directly break the compiling.

    $ gcc -o nolibc-test tools/testing/selftests/nolibc/nolibc-test.c
    tools/testing/selftests/nolibc/nolibc-test.c: In function ‘run_syscall’:
    tools/testing/selftests/nolibc/nolibc-test.c:285:57: error: ‘ret’ undeclared (first use in this function)
      285 |  do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_sysne(expr, llen, val); } while (0)

You can re-check all of the used 'ret' like this:

    $ grep "ret += expect" -ur tools/testing/selftests/nolibc/nolibc-test.c

To avoid sending such patches, simple local tests are required, for this patch,
the 'libc-test' or 'nolibc-test' target may help us to find the above compile
error:

    $ cd tools/testing/selftests/nolibc/
    $ make libc-test
    or
    $ make nolibc-test

Thanks,
Zhangjin

> Fix the following coccicheck warning:
> 
> tools/testing/selftests/nolibc/nolibc-test.c:646:5-8: Unneeded variable: 
> "ret". Return "0"
> 
> Signed-off-by: Yonggang Wu <wuyonggang001@208suo.com>
> ---
>   tools/testing/selftests/nolibc/nolibc-test.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c 
> b/tools/testing/selftests/nolibc/nolibc-test.c
> index 486334981e60..2b723354e085 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -546,7 +546,6 @@ int run_syscall(int min, int max)
>       int proc;
>       int test;
>       int tmp;
> -    int ret = 0;
>       void *p1, *p2;
> 
>       /* <proc> indicates whether or not /proc is mounted */
> @@ -632,18 +631,17 @@ int run_syscall(int min, int max)
>           CASE_TEST(syscall_noargs);    EXPECT_SYSEQ(1, 
> syscall(__NR_getpid), getpid()); break;
>           CASE_TEST(syscall_args);      EXPECT_SYSER(1, 
> syscall(__NR_statx, 0, NULL, 0, 0, NULL), -1, EFAULT); break;
>           case __LINE__:
> -            return ret; /* must be last */
> +            return 0; /* must be last */
>           /* note: do not set any defaults so as to permit holes above */
>           }
>       }
> -    return ret;
> +    return 0;
>   }
> 
>   int run_stdlib(int min, int max)
>   {
>       int test;
>       int tmp;
> -    int ret = 0;
>       void *p1, *p2;
> 
>       for (test = min; test >= 0 && test <= max; test++) {
> @@ -726,11 +724,11 @@ int run_stdlib(int min, int max)
>   # warning "__SIZEOF_LONG__ is undefined"
>   #endif /* __SIZEOF_LONG__ */
>           case __LINE__:
> -            return ret; /* must be last */
> +            return 0; /* must be last */
>           /* note: do not set any defaults so as to permit holes above */
>           }
>       }
> -    return ret;
> +    return 0;
>   }
> 
>   #define EXPECT_VFPRINTF(c, expected, fmt, ...)                \
> @@ -790,7 +788,6 @@ static int run_vfprintf(int min, int max)
>   {
>       int test;
>       int tmp;
> -    int ret = 0;
>       void *p1, *p2;
> 
>       for (test = min; test >= 0 && test <= max; test++) {
> @@ -810,11 +807,11 @@ static int run_vfprintf(int min, int max)
>           CASE_TEST(hex);          EXPECT_VFPRINTF(1, "f", "%x", 0xf); 
> break;
>           CASE_TEST(pointer);      EXPECT_VFPRINTF(3, "0x1", "%p", (void 
> *) 0x1); break;
>           case __LINE__:
> -            return ret; /* must be last */
> +            return 0; /* must be last */
>           /* note: do not set any defaults so as to permit holes above */
>           }
>       }
> -    return ret;
> +    return 0;
>   }
> 
>   static int smash_stack(void)
> 

      reply	other threads:[~2023-06-16  6:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230614080240.48197-1-zhanglibing@cdjrlc.com>
2023-06-14  8:09 ` wuyonggang001
2023-06-16  6:34   ` Zhangjin Wu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230616063448.14099-1-falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=w@1wt.eu \
    --cc=wuyonggang001@208suo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®