Commit a3641ca4 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by David S. Miller
Browse files

net: smc911x: Fix min() use in debug code



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: 5ff0348b ("net: smc911x: replace ternary operator with min()")
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 223153ea
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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