Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp283751iob; Wed, 18 May 2022 02:04:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1C7CtEzCAZMuk1HhqEJMG7LaHwrHGJ51CmtzKidc5ZHBR9ywSBcdJzUBW5+UqEcQwDQSw X-Received: by 2002:a62:d445:0:b0:50d:b868:47bc with SMTP id u5-20020a62d445000000b0050db86847bcmr26544122pfl.73.1652864681576; Wed, 18 May 2022 02:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652864681; cv=none; d=google.com; s=arc-20160816; b=Kr43dX7dI3Jvmmx0rD9GQ3gP/dmc3p1P3t1lTDDDaq3ZVP7jp8uGEuKtE1nE7CegrF mrpyhbnms26PvaX1IP8QX4sVJ6BBHs+5F2ikKVRkePBJllc/B+hnlwhJg41LBUrJrN7a AFVMhiKTzRgEXprMhJ2qXYAin5xHEtXwRKIBpNgHheHKCQjYTch3ZJQzKCYDG+224Kkr LdIlkUKdK2jJxZePxzGFY1v+TJCCsToMZlvLvd6lXvxgvIUC6XE6gXU0PjE+AOzZFhyJ kFowyE3hg/REAY7v6NaJ47/6pZAgvJuO2NtGmrVsyiAuAGRIA+pAQ9lHL2/viQM5WLQw YREw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9kt4+H7VRsg69jKeehto2RXX55nlFapCgvNfloRHblA=; b=sKNGz39xFs5qwQlVK0eSqdl1VRPX8tL3MxaA4u35fNl/J5N6T7cTDI15SPLsVggiJy MPk0GlH1SCNUVEu3JMKYuuti0zdBgfyiPVub+BvuB+SGdrx8Hsk8R1AYa+/AHTPQ1+vB lGQ2b+uD9VbY5Sazw7kamb4M3nppQ1my6cYm55BK5oGLRR8gZfU5qTXOaRFJGSgDNizf 0dI//DwaVVzRimhNnRDGUDZ7a7VeIZEyS510QTUqaX7UoAMj7QpL0R2aAy1tvG5DZVKf pfH77CApzJ6NtdNpmD8StOdRg0EhNTebksMAENpNoq4bP+zTv2BCdgpJpxe3Dcwm5xkj mJqA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id rj7-20020a17090b3e8700b001dfa650a00asi2365152pjb.149.2022.05.18.02.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:04:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 018A513CA0C; Wed, 18 May 2022 02:04:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233726AbiERJE3 (ORCPT + 99 others); Wed, 18 May 2022 05:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233672AbiERJE0 (ORCPT ); Wed, 18 May 2022 05:04:26 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9C513CA32 for ; Wed, 18 May 2022 02:04:24 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:1425:89ca:2e9e:5fc1]) by laurent.telenet-ops.be with bizsmtp id Y94M2700H10zdRX0194MBv; Wed, 18 May 2022 11:04:22 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nrFbR-000oUd-5V; Wed, 18 May 2022 11:04:21 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1nrFbQ-00BX4e-Jh; Wed, 18 May 2022 11:04:20 +0200 From: Geert Uytterhoeven To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Guo Zhengkui Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] net: smc911x: Fix min() use in debug code Date: Wed, 18 May 2022 11:04:19 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If ENABLE_SMC_DEBUG_PKTS=1: 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)); Fix this by making the constant unsigned, to match the type of "len". While at it, replace the other missed ternary operator by min(), too. Convert the dummy PRINT_PKT() from a macro to a static inline function, to catch mistakes like this without having to enable debug options manually. Fixes: 5ff0348b7f755aac ("net: smc911x: replace ternary operator with min()") Signed-off-by: Geert Uytterhoeven --- drivers/net/ethernet/smsc/smc911x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c index 2694287770e6cd8e..24d66af797d465ca 100644 --- a/drivers/net/ethernet/smsc/smc911x.c +++ b/drivers/net/ethernet/smsc/smc911x.c @@ -140,7 +140,7 @@ static void PRINT_PKT(u_char *buf, int length) pr_cont("\n"); } #else -#define PRINT_PKT(x...) do { } while (0) +static inline void PRINT_PKT(u_char *buf, int length) { } #endif @@ -430,7 +430,7 @@ static inline void smc911x_rcv(struct net_device *dev) SMC_PULL_DATA(lp, data, pkt_len+2+3); DBG(SMC_DEBUG_PKTS, dev, "Received packet\n"); - PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64); + PRINT_PKT(data, min(pkt_len - 4, 64U)); skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); dev->stats.rx_packets++; @@ -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, min(len, 64)); + PRINT_PKT(buf, min(len, 64U)); /* Send pkt via PIO or DMA */ #ifdef SMC_USE_DMA -- 2.25.1