lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGRGNgVULqZzu2_bqBSSdnjSj=EuO3-0BS3TBMk=RHL8O32NmQ@mail.gmail.com>
Date:   Wed, 14 Jun 2023 22:07:02 +1000
From:   Julian Calaby <julian.calaby@...il.com>
To:     baomingtong001@...suo.com
Cc:     toke@...e.dk, kvalo@...nel.org, linux-wireless@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ath: Remove unneeded variable

Hi Mingtong,

On Wed, Jun 14, 2023 at 1:23 PM <baomingtong001@...suo.com> wrote:
>
> Fix the following coccicheck warning:
>
> drivers/net/wireless/ath/ath9k/gpio.c:501:5-8: Unneeded variable: "len".

Coccinelle / Coccicheck is unable to accurately detect unused
variables as it can only analyse the code as it is written and
doesn't, for example, expand macros. This produces false positives
like the one you're trying to fix in this patch.

> Signed-off-by: Mingtong Bao <baomingtong001@...suo.com>
> ---
>   drivers/net/wireless/ath/ath9k/gpio.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/gpio.c
> b/drivers/net/wireless/ath/ath9k/gpio.c
> index b457e52dd365..f3d1bc02e633 100644
> --- a/drivers/net/wireless/ath/ath9k/gpio.c
> +++ b/drivers/net/wireless/ath/ath9k/gpio.c
> @@ -498,14 +498,13 @@ static int ath9k_dump_legacy_btcoex(struct
> ath_softc *sc, u8 *buf, u32 size)
>   {
>
>       struct ath_btcoex *btcoex = &sc->btcoex;
> -    u32 len = 0;
>
>       ATH_DUMP_BTCOEX("Stomp Type", btcoex->bt_stomp_type);

ATH_DUMP_BTCOEX() is a macro that relies on a bunch of local variables
being defined, one of which is "len". If you'd compiled this code, you
would have spotted this problem immediately.

A "correct" solution to the "problem" here might be to add the local
variables to the macro parameters or move the definition of the macro
closer to where it's used so it's more obvious that some "magic" is
going on here.

As others have said, you need to fully understand what code is doing
before producing these sorts of cleanups, otherwise you'll produce
incorrect patches like this one.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@...il.com
Profile: http://www.google.com/profiles/julian.calaby/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ