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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 18 May 2022 11:07:08 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Guo Zhengkui <guozhengkui@...o.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Colin Ian King <colin.king@...el.com>,
        Jiasheng Jiang <jiasheng@...as.ac.cn>,
        "open list:NETWORKING DRIVERS" <netdev@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        zhengkui_guo@...look.com
Subject: Re: [PATCH linux-next] net: smc911x: replace ternary operator with min()

Hi Guo,

On Mon, May 16, 2022 at 10:36 PM Guo Zhengkui <guozhengkui@...o.com> wrote:
> Fix the following coccicheck warning:
>
> drivers/net/ethernet/smsc/smc911x.c:483:20-22: WARNING opportunity for min()
>
> Signed-off-by: Guo Zhengkui <guozhengkui@...o.com>

Thanks for your patch, which is now commit 5ff0348b7f755aac ("net:
smc911x: replace ternary operator with min()") in net-next/master.

> --- a/drivers/net/ethernet/smsc/smc911x.c
> +++ b/drivers/net/ethernet/smsc/smc911x.c
> @@ -480,7 +480,7 @@ static void smc911x_hardware_send_pkt(struct net_device *dev)
>         SMC_SET_TX_FIFO(lp, cmdB);
>
>         DBG(SMC_DEBUG_PKTS, dev, "Transmitted packet\n");
> -       PRINT_PKT(buf, len <= 64 ? len : 64);
> +       PRINT_PKT(buf, min(len, 64));

Unfortunately you forgot to test-compile this with
ENABLE_SMC_DEBUG_PKTS=1, which triggers:

        drivers/net/ethernet/smsc/smc911x.c: In function
‘smc911x_hardware_send_pkt’:
        include/linux/minmax.h:20:28: error: comparison of distinct
pointer types lacks a cast [-Werror]
           20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
              |                            ^~
        drivers/net/ethernet/smsc/smc911x.c:483:17: note: in expansion
of macro ‘min’
          483 |  PRINT_PKT(buf, min(len, 64));

"len" is "unsigned int", while "64" is "(signed) int".

I have sent a fix
https://lore.kernel.org/r/ca032d4122fc70d3a56a524e5944a8eff9a329e8.1652864652.git.geert+renesas@glider.be/

>
>         /* Send pkt via PIO or DMA */
>  #ifdef SMC_USE_DMA

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists