Re: [PATCH 10/11] kselftest/arm64: mte: Fix clang warning

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

 



On Fri, Mar 19, 2021 at 9:53 AM Andre Przywara <andre.przywara@xxxxxxx> wrote:
>
> if (!prctl(...) == 0) is not only cumbersome to read, it also upsets
> clang and triggers a warning:
> ------------
> mte_common_util.c:287:6: warning: logical not is only applied to the
> left hand side of this comparison [-Wlogical-not-parentheses]
> ....
>
> Fix that by just comparing against "not 0" instead.
>
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
> ---
>  tools/testing/selftests/arm64/mte/mte_common_util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/arm64/mte/mte_common_util.c b/tools/testing/selftests/arm64/mte/mte_common_util.c
> index aa8a8a6b8b6d..040abdca079d 100644
> --- a/tools/testing/selftests/arm64/mte/mte_common_util.c
> +++ b/tools/testing/selftests/arm64/mte/mte_common_util.c
> @@ -284,7 +284,7 @@ int mte_switch_mode(int mte_option, unsigned long incl_mask)
>
>         en |= (incl_mask << PR_MTE_TAG_SHIFT);
>         /* Enable address tagging ABI, mte error reporting mode and tag inclusion mask. */
> -       if (!prctl(PR_SET_TAGGED_ADDR_CTRL, en, 0, 0, 0) == 0) {
> +       if (prctl(PR_SET_TAGGED_ADDR_CTRL, en, 0, 0, 0) != 0) {

How about `if (prctl(...)) {`?

>                 ksft_print_msg("FAIL:prctl PR_SET_TAGGED_ADDR_CTRL for mte mode\n");
>                 return -EINVAL;
>         }
> --
> 2.17.5
>


-- 
Thanks,
~Nick Desaulniers



[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