diff mbox series

wilc1000: use min() to make code cleaner

Message ID 20211216091713.449841-1-deng.changcheng@zte.com.cn (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wilc1000: use min() to make code cleaner | expand

Commit Message

CGEL Dec. 16, 2021, 9:17 a.m. UTC
From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use min() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Kalle Valo Dec. 21, 2021, 6:13 p.m. UTC | #1
cgel.zte@gmail.com wrote:

> From: Changcheng Deng <deng.changcheng@zte.com.cn>
> 
> Use min() in order to make code cleaner.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>

Failed to compile:

In file included from ./include/linux/kernel.h:17,
                 from ./include/linux/clk.h:13,
                 from drivers/net/wireless/microchip/wilc1000/spi.c:7:
drivers/net/wireless/microchip/wilc1000/spi.c: In function 'wilc_spi_dma_rw':
./include/linux/minmax.h:20:35: error: comparison of distinct pointer types lacks a cast [-Werror]
   20 |         (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                                   ^~
./include/linux/minmax.h:26:18: note: in expansion of macro '__typecheck'
   26 |                 (__typecheck(x, y) && __no_side_effects(x, y))
      |                  ^~~~~~~~~~~
./include/linux/minmax.h:36:31: note: in expansion of macro '__safe_cmp'
   36 |         __builtin_choose_expr(__safe_cmp(x, y), \
      |                               ^~~~~~~~~~
./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp'
   45 | #define min(x, y)       __careful_cmp(x, y, <)
      |                         ^~~~~~~~~~~~~
drivers/net/wireless/microchip/wilc1000/spi.c:677:26: note: in expansion of macro 'min'
  677 |                 nbytes = min(sz, DATA_PKT_SZ);
      |                          ^~~
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:287: drivers/net/wireless/microchip/wilc1000/spi.o] Error 1
make[4]: *** [scripts/Makefile.build:549: drivers/net/wireless/microchip/wilc1000] Error 2
make[3]: *** [scripts/Makefile.build:549: drivers/net/wireless/microchip] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers/net/wireless] Error 2
make[1]: *** [scripts/Makefile.build:549: drivers/net] Error 2
make: *** [Makefile:1846: drivers] Error 2

Patch set to Changes Requested.
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 6e7fd18c14e7..629ba5d7a7df 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -675,10 +675,7 @@  static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
 		int nbytes;
 		u8 rsp;
 
-		if (sz <= DATA_PKT_SZ)
-			nbytes = sz;
-		else
-			nbytes = DATA_PKT_SZ;
+		nbytes = min(sz, DATA_PKT_SZ);
 
 		/*
 		 * Data Response header