Commit 60da481b authored by Helge Deller's avatar Helge Deller Committed by David S. Miller

WAVELAN - compile-time check for struct sizes

Convert optional struct size checks to non-optional compile-time checks.
Furthermore BUILD_BUG_ON() which will be optimized away by the compiler.
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent eb189d8b
...@@ -49,27 +49,6 @@ static int __init wv_psa_to_irq(u8 irqval) ...@@ -49,27 +49,6 @@ static int __init wv_psa_to_irq(u8 irqval)
return -1; return -1;
} }
#ifdef STRUCT_CHECK
/*------------------------------------------------------------------*/
/*
* Sanity routine to verify the sizes of the various WaveLAN interface
* structures.
*/
static char *wv_struct_check(void)
{
#define SC(t,s,n) if (sizeof(t) != s) return(n);
SC(psa_t, PSA_SIZE, "psa_t");
SC(mmw_t, MMW_SIZE, "mmw_t");
SC(mmr_t, MMR_SIZE, "mmr_t");
SC(ha_t, HA_SIZE, "ha_t");
#undef SC
return ((char *) NULL);
} /* wv_struct_check */
#endif /* STRUCT_CHECK */
/********************* HOST ADAPTER SUBROUTINES *********************/ /********************* HOST ADAPTER SUBROUTINES *********************/
/* /*
* Useful subroutines to manage the WaveLAN ISA interface * Useful subroutines to manage the WaveLAN ISA interface
...@@ -4215,14 +4194,11 @@ struct net_device * __init wavelan_probe(int unit) ...@@ -4215,14 +4194,11 @@ struct net_device * __init wavelan_probe(int unit)
int i; int i;
int r = 0; int r = 0;
#ifdef STRUCT_CHECK /* compile-time check the sizes of structures */
if (wv_struct_check() != (char *) NULL) { BUILD_BUG_ON(sizeof(psa_t) != PSA_SIZE);
printk(KERN_WARNING BUILD_BUG_ON(sizeof(mmw_t) != MMW_SIZE);
"%s: wavelan_probe(): structure/compiler botch: \"%s\"\n", BUILD_BUG_ON(sizeof(mmr_t) != MMR_SIZE);
dev->name, wv_struct_check()); BUILD_BUG_ON(sizeof(ha_t) != HA_SIZE);
return -ENODEV;
}
#endif /* STRUCT_CHECK */
dev = alloc_etherdev(sizeof(net_local)); dev = alloc_etherdev(sizeof(net_local));
if (!dev) if (!dev)
......
...@@ -400,7 +400,6 @@ ...@@ -400,7 +400,6 @@
*/ */
#undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */ #undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */
#define USE_PSA_CONFIG /* Use info from the PSA. */ #define USE_PSA_CONFIG /* Use info from the PSA. */
#undef STRUCT_CHECK /* Verify padding of structures. */
#undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */ #undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */
#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ #define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */
#undef SET_MAC_ADDRESS /* Experimental */ #undef SET_MAC_ADDRESS /* Experimental */
......
...@@ -71,27 +71,6 @@ static void wv_nwid_filter(unsigned char mode, net_local *lp); ...@@ -71,27 +71,6 @@ static void wv_nwid_filter(unsigned char mode, net_local *lp);
* (wavelan modem or i82593) * (wavelan modem or i82593)
*/ */
#ifdef STRUCT_CHECK
/*------------------------------------------------------------------*/
/*
* Sanity routine to verify the sizes of the various WaveLAN interface
* structures.
*/
static char *
wv_structuct_check(void)
{
#define SC(t,s,n) if (sizeof(t) != s) return(n);
SC(psa_t, PSA_SIZE, "psa_t");
SC(mmw_t, MMW_SIZE, "mmw_t");
SC(mmr_t, MMR_SIZE, "mmr_t");
#undef SC
return((char *) NULL);
} /* wv_structuct_check */
#endif /* STRUCT_CHECK */
/******************* MODEM MANAGEMENT SUBROUTINES *******************/ /******************* MODEM MANAGEMENT SUBROUTINES *******************/
/* /*
* Useful subroutines to manage the modem of the wavelan * Useful subroutines to manage the modem of the wavelan
...@@ -3794,14 +3773,10 @@ wv_hw_config(struct net_device * dev) ...@@ -3794,14 +3773,10 @@ wv_hw_config(struct net_device * dev)
printk(KERN_DEBUG "%s: ->wv_hw_config()\n", dev->name); printk(KERN_DEBUG "%s: ->wv_hw_config()\n", dev->name);
#endif #endif
#ifdef STRUCT_CHECK /* compile-time check the sizes of structures */
if(wv_structuct_check() != (char *) NULL) BUILD_BUG_ON(sizeof(psa_t) != PSA_SIZE);
{ BUILD_BUG_ON(sizeof(mmw_t) != MMW_SIZE);
printk(KERN_WARNING "%s: wv_hw_config: structure/compiler botch: \"%s\"\n", BUILD_BUG_ON(sizeof(mmr_t) != MMR_SIZE);
dev->name, wv_structuct_check());
return FALSE;
}
#endif /* STRUCT_CHECK == 1 */
/* Reset the pcmcia interface */ /* Reset the pcmcia interface */
if(wv_pcmcia_reset(dev) == FALSE) if(wv_pcmcia_reset(dev) == FALSE)
......
...@@ -459,7 +459,6 @@ ...@@ -459,7 +459,6 @@
#undef WAVELAN_ROAMING_EXT /* Enable roaming wireless extensions */ #undef WAVELAN_ROAMING_EXT /* Enable roaming wireless extensions */
#undef SET_PSA_CRC /* Set the CRC in PSA (slower) */ #undef SET_PSA_CRC /* Set the CRC in PSA (slower) */
#define USE_PSA_CONFIG /* Use info from the PSA */ #define USE_PSA_CONFIG /* Use info from the PSA */
#undef STRUCT_CHECK /* Verify padding of structures */
#undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */ #undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */
#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */ #define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */
#undef SET_MAC_ADDRESS /* Experimental */ #undef SET_MAC_ADDRESS /* Experimental */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment