diff mbox series

[net-next,v2] lib8390: Replace panic() call with BUILD_BUG_ON

Message ID 20200929171326.6492-1-W_Armin@gmx.de
State Accepted
Delegated to: David Miller
Headers show
Series [net-next,v2] lib8390: Replace panic() call with BUILD_BUG_ON | expand

Commit Message

Armin Wolf Sept. 29, 2020, 5:13 p.m. UTC
Replace panic() call in lib8390.c with BUILD_BUG_ON()
since checking the size of struct e8390_pkt_hdr should
happen at compile-time.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
v2 changes:
- remove __packed from struct e8390_pkt_hdr
---
 drivers/net/ethernet/8390/lib8390.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.20.1

Comments

David Miller Sept. 29, 2020, 9:22 p.m. UTC | #1
From: Armin Wolf <W_Armin@gmx.de>
Date: Tue, 29 Sep 2020 19:13:26 +0200

> Replace panic() call in lib8390.c with BUILD_BUG_ON()
> since checking the size of struct e8390_pkt_hdr should
> happen at compile-time.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> v2 changes:
> - remove __packed from struct e8390_pkt_hdr

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index 1f48d7f6365c..deba94d2c909 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -50,6 +50,7 @@ 

   */

+#include <linux/build_bug.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
@@ -1018,8 +1019,7 @@  static void __NS8390_init(struct net_device *dev, int startp)
 	    ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
 	    : 0x48;

-	if (sizeof(struct e8390_pkt_hdr) != 4)
-		panic("8390.c: header struct mispacked\n");
+	BUILD_BUG_ON(sizeof(struct e8390_pkt_hdr) != 4);
 	/* Follow National Semi's recommendations for initing the DP83902. */
 	ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */
 	ei_outb_p(endcfg, e8390_base + EN0_DCFG);	/* 0x48 or 0x49 */