From b6ac161364eccce1bea4a23a9de395883e90d7ab Mon Sep 17 00:00:00 2001 From: Stoyan Gaydarov Date: Tue, 21 Jul 2009 22:02:27 -0500 Subject: Staging: ARRAY_SIZE changes These changes were a direct result of using a semantic patch More information can be found at http://www.emn.fr/x-info/coccinelle/ Signed-off-by: Stoyan Gaydarov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index c4d8c4c..091a1a5 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -513,7 +513,7 @@ MODULE_DEVICE_TABLE(pci, pci230_pci_table); /* * Useful for shorthand access to the particular board structure */ -#define n_pci230_boards (sizeof(pci230_boards)/sizeof(pci230_boards[0])) +#define n_pci230_boards ARRAY_SIZE(pci230_boards) #define thisboard ((const struct pci230_board *)dev->board_ptr) /* this structure is for data unique to this hardware driver. If diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 2f7aa3b..12d12b4 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -78,7 +78,7 @@ static const struct das16cs_board das16cs_boards[] = { }, }; -#define n_boards (sizeof(das16cs_boards)/sizeof(das16cs_boards[0])) +#define n_boards ARRAY_SIZE(das16cs_boards) #define thisboard ((const struct das16cs_board *)dev->board_ptr) struct das16cs_private { diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 74fcc10..9cab21e 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -65,8 +65,7 @@ static struct comedi_driver driver_das08_cs = { .attach = das08_cs_attach, .detach = das08_common_detach, .board_name = &das08_cs_boards[0].name, - .num_names = sizeof(das08_cs_boards) / - sizeof(struct das08_board_struct), + .num_names = ARRAY_SIZE(das08_cs_boards), .offset = sizeof(struct das08_board_struct), }; diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 7a49dfc..b37ef37 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -103,7 +103,7 @@ static const struct ni6527_board ni6527_boards[] = { }, }; -#define n_ni6527_boards (sizeof(ni6527_boards)/sizeof(ni6527_boards[0])) +#define n_ni6527_boards ARRAY_SIZE(ni6527_boards) #define this_board ((const struct ni6527_board *)dev->board_ptr) static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = { diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 8079c41..6b118c1 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -246,7 +246,7 @@ static const struct ni_65xx_board ni_65xx_boards[] = { }, }; -#define n_ni_65xx_boards (sizeof(ni_65xx_boards)/sizeof(ni_65xx_boards[0])) +#define n_ni_65xx_boards ARRAY_SIZE(ni_65xx_boards) static inline const struct ni_65xx_board *board(struct comedi_device *dev) { return dev->board_ptr; diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 772c937..404d3c5 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -454,7 +454,7 @@ static inline const struct ni_660x_board *board(struct comedi_device *dev) return dev->board_ptr; } -#define n_ni_660x_boards (sizeof(ni_660x_boards)/sizeof(ni_660x_boards[0])) +#define n_ni_660x_boards ARRAY_SIZE(ni_660x_boards) static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 89ce5b8..9b43547 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -111,7 +111,7 @@ struct ni_670x_private { }; #define devpriv ((struct ni_670x_private *)dev->private) -#define n_ni_670x_boards (sizeof(ni_670x_boards)/sizeof(ni_670x_boards[0])) +#define n_ni_670x_boards ARRAY_SIZE(ni_670x_boards) static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it); diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index cde30b7..901833d 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -121,7 +121,7 @@ static const struct atmio16_board_t atmio16_boards[] = { }, }; -#define n_atmio16_boards sizeof(atmio16_boards)/sizeof(atmio16_boards[0]) +#define n_atmio16_boards ARRAY_SIZE(atmio16_boards) #define boardtype ((const struct atmio16_board_t *)dev->board_ptr) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 15148d1..52b2eca 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -374,7 +374,7 @@ static const struct nidio_board nidio_boards[] = { }, }; -#define n_nidio_boards (sizeof(nidio_boards)/sizeof(nidio_boards[0])) +#define n_nidio_boards ARRAY_SIZE(nidio_boards) #define this_board ((const struct nidio_board *)dev->board_ptr) static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = { diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 0dc6392..19d8755 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1208,7 +1208,7 @@ static const struct ni_board_struct ni_boards[] = { }, }; -#define n_pcimio_boards ((sizeof(ni_boards)/sizeof(ni_boards[0]))) +#define n_pcimio_boards ARRAY_SIZE(ni_boards) static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it); diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index 7368bf3..acac670 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -69,7 +69,7 @@ static const struct pcmad_board_struct pcmad_boards[] = { }; #define this_board ((const struct pcmad_board_struct *)(dev->board_ptr)) -#define n_pcmad_boards (sizeof(pcmad_boards)/sizeof(pcmad_boards[0])) +#define n_pcmad_boards ARRAY_SIZE(pcmad_boards) struct pcmad_priv_struct { int differential; diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 729a0d8..d23e588 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -102,7 +102,7 @@ static const struct boarddef_struct boards[] = { }, }; -#define n_boards (sizeof(boards)/sizeof(boards[0])) +#define n_boards ARRAY_SIZE(boards) #define this_board ((const struct boarddef_struct *)dev->board_ptr) static struct comedi_driver driver_poc = { diff --git a/drivers/staging/epl/EplDllk.c b/drivers/staging/epl/EplDllk.c index 25d2c34..0572c3d 100644 --- a/drivers/staging/epl/EplDllk.c +++ b/drivers/staging/epl/EplDllk.c @@ -328,7 +328,7 @@ tEplKernel EplDllkAddInstance(tEplDllkInitParam * pInitParam_p) // initialize and link pointers in instance structure to frame tables EplDllkInstance_g.m_pTxBuffer = aEplDllkTxBuffer_l; EplDllkInstance_g.m_uiMaxTxFrames = - sizeof(aEplDllkTxBuffer_l) / sizeof(tEdrvTxBuffer); + ARRAY_SIZE(aEplDllkTxBuffer_l); // initialize state EplDllkInstance_g.m_DllState = kEplDllGsInit; diff --git a/drivers/staging/epl/proc_fs.c b/drivers/staging/epl/proc_fs.c index 9ccf079..e48949d 100644 --- a/drivers/staging/epl/proc_fs.c +++ b/drivers/staging/epl/proc_fs.c @@ -196,7 +196,7 @@ void TgtDbgSignalTracePoint(u8 bTracePointNumber_p) { if (bTracePointNumber_p >= - (sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0]))) { + ARRAY_SIZE(aatmDbgTracePoint_l)) { goto Exit; } @@ -330,7 +330,7 @@ static int EplLinProcRead(char *pcBuffer_p, nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize, "DbgTracePoints:\n"); for (nNum = 0; - nNum < (sizeof(aatmDbgTracePoint_l) / sizeof(atomic_t)); + nNum < ARRAY_SIZE(aatmDbgTracePoint_l); nNum++) { nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize, diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 85a20d0..f188ece 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -682,7 +682,7 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_ return -ENODEV; /* check vendor and product id */ - for (devtype = sizeof(line6_id_table) / sizeof(line6_id_table[0]) - 1; devtype--;) + for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) if ((le16_to_cpu(usbdev->descriptor.idVendor) == line6_id_table[devtype].idVendor) && (le16_to_cpu(usbdev->descriptor.idProduct) == line6_id_table[devtype].idProduct)) break; diff --git a/drivers/staging/meilhaus/me0600_device.h b/drivers/staging/meilhaus/me0600_device.h index d93a8ae..75bd3b7 100644 --- a/drivers/staging/meilhaus/me0600_device.h +++ b/drivers/staging/meilhaus/me0600_device.h @@ -54,7 +54,7 @@ static me0600_version_t me0600_versions[] = { {0}, }; -#define ME0600_DEVICE_VERSIONS (sizeof(me0600_versions) / sizeof(me0600_version_t) - 1) /**< Returns the number of entries in #me0600_versions. */ +#define ME0600_DEVICE_VERSIONS (ARRAY_SIZE(me0600_versions) - 1) /**< Returns the number of entries in #me0600_versions. */ /** * @brief Returns the index of the device entry in #me0600_versions. diff --git a/drivers/staging/meilhaus/me0900_device.h b/drivers/staging/meilhaus/me0900_device.h index bd17f25..53c05e8 100644 --- a/drivers/staging/meilhaus/me0900_device.h +++ b/drivers/staging/meilhaus/me0900_device.h @@ -53,7 +53,7 @@ static me0900_version_t me0900_versions[] = { {0}, }; -#define ME0900_DEVICE_VERSIONS (sizeof(me0900_versions) / sizeof(me0900_version_t) - 1) /**< Returns the number of entries in #me0900_versions. */ +#define ME0900_DEVICE_VERSIONS (ARRAY_SIZE(me0900_versions) - 1) /**< Returns the number of entries in #me0900_versions. */ /** * @brief Returns the index of the device entry in #me0900_versions. diff --git a/drivers/staging/meilhaus/me1400_device.h b/drivers/staging/meilhaus/me1400_device.h index 6215b25..d20112d 100644 --- a/drivers/staging/meilhaus/me1400_device.h +++ b/drivers/staging/meilhaus/me1400_device.h @@ -60,7 +60,7 @@ static me1400_version_t me1400_versions[] = { {0} }; -#define ME1400_DEVICE_VERSIONS (sizeof(me1400_versions) / sizeof(me1400_version_t) - 1) /**< Returns the number of entries in #me1400_versions. */ +#define ME1400_DEVICE_VERSIONS (ARRAY_SIZE(me1400_versions) - 1) /**< Returns the number of entries in #me1400_versions. */ /** * @brief Returns the index of the device entry in #me1400_versions. diff --git a/drivers/staging/meilhaus/me1600_device.h b/drivers/staging/meilhaus/me1600_device.h index f7b231f..c73aca1 100644 --- a/drivers/staging/meilhaus/me1600_device.h +++ b/drivers/staging/meilhaus/me1600_device.h @@ -58,7 +58,7 @@ static me1600_version_t me1600_versions[] = { }; /**< Returns the number of entries in #me1600_versions. */ -#define ME1600_DEVICE_VERSIONS (sizeof(me1600_versions) / sizeof(me1600_version_t) - 1) +#define ME1600_DEVICE_VERSIONS (ARRAY_SIZE(me1600_versions) - 1) /** * @brief Returns the index of the device entry in #me1600_versions. diff --git a/drivers/staging/meilhaus/me4600_device.h b/drivers/staging/meilhaus/me4600_device.h index fa812d4..c755c57 100644 --- a/drivers/staging/meilhaus/me4600_device.h +++ b/drivers/staging/meilhaus/me4600_device.h @@ -80,7 +80,7 @@ static me4600_version_t me4600_versions[] = { {0}, }; -#define ME4600_DEVICE_VERSIONS (sizeof(me4600_versions) / sizeof(me4600_version_t) - 1) /**< Returns the number of entries in #me4600_versions. */ +#define ME4600_DEVICE_VERSIONS (ARRAY_SIZE(me4600_versions) - 1) /**< Returns the number of entries in #me4600_versions. */ /** * @brief Returns the index of the device entry in #me4600_versions. diff --git a/drivers/staging/meilhaus/me6000_device.h b/drivers/staging/meilhaus/me6000_device.h index 18cc7d1..eed4011 100644 --- a/drivers/staging/meilhaus/me6000_device.h +++ b/drivers/staging/meilhaus/me6000_device.h @@ -103,7 +103,7 @@ static me6000_version_t me6000_versions[] = { {0}, }; -#define ME6000_DEVICE_VERSIONS (sizeof(me6000_versions) / sizeof(me6000_version_t) - 1) /**< Returns the number of entries in #me6000_versions. */ +#define ME6000_DEVICE_VERSIONS (ARRAY_SIZE(me6000_versions) - 1) /**< Returns the number of entries in #me6000_versions. */ /** * @brief Returns the index of the device entry in #me6000_versions. diff --git a/drivers/staging/meilhaus/me8100_device.h b/drivers/staging/meilhaus/me8100_device.h index 44c42ef..238dc06 100644 --- a/drivers/staging/meilhaus/me8100_device.h +++ b/drivers/staging/meilhaus/me8100_device.h @@ -53,7 +53,7 @@ static me8100_version_t me8100_versions[] = { {0}, }; -#define ME8100_DEVICE_VERSIONS (sizeof(me8100_versions) / sizeof(me8100_version_t) - 1) /**< Returns the number of entries in #me8100_versions. */ +#define ME8100_DEVICE_VERSIONS (ARRAY_SIZE(me8100_versions) - 1) /**< Returns the number of entries in #me8100_versions. */ /** * @brief Returns the index of the device entry in #me8100_versions. diff --git a/drivers/staging/meilhaus/me8200_device.h b/drivers/staging/meilhaus/me8200_device.h index cbd2a01..66f5084 100644 --- a/drivers/staging/meilhaus/me8200_device.h +++ b/drivers/staging/meilhaus/me8200_device.h @@ -53,7 +53,7 @@ static me8200_version_t me8200_versions[] = { {0}, }; -#define ME8200_DEVICE_VERSIONS (sizeof(me8200_versions) / sizeof(me8200_version_t) - 1) /**< Returns the number of entries in #me8200_versions. */ +#define ME8200_DEVICE_VERSIONS (ARRAY_SIZE(me8200_versions) - 1) /**< Returns the number of entries in #me8200_versions. */ /** * @brief Returns the index of the device entry in #me8200_versions. diff --git a/drivers/staging/meilhaus/metempl_device.h b/drivers/staging/meilhaus/metempl_device.h index 3c3702c..c0626e7 100644 --- a/drivers/staging/meilhaus/metempl_device.h +++ b/drivers/staging/meilhaus/metempl_device.h @@ -50,7 +50,7 @@ static metempl_version_t metempl_versions[] = { {0}, }; -#define METEMPL_DEVICE_VERSIONS (sizeof(metempl_versions) / sizeof(metempl_version_t) - 1) /**< Returns the number of entries in #metempl_versions. */ +#define METEMPL_DEVICE_VERSIONS (ARRAY_SIZE(metempl_versions) - 1) /**< Returns the number of entries in #metempl_versions. */ /** * @brief Returns the index of the device entry in #metempl_versions. diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 081c022..766892e 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -27,7 +27,7 @@ u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; -#define RATE_COUNT (sizeof(rtl8180_rates)/sizeof(rtl8180_rates[0])) +#define RATE_COUNT ARRAY_SIZE(rtl8180_rates) static CHANNEL_LIST DefaultChannelPlan[] = { // {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}, //Default channel plan @@ -1578,9 +1578,9 @@ static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev) struct iw_handler_def r8180_wx_handlers_def={ .standard = r8180_wx_handlers, - .num_standard = sizeof(r8180_wx_handlers) / sizeof(iw_handler), + .num_standard = ARRAY_SIZE(r8180_wx_handlers), .private = r8180_private_handler, - .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler), + .num_private = ARRAY_SIZE(r8180_private_handler), .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args), .get_wireless_stats = r8180_get_wireless_stats, .private_args = (struct iw_priv_args *)r8180_private_args, diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c index 3afd8b3..145a312 100644 --- a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c @@ -87,7 +87,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - for(i=0; i<(sizeof(ieee80211_modes)/sizeof(ieee80211_modes[0])); i++) { + for(i=0; imode&(1<