[PATCH] selftests/nolibc: Remove unneeded variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>   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)
> 



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux