* [PATCH 0/7] ARRAY_SIZE changes @ 2009-07-22 3:02 Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 1/7] [staging] " Stoyan Gaydarov 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov These changes were a direct result of using a semantic patch More information can be found at http://www.emn.fr/x-info/coccinelle/ Stoyan Gaydarov (7): [staging] ARRAY_SIZE changes [isdn] ARRAY_SIZE changes [video] ARRAY_SIZE changes [drivers] ARRAY_SIZE changes [powerpc] ARRAY_SIZE changes [ia64] ARRAY_SIZE changes [cris] ARRAY_SIZE changes arch/cris/arch-v32/mach-a3/io.c | 2 +- arch/cris/arch-v32/mach-fs/io.c | 2 +- arch/ia64/kernel/perfmon.c | 2 +- arch/ia64/xen/xen_pv_ops.c | 3 +- arch/powerpc/platforms/pasemi/idle.c | 2 +- arch/powerpc/platforms/powermac/feature.c | 4 +- drivers/ata/sata_mv.c | 2 +- drivers/infiniband/hw/ipath/ipath_intr.c | 4 +-- drivers/isdn/act2000/capi.c | 2 +- drivers/isdn/act2000/module.c | 2 +- drivers/isdn/hardware/eicon/message.c | 2 +- drivers/isdn/hardware/eicon/os_4bri.c | 3 +- drivers/isdn/hisax/callc.c | 2 +- drivers/isdn/hisax/isdnl1.c | 6 ++-- drivers/isdn/hisax/isdnl2.c | 2 +- drivers/isdn/hisax/isdnl3.c | 2 +- drivers/isdn/hisax/l3_1tr6.c | 9 ++----- drivers/isdn/hisax/l3dss1.c | 12 +++------ drivers/isdn/hisax/l3ni1.c | 12 +++------ drivers/isdn/hisax/q931.c | 24 ++++++++++---------- drivers/isdn/hisax/tei.c | 2 +- drivers/media/dvb/frontends/au8522_decoder.c | 6 +--- drivers/media/video/gspca/conex.c | 2 +- drivers/media/video/gspca/etoms.c | 4 +- drivers/media/video/gspca/spca501.c | 2 +- drivers/media/video/gspca/spca506.c | 2 +- drivers/media/video/gspca/sunplus.c | 6 ++-- drivers/media/video/gspca/zc3xx.c | 2 +- drivers/media/video/tveeprom.c | 4 +- drivers/mtd/lpddr/qinfo_probe.c | 2 +- drivers/mtd/maps/solutionengine.c | 2 +- drivers/net/s6gmac.c | 2 +- drivers/net/wireless/prism54/oid_mgt.c | 5 +-- drivers/pcmcia/i82365.c | 2 +- drivers/serial/68328serial.c | 6 ++-- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- drivers/staging/comedi/drivers/cb_das16_cs.c | 2 +- drivers/staging/comedi/drivers/das08_cs.c | 3 +- drivers/staging/comedi/drivers/ni_6527.c | 2 +- drivers/staging/comedi/drivers/ni_65xx.c | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_670x.c | 2 +- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_pcimio.c | 2 +- drivers/staging/comedi/drivers/pcmad.c | 2 +- drivers/staging/comedi/drivers/poc.c | 2 +- drivers/staging/epl/EplDllk.c | 2 +- drivers/staging/epl/proc_fs.c | 4 +- drivers/staging/line6/driver.c | 2 +- drivers/staging/meilhaus/me0600_device.h | 2 +- drivers/staging/meilhaus/me0900_device.h | 2 +- drivers/staging/meilhaus/me1400_device.h | 2 +- drivers/staging/meilhaus/me1600_device.h | 2 +- drivers/staging/meilhaus/me4600_device.h | 2 +- drivers/staging/meilhaus/me6000_device.h | 2 +- drivers/staging/meilhaus/me8100_device.h | 2 +- drivers/staging/meilhaus/me8200_device.h | 2 +- drivers/staging/meilhaus/metempl_device.h | 2 +- drivers/staging/rtl8187se/r8180_wx.c | 6 ++-- drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c | 2 +- drivers/staging/rtl8192su/r8192U_wx.c | 4 +- drivers/staging/slicoss/slicoss.c | 2 +- drivers/staging/sxg/sxg.c | 2 +- drivers/usb/gadget/ci13xxx_udc.c | 2 +- drivers/zorro/names.c | 2 +- 66 files changed, 100 insertions(+), 119 deletions(-) ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] [staging] ARRAY_SIZE changes 2009-07-22 3:02 [PATCH 0/7] ARRAY_SIZE changes Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 2/7] [isdn] " Stoyan Gaydarov 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, gregkh, devel 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 <sgayda2@uiuc.edu> --- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- drivers/staging/comedi/drivers/cb_das16_cs.c | 2 +- drivers/staging/comedi/drivers/das08_cs.c | 3 +-- drivers/staging/comedi/drivers/ni_6527.c | 2 +- drivers/staging/comedi/drivers/ni_65xx.c | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_670x.c | 2 +- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_pcimio.c | 2 +- drivers/staging/comedi/drivers/pcmad.c | 2 +- drivers/staging/comedi/drivers/poc.c | 2 +- drivers/staging/epl/EplDllk.c | 2 +- drivers/staging/epl/proc_fs.c | 4 ++-- drivers/staging/line6/driver.c | 2 +- drivers/staging/meilhaus/me0600_device.h | 2 +- drivers/staging/meilhaus/me0900_device.h | 2 +- drivers/staging/meilhaus/me1400_device.h | 2 +- drivers/staging/meilhaus/me1600_device.h | 2 +- drivers/staging/meilhaus/me4600_device.h | 2 +- drivers/staging/meilhaus/me6000_device.h | 2 +- drivers/staging/meilhaus/me8100_device.h | 2 +- drivers/staging/meilhaus/me8200_device.h | 2 +- drivers/staging/meilhaus/metempl_device.h | 2 +- drivers/staging/rtl8187se/r8180_wx.c | 6 +++--- drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c | 2 +- drivers/staging/rtl8192su/r8192U_wx.c | 4 ++-- drivers/staging/slicoss/slicoss.c | 2 +- drivers/staging/sxg/sxg.c | 2 +- 29 files changed, 33 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 21133f0..84d355e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -512,7 +512,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 7af245b..59f635f 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 8e44641..bfd2b8d 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -64,8 +64,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 67adc97..e331004 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -102,7 +102,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 3570850..e261079 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -241,7 +241,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 11e9b04..edf57f9 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -447,7 +447,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); static int ni_660x_detach(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 71f7d3a..0412c93 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -110,7 +110,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); static int ni_670x_detach(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 1a8c2ab..eaeb721 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 6b86a39..3d50ac7 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -372,7 +372,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 1d04b75..b42d106 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1205,7 +1205,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); static int pcimio_detach(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index 9bb2669..bfb2df3 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 47850bd..bbcdec9 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -100,7 +100,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 979ba0b..ffefc25 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -30,7 +30,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 @@ -1631,9 +1631,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), #if WIRELESS_EXT >= 17 .get_wireless_stats = r8180_get_wireless_stats, diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c index ae11e25..b5b9c6c 100644 --- a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c @@ -120,7 +120,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; i<ARRAY_SIZE(ieee80211_modes); i++) { if(network->mode&(1<<i)) { sprintf(pname,ieee80211_modes[i].mode_string,ieee80211_modes[i].mode_size); pname +=ieee80211_modes[i].mode_size; diff --git a/drivers/staging/rtl8192su/r8192U_wx.c b/drivers/staging/rtl8192su/r8192U_wx.c index f9eafb1..c3f8148 100644 --- a/drivers/staging/rtl8192su/r8192U_wx.c +++ b/drivers/staging/rtl8192su/r8192U_wx.c @@ -1339,9 +1339,9 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) struct iw_handler_def r8192_wx_handlers_def={ .standard = r8192_wx_handlers, - .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), + .num_standard = ARRAY_SIZE(r8192_wx_handlers), .private = r8192_private_handler, - .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), + .num_private = ARRAY_SIZE(r8192_private_handler), .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), #if WIRELESS_EXT >= 17 .get_wireless_stats = r8192_get_wireless_stats, diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index ed47db5..582835c 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1306,7 +1306,7 @@ static void slic_mcast_init_crc32(void) static int p[] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 }; - for (i = 0; i < sizeof(p) / sizeof(int); i++) + for (i = 0; i < ARRAY_SIZE(p); i++) e |= 1L << (31 - p[i]); for (i = 1; i < 256; i++) { diff --git a/drivers/staging/sxg/sxg.c b/drivers/staging/sxg/sxg.c index 3a0dac9..395e876 100644 --- a/drivers/staging/sxg/sxg.c +++ b/drivers/staging/sxg/sxg.c @@ -3500,7 +3500,7 @@ static void sxg_mcast_init_crc32(void) static int p[] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 }; - for (i = 0; i < sizeof(p) / sizeof(int); i++) { + for (i = 0; i < ARRAY_SIZE(p); i++) { e |= 1L << (31 - p[i]); } -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] [isdn] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 1/7] [staging] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 3/7] [video] " Stoyan Gaydarov 2009-07-24 10:51 ` [PATCH 2/7] [isdn] " Karsten Keil 0 siblings, 2 replies; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, isdn 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 <sgayda2@uiuc.edu> --- drivers/isdn/act2000/capi.c | 2 +- drivers/isdn/act2000/module.c | 2 +- drivers/isdn/hardware/eicon/message.c | 2 +- drivers/isdn/hardware/eicon/os_4bri.c | 3 +-- drivers/isdn/hisax/callc.c | 2 +- drivers/isdn/hisax/isdnl1.c | 6 +++--- drivers/isdn/hisax/isdnl2.c | 2 +- drivers/isdn/hisax/isdnl3.c | 2 +- drivers/isdn/hisax/l3_1tr6.c | 9 +++------ drivers/isdn/hisax/l3dss1.c | 12 ++++-------- drivers/isdn/hisax/l3ni1.c | 12 ++++-------- drivers/isdn/hisax/q931.c | 24 ++++++++++++------------ drivers/isdn/hisax/tei.c | 2 +- 13 files changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c index 946c38c..a3428da 100644 --- a/drivers/isdn/act2000/capi.c +++ b/drivers/isdn/act2000/capi.c @@ -78,7 +78,7 @@ static actcapi_msgdsc valid_msg[] = { #endif {{ 0x00, 0x00}, NULL}, }; -#define num_valid_msg (sizeof(valid_msg)/sizeof(actcapi_msgdsc)) +#define num_valid_msg ARRAY_SIZE(valid_msg) #define num_valid_imsg 27 /* MANUFACTURER_IND */ /* diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c index 8325022..6387baa 100644 --- a/drivers/isdn/act2000/module.c +++ b/drivers/isdn/act2000/module.c @@ -23,7 +23,7 @@ static unsigned short act2000_isa_ports[] = 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380, 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60, }; -#define ISA_NRPORTS (sizeof(act2000_isa_ports)/sizeof(unsigned short)) +#define ISA_NRPORTS ARRAY_SIZE(act2000_isa_ports) static act2000_card *cards = (act2000_card *) NULL; diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c index 31f91c1..9253209 100644 --- a/drivers/isdn/hardware/eicon/message.c +++ b/drivers/isdn/hardware/eicon/message.c @@ -552,7 +552,7 @@ word api_put(APPL * appl, CAPI_MSG * msg) for(j=0;j<MAX_MSG_PARMS+1;j++) msg_parms[j].length = 0; for(i=0, ret = _BAD_MSG; - i<(sizeof(ftable)/sizeof(struct _ftable)); + i<ARRAY_SIZE(ftable); i++) { if(ftable[i].command==msg->header.command) { diff --git a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c index c964b8d..cb7616c 100644 --- a/drivers/isdn/hardware/eicon/os_4bri.c +++ b/drivers/isdn/hardware/eicon/os_4bri.c @@ -149,8 +149,7 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) diva_os_xdi_adapter_t *diva_current; diva_os_xdi_adapter_t *adapter_list[4]; PISDN_ADAPTER Slave; - unsigned long bar_length[sizeof(_4bri_bar_length) / - sizeof(_4bri_bar_length[0])]; + unsigned long bar_length[ARRAY_SIZE(_4bri_bar_length)]; int v2 = _4bri_is_rev_2_card(a->CardOrdinal); int tasks = _4bri_is_rev_2_bri_card(a->CardOrdinal) ? 1 : MQ_INSTANCE_COUNT; int factor = (tasks == 1) ? 1 : 2; diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index 025a20d..f90d6a6 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -833,7 +833,7 @@ static struct FsmNode fnlist[] __initdata = }; /* *INDENT-ON* */ -#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode)) +#define FNCOUNT ARRAY_SIZE(fnlist) int __init CallcNew(void) diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c index 317f16f..980e099 100644 --- a/drivers/isdn/hisax/isdnl1.c +++ b/drivers/isdn/hisax/isdnl1.c @@ -647,7 +647,7 @@ static struct FsmNode L1SFnList[] __initdata = {ST_L1_F8, EV_TIMER_DEACT, l1_timer_deact}, }; -#define L1S_FN_COUNT (sizeof(L1SFnList)/sizeof(struct FsmNode)) +#define L1S_FN_COUNT ARRAY_SIZE(L1SFnList) #ifdef HISAX_UINTERFACE static void @@ -706,7 +706,7 @@ static struct FsmNode L1UFnList[] __initdata = {ST_L1_RESET, EV_TIMER_DEACT, l1_timer_deact}, }; -#define L1U_FN_COUNT (sizeof(L1UFnList)/sizeof(struct FsmNode)) +#define L1U_FN_COUNT ARRAY_SIZE(L1UFnList) #endif @@ -754,7 +754,7 @@ static struct FsmNode L1BFnList[] __initdata = {ST_L1_WAIT_DEACT, EV_TIMER_DEACT, l1b_timer_deact}, }; -#define L1B_FN_COUNT (sizeof(L1BFnList)/sizeof(struct FsmNode)) +#define L1B_FN_COUNT ARRAY_SIZE(L1BFnList) int __init Isdnl1New(void) diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c index 3446f24..846a7e6 100644 --- a/drivers/isdn/hisax/isdnl2.c +++ b/drivers/isdn/hisax/isdnl2.c @@ -1623,7 +1623,7 @@ static struct FsmNode L2FnList[] __initdata = {ST_L2_8, EV_L1_DEACTIVATE, l2_persistent_da}, }; -#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode)) +#define L2_FN_COUNT ARRAY_SIZE(L2FnList) static void isdnl2_l1l2(struct PStack *st, int pr, void *arg) diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c index 935f233..c081fed 100644 --- a/drivers/isdn/hisax/isdnl3.c +++ b/drivers/isdn/hisax/isdnl3.c @@ -543,7 +543,7 @@ static struct FsmNode L3FnList[] __initdata = }; /* *INDENT-ON* */ -#define L3_FN_COUNT (sizeof(L3FnList)/sizeof(struct FsmNode)) +#define L3_FN_COUNT ARRAY_SIZE(L3FnList) void l3_msg(struct PStack *st, int pr, void *arg) diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c index c5c36ee..ff62679 100644 --- a/drivers/isdn/hisax/l3_1tr6.c +++ b/drivers/isdn/hisax/l3_1tr6.c @@ -698,8 +698,7 @@ static struct stateentry downstl[] = CC_T308_2, l3_1tr6_t308_2}, }; -#define DOWNSTL_LEN \ - (sizeof(downstl) / sizeof(struct stateentry)) +#define DOWNSTL_LEN ARRAY_SIZE(downstl) static struct stateentry datastln1[] = { @@ -735,8 +734,7 @@ static struct stateentry datastln1[] = MT_N1_REL_ACK, l3_1tr6_rel_ack} }; -#define DATASTLN1_LEN \ - (sizeof(datastln1) / sizeof(struct stateentry)) +#define DATASTLN1_LEN ARRAY_SIZE(datastln1) static struct stateentry manstatelist[] = { @@ -746,8 +744,7 @@ static struct stateentry manstatelist[] = DL_RELEASE | INDICATION, l3_1tr6_dl_release}, }; -#define MANSLLEN \ - (sizeof(manstatelist) / sizeof(struct stateentry)) +#define MANSLLEN ARRAY_SIZE(manstatelist) /* *INDENT-ON* */ static void diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c index 99feae8..c434fa5 100644 --- a/drivers/isdn/hisax/l3dss1.c +++ b/drivers/isdn/hisax/l3dss1.c @@ -2820,8 +2820,7 @@ static struct stateentry downstatelist[] = CC_T309, l3dss1_dl_release}, }; -#define DOWNSLLEN \ - (sizeof(downstatelist) / sizeof(struct stateentry)) +#define DOWNSLLEN ARRAY_SIZE(downstatelist) static struct stateentry datastatelist[] = { @@ -2875,8 +2874,7 @@ static struct stateentry datastatelist[] = MT_RESUME_REJECT, l3dss1_resume_rej}, }; -#define DATASLLEN \ - (sizeof(datastatelist) / sizeof(struct stateentry)) +#define DATASLLEN ARRAY_SIZE(datastatelist) static struct stateentry globalmes_list[] = { @@ -2888,8 +2886,7 @@ static struct stateentry globalmes_list[] = MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack}, */ }; -#define GLOBALM_LEN \ - (sizeof(globalmes_list) / sizeof(struct stateentry)) +#define GLOBALM_LEN ARRAY_SIZE(globalmes_list) static struct stateentry manstatelist[] = { @@ -2903,8 +2900,7 @@ static struct stateentry manstatelist[] = DL_RELEASE | INDICATION, l3dss1_dl_release}, }; -#define MANSLLEN \ - (sizeof(manstatelist) / sizeof(struct stateentry)) +#define MANSLLEN ARRAY_SIZE(manstatelist) /* *INDENT-ON* */ diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c index f7041d5..ba05ae3 100644 --- a/drivers/isdn/hisax/l3ni1.c +++ b/drivers/isdn/hisax/l3ni1.c @@ -2755,8 +2755,7 @@ static struct stateentry downstatelist[] = CC_TSPID, l3ni1_spid_tout }, }; -#define DOWNSLLEN \ - (sizeof(downstatelist) / sizeof(struct stateentry)) +#define DOWNSLLEN ARRAY_SIZE(downstatelist) static struct stateentry datastatelist[] = { @@ -2810,8 +2809,7 @@ static struct stateentry datastatelist[] = MT_RESUME_REJECT, l3ni1_resume_rej}, }; -#define DATASLLEN \ - (sizeof(datastatelist) / sizeof(struct stateentry)) +#define DATASLLEN ARRAY_SIZE(datastatelist) static struct stateentry globalmes_list[] = { @@ -2825,8 +2823,7 @@ static struct stateentry globalmes_list[] = { SBIT( 0 ), MT_DL_ESTABLISHED, l3ni1_spid_send }, { SBIT( 20 ) | SBIT( 21 ) | SBIT( 22 ), MT_INFORMATION, l3ni1_spid_epid }, }; -#define GLOBALM_LEN \ - (sizeof(globalmes_list) / sizeof(struct stateentry)) +#define GLOBALM_LEN ARRAY_SIZE(globalmes_list) static struct stateentry manstatelist[] = { @@ -2840,8 +2837,7 @@ static struct stateentry manstatelist[] = DL_RELEASE | INDICATION, l3ni1_dl_release}, }; -#define MANSLLEN \ - (sizeof(manstatelist) / sizeof(struct stateentry)) +#define MANSLLEN ARRAY_SIZE(manstatelist) /* *INDENT-ON* */ diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c index aacbf0d..8b853d5 100644 --- a/drivers/isdn/hisax/q931.c +++ b/drivers/isdn/hisax/q931.c @@ -140,7 +140,7 @@ struct MessageType { } }; -#define MTSIZE sizeof(mtlist)/sizeof(struct MessageType) +#define MTSIZE ARRAY_SIZE(mtlist) static struct MessageType mt_n0[] = @@ -157,7 +157,7 @@ struct MessageType mt_n0[] = {MT_N0_CLO_ACK, "CLOse ACKnowledge"} }; -#define MT_N0_LEN (sizeof(mt_n0) / sizeof(struct MessageType)) +#define MT_N0_LEN ARRAY_SIZE(mt_n0) static struct MessageType mt_n1[] = @@ -194,7 +194,7 @@ struct MessageType mt_n1[] = {MT_N1_STAT, "STATus"} }; -#define MT_N1_LEN (sizeof(mt_n1) / sizeof(struct MessageType)) +#define MT_N1_LEN ARRAY_SIZE(mt_n1) static int @@ -438,7 +438,7 @@ struct CauseValue { }, }; -#define CVSIZE sizeof(cvlist)/sizeof(struct CauseValue) +#define CVSIZE ARRAY_SIZE(cvlist) static int @@ -516,7 +516,7 @@ struct MessageType cause_1tr6[] = {CAUSE_UserInfoDiscarded, "User Info Discarded"} }; -static int cause_1tr6_len = (sizeof(cause_1tr6) / sizeof(struct MessageType)); +static int cause_1tr6_len = ARRAY_SIZE(cause_1tr6); static int prcause_1tr6(char *dest, u_char * p) @@ -865,7 +865,7 @@ struct DTag { /* Display tags */ { 0x96, "Redirection name" }, { 0x9e, "Text" }, }; -#define DTAGSIZE sizeof(dtaglist)/sizeof(struct DTag) +#define DTAGSIZE ARRAY_SIZE(dtaglist) static int disptext_ni1(char *dest, u_char * p) @@ -1074,7 +1074,7 @@ struct InformationElement { }; -#define IESIZE sizeof(ielist)/sizeof(struct InformationElement) +#define IESIZE ARRAY_SIZE(ielist) static struct InformationElement ielist_ni1[] = { @@ -1102,7 +1102,7 @@ struct InformationElement ielist_ni1[] = { }; -#define IESIZE_NI1 sizeof(ielist_ni1)/sizeof(struct InformationElement) +#define IESIZE_NI1 ARRAY_SIZE(ielist_ni1) static struct InformationElement ielist_ni1_cs5[] = { @@ -1110,14 +1110,14 @@ struct InformationElement ielist_ni1_cs5[] = { { 0x2a, "Display text", disptext_ni1 }, }; -#define IESIZE_NI1_CS5 sizeof(ielist_ni1_cs5)/sizeof(struct InformationElement) +#define IESIZE_NI1_CS5 ARRAY_SIZE(ielist_ni1_cs5) static struct InformationElement ielist_ni1_cs6[] = { { 0x7b, "Call appearance", general_ni1 }, }; -#define IESIZE_NI1_CS6 sizeof(ielist_ni1_cs6)/sizeof(struct InformationElement) +#define IESIZE_NI1_CS6 ARRAY_SIZE(ielist_ni1_cs6) static struct InformationElement we_0[] = { @@ -1133,7 +1133,7 @@ static struct InformationElement we_0[] = {WE0_userInfo, "User Info", general} }; -#define WE_0_LEN (sizeof(we_0) / sizeof(struct InformationElement)) +#define WE_0_LEN ARRAY_SIZE(we_0) static struct InformationElement we_6[] = { @@ -1145,7 +1145,7 @@ static struct InformationElement we_6[] = {WE6_statusCalled, "Status Called", general}, {WE6_addTransAttr, "Additional Transmission Attributes", general} }; -#define WE_6_LEN (sizeof(we_6) / sizeof(struct InformationElement)) +#define WE_6_LEN ARRAY_SIZE(we_6) int QuickHex(char *txt, u_char * p, int cnt) diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c index ceb0df9..21567af 100644 --- a/drivers/isdn/hisax/tei.c +++ b/drivers/isdn/hisax/tei.c @@ -447,7 +447,7 @@ static struct FsmNode TeiFnList[] __initdata = {ST_TEI_IDVERIFY, EV_CHKREQ, tei_id_chk_req}, }; -#define TEI_FN_COUNT (sizeof(TeiFnList)/sizeof(struct FsmNode)) +#define TEI_FN_COUNT ARRAY_SIZE(TeiFnList) int __init TeiNew(void) -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] [video] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 2/7] [isdn] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 4/7] [drivers] " Stoyan Gaydarov 2009-07-24 10:51 ` [PATCH 2/7] [isdn] " Karsten Keil 1 sibling, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, moinejf, linux-media 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 <sgayda2@uiuc.edu> --- drivers/media/video/gspca/conex.c | 2 +- drivers/media/video/gspca/etoms.c | 4 ++-- drivers/media/video/gspca/spca501.c | 2 +- drivers/media/video/gspca/spca506.c | 2 +- drivers/media/video/gspca/sunplus.c | 6 +++--- drivers/media/video/gspca/zc3xx.c | 2 +- drivers/media/video/tveeprom.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index 219cfa6..11aa91d 100644 --- a/drivers/media/video/gspca/conex.c +++ b/drivers/media/video/gspca/conex.c @@ -820,7 +820,7 @@ static int sd_config(struct gspca_dev *gspca_dev, cam = &gspca_dev->cam; cam->cam_mode = vga_mode; - cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; + cam->nmodes = ARRAY_SIZE(vga_mode); sd->brightness = BRIGHTNESS_DEF; sd->contrast = CONTRAST_DEF; diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c index 2c20d06..c1461e6 100644 --- a/drivers/media/video/gspca/etoms.c +++ b/drivers/media/video/gspca/etoms.c @@ -635,10 +635,10 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->sensor = id->driver_info; if (sd->sensor == SENSOR_PAS106) { cam->cam_mode = sif_mode; - cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; + cam->nmodes = ARRAY_SIZE(sif_mode); } else { cam->cam_mode = vga_mode; - cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; + cam->nmodes = ARRAY_SIZE(vga_mode); gspca_dev->ctrl_dis = (1 << COLOR_IDX); } sd->brightness = BRIGHTNESS_DEF; diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c index d48b27c..b74a342 100644 --- a/drivers/media/video/gspca/spca501.c +++ b/drivers/media/video/gspca/spca501.c @@ -1923,7 +1923,7 @@ static int sd_config(struct gspca_dev *gspca_dev, cam = &gspca_dev->cam; cam->cam_mode = vga_mode; - cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; + cam->nmodes = ARRAY_SIZE(vga_mode); sd->subtype = id->driver_info; sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value; sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value; diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c index 3a0c893..a199298 100644 --- a/drivers/media/video/gspca/spca506.c +++ b/drivers/media/video/gspca/spca506.c @@ -286,7 +286,7 @@ static int sd_config(struct gspca_dev *gspca_dev, cam = &gspca_dev->cam; cam->cam_mode = vga_mode; - cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; + cam->nmodes = ARRAY_SIZE(vga_mode); sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c index 9623f29..6ddffdc 100644 --- a/drivers/media/video/gspca/sunplus.c +++ b/drivers/media/video/gspca/sunplus.c @@ -840,15 +840,15 @@ static int sd_config(struct gspca_dev *gspca_dev, /* case BRIDGE_SPCA504: */ /* case BRIDGE_SPCA536: */ cam->cam_mode = vga_mode; - cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; + cam->nmodes = ARRAY_SIZE(vga_mode); break; case BRIDGE_SPCA533: cam->cam_mode = custom_mode; - cam->nmodes = sizeof custom_mode / sizeof custom_mode[0]; + cam->nmodes = ARRAY_SIZE(custom_mode); break; case BRIDGE_SPCA504C: cam->cam_mode = vga_mode2; - cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0]; + cam->nmodes = ARRAY_SIZE(vga_mode2); break; } sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index 08422d3..02043ef 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c @@ -7572,7 +7572,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, static const struct sd_desc sd_desc = { .name = MODULE_NAME, .ctrls = sd_ctrls, - .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], + .nctrls = ARRAY_SIZE(sd_ctrls), .config = sd_config, .init = sd_init, .start = sd_start, diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index ac02808..d533ea5 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -646,14 +646,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, tvee->has_radio = 1; } - if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + if (tuner1 < ARRAY_SIZE(hauppauge_tuner)) { tvee->tuner_type = hauppauge_tuner[tuner1].id; t_name1 = hauppauge_tuner[tuner1].name; } else { t_name1 = "unknown"; } - if (tuner2 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + if (tuner2 < ARRAY_SIZE(hauppauge_tuner)) { tvee->tuner2_type = hauppauge_tuner[tuner2].id; t_name2 = hauppauge_tuner[tuner2].name; } else { -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] [drivers] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 3/7] [video] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 5/7] [powerpc] " Stoyan Gaydarov 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, trivial 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 <sgayda2@uiuc.edu> --- drivers/ata/sata_mv.c | 2 +- drivers/infiniband/hw/ipath/ipath_intr.c | 4 +--- drivers/media/dvb/frontends/au8522_decoder.c | 6 ++---- drivers/mtd/lpddr/qinfo_probe.c | 2 +- drivers/mtd/maps/solutionengine.c | 2 +- drivers/net/s6gmac.c | 2 +- drivers/net/wireless/prism54/oid_mgt.c | 5 ++--- drivers/pcmcia/i82365.c | 2 +- drivers/serial/68328serial.c | 6 +++--- drivers/usb/gadget/ci13xxx_udc.c | 2 +- drivers/zorro/names.c | 2 +- 11 files changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 23714ae..a661151 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -2192,7 +2192,7 @@ static unsigned int mv_qc_issue_fis(struct ata_queued_cmd *qc) int err = 0; ata_tf_to_fis(&qc->tf, link->pmp, 1, (void *)fis); - err = mv_send_fis(ap, fis, sizeof(fis) / sizeof(fis[0])); + err = mv_send_fis(ap, fis, ARRAY_SIZE(fis)); if (err) return err; diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c index 6c21b4b..2d41bcf 100644 --- a/drivers/infiniband/hw/ipath/ipath_intr.c +++ b/drivers/infiniband/hw/ipath/ipath_intr.c @@ -207,9 +207,7 @@ void ipath_format_hwerrors(u64 hwerrs, char *msg, size_t msgl) { int i; - const int glen = - sizeof(ipath_generic_hwerror_msgs) / - sizeof(ipath_generic_hwerror_msgs[0]); + const int glen = ARRAY_SIZE(ipath_generic_hwerror_msgs); for (i=0; i<glen; i++) { if (hwerrs & ipath_generic_hwerror_msgs[i].mask) { diff --git a/drivers/media/dvb/frontends/au8522_decoder.c b/drivers/media/dvb/frontends/au8522_decoder.c index 9e9a755..41453bc 100644 --- a/drivers/media/dvb/frontends/au8522_decoder.c +++ b/drivers/media/dvb/frontends/au8522_decoder.c @@ -96,8 +96,7 @@ struct au8522_register_config filter_coef[] = { {AU8522_FILTER_COEF_R42D, {0x01, 0x34, 0x01, 0x01, 0x34, 0x34, 0x34} }, }; -#define NUM_FILTER_COEF (sizeof(filter_coef)\ - / sizeof(struct au8522_register_config)) +#define NUM_FILTER_COEF ARRAY_SIZE(filter_coef) /* Registers 0x060b through 0x0652 are the LP Filter coefficients @@ -179,8 +178,7 @@ struct au8522_register_config lpfilter_coef[] = { {0x0651, {0x40, 0x40} }, {0x0652, {0x01, 0x01} }, }; -#define NUM_LPFILTER_COEF (sizeof(lpfilter_coef)\ - / sizeof(struct au8522_register_config)) +#define NUM_LPFILTER_COEF ARRAY_SIZE(lpfilter_coef) static inline struct au8522_state *to_state(struct v4l2_subdev *sd) { diff --git a/drivers/mtd/lpddr/qinfo_probe.c b/drivers/mtd/lpddr/qinfo_probe.c index 79bf40f..4129bca 100644 --- a/drivers/mtd/lpddr/qinfo_probe.c +++ b/drivers/mtd/lpddr/qinfo_probe.c @@ -57,7 +57,7 @@ static struct qinfo_query_info qinfo_array[] = { static long lpddr_get_qinforec_pos(struct map_info *map, char *id_str) { - int qinfo_lines = sizeof(qinfo_array)/sizeof(struct qinfo_query_info); + int qinfo_lines = ARRAY_SIZE(qinfo_array); int i; int bankwidth = map_bankwidth(map) * 8; int major, minor; diff --git a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c index 0eb41d9..7ad9496 100644 --- a/drivers/mtd/maps/solutionengine.c +++ b/drivers/mtd/maps/solutionengine.c @@ -99,7 +99,7 @@ static int __init init_soleng_maps(void) printk(KERN_NOTICE "Using configured partition at 0x%08x.\n", CONFIG_MTD_SUPERH_RESERVE); parsed_parts = superh_se_partitions; - nr_parts = sizeof(superh_se_partitions)/sizeof(*parsed_parts); + nr_parts = ARRAY_SIZE(superh_se_partitions); } #endif /* CONFIG_MTD_SUPERH_RESERVE */ diff --git a/drivers/net/s6gmac.c b/drivers/net/s6gmac.c index 5345e47..cc541f8 100644 --- a/drivers/net/s6gmac.c +++ b/drivers/net/s6gmac.c @@ -937,7 +937,7 @@ static struct net_device_stats *s6gmac_stats(struct net_device *dev) do { unsigned long flags; spin_lock_irqsave(&pd->lock, flags); - for (i = 0; i < sizeof(pd->stats) / sizeof(unsigned long); i++) + for (i = 0; i < ARRAY_SIZE(pd->stats); i++) pd->stats[i] = pd->carry[i] << (S6_GMAC_STAT_SIZE_MIN - 1); s6gmac_stats_collect(pd, &statinf[0][0]); diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c index 1187e61..6d094ba 100644 --- a/drivers/net/wireless/prism54/oid_mgt.c +++ b/drivers/net/wireless/prism54/oid_mgt.c @@ -692,7 +692,6 @@ mgt_update_addr(islpci_private *priv) return ret; } -#define VEC_SIZE(a) ARRAY_SIZE(a) int mgt_commit(islpci_private *priv) @@ -703,10 +702,10 @@ mgt_commit(islpci_private *priv) if (islpci_get_state(priv) < PRV_STATE_INIT) return 0; - rvalue = mgt_commit_list(priv, commit_part1, VEC_SIZE(commit_part1)); + rvalue = mgt_commit_list(priv, commit_part1, ARRAY_SIZE(commit_part1)); if (priv->iw_mode != IW_MODE_MONITOR) - rvalue |= mgt_commit_list(priv, commit_part2, VEC_SIZE(commit_part2)); + rvalue |= mgt_commit_list(priv, commit_part2, ARRAY_SIZE(commit_part2)); u = OID_INL_MODE; rvalue |= mgt_commit_list(priv, &u, 1); diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 40d4953..892b0a2 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -227,7 +227,7 @@ static pcic_t pcic[] = { { "VIA VT83C469", IS_CIRRUS|IS_VIA }, }; -#define PCIC_COUNT (sizeof(pcic)/sizeof(pcic_t)) +#define PCIC_COUNT ARRAY_SIZE(pcic) /*====================================================================*/ diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c index d935b2d..50af3e8 100644 --- a/drivers/serial/68328serial.c +++ b/drivers/serial/68328serial.c @@ -153,7 +153,7 @@ static int baud_table[] = { 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 0 }; -#define BAUD_TABLE_SIZE (sizeof(baud_table)/sizeof(baud_table[0])) +#define BAUD_TABLE_SIZE ARRAY_SIZE(baud_table) /* Sets or clears DTR/RTS on the requested line */ static inline void m68k_rtsdtr(struct m68k_serial *ss, int set) @@ -1406,10 +1406,10 @@ static void m68328_set_baud(void) USTCNT = ustcnt & ~USTCNT_TXEN; again: - for (i = 0; i < sizeof(baud_table) / sizeof(baud_table[0]); i++) + for (i = 0; i < BAUD_TABLE_SIZE; i++) if (baud_table[i] == m68328_console_baud) break; - if (i >= sizeof(baud_table) / sizeof(baud_table[0])) { + if (i >= BAUD_TABLE_SIZE) { m68328_console_baud = 9600; goto again; } diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index c7cb87a..3374619 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c @@ -1223,7 +1223,7 @@ static ssize_t show_registers(struct device *dev, } spin_lock_irqsave(udc->lock, flags); - k = hw_register_read(dump, sizeof(dump)/sizeof(u32)); + k = hw_register_read(dump, ARRAY_SIZE(dump)); spin_unlock_irqrestore(udc->lock, flags); for (i = 0; i < k; i++) { diff --git a/drivers/zorro/names.c b/drivers/zorro/names.c index e8517c3..09c516b 100644 --- a/drivers/zorro/names.c +++ b/drivers/zorro/names.c @@ -54,7 +54,7 @@ static struct zorro_manuf_info __initdata zorro_manuf_list[] = { #include "devlist.h" }; -#define MANUFS (sizeof(zorro_manuf_list)/sizeof(struct zorro_manuf_info)) +#define MANUFS ARRAY_SIZE(zorro_manuf_list) void __init zorro_name_device(struct zorro_dev *dev) { -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] [powerpc] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 4/7] [drivers] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 6/7] [ia64] " Stoyan Gaydarov 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, benh, paulus, linuxppc-dev 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 <sgayda2@uiuc.edu> --- arch/powerpc/platforms/pasemi/idle.c | 2 +- arch/powerpc/platforms/powermac/feature.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c index 43911d8..75b296b 100644 --- a/arch/powerpc/platforms/pasemi/idle.c +++ b/arch/powerpc/platforms/pasemi/idle.c @@ -90,7 +90,7 @@ machine_late_initcall(pasemi, pasemi_idle_init); static int __init idle_param(char *p) { int i; - for (i = 0; i < sizeof(modes)/sizeof(struct sleep_mode); i++) { + for (i = 0; i < ARRAY_SIZE(modes); i++) { if (!strcmp(modes[i].name, p)) { current_mode = i; break; diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index e6c0040..095de32 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c @@ -2419,13 +2419,13 @@ static int __init probe_motherboard(void) dt = of_find_node_by_name(NULL, "device-tree"); if (dt != NULL) model = of_get_property(dt, "model", NULL); - for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { + for(i=0; model && i<ARRAY_SIZE(pmac_mb_defs); i++) { if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { pmac_mb = pmac_mb_defs[i]; goto found; } } - for(i=0; i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { + for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) { if (machine_is_compatible(pmac_mb_defs[i].model_string)) { pmac_mb = pmac_mb_defs[i]; goto found; -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] [ia64] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 5/7] [powerpc] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 7/7] [cris] " Stoyan Gaydarov 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, tony.luck, fenghua.yu, linux-ia64 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 <sgayda2@uiuc.edu> --- arch/ia64/kernel/perfmon.c | 2 +- arch/ia64/xen/xen_pv_ops.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index f178270..15e8fbb 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -4693,7 +4693,7 @@ static pfm_cmd_desc_t pfm_cmd_tab[]={ /* 32 */PFM_CMD(pfm_write_ibrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL), /* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, pfarg_dbreg_t, NULL) }; -#define PFM_CMD_COUNT (sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t)) +#define PFM_CMD_COUNT ARRAY_SIZE(pfm_cmd_tab) static int pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags) diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c index 5e2270a..3ce0fdb 100644 --- a/arch/ia64/xen/xen_pv_ops.c +++ b/arch/ia64/xen/xen_pv_ops.c @@ -1102,8 +1102,7 @@ __initdata_or_module = static unsigned long __init_or_module xen_patch_bundle(void *sbundle, void *ebundle, unsigned long type) { - const unsigned long nelems = sizeof(xen_patch_bundle_elems) / - sizeof(xen_patch_bundle_elems[0]); + const unsigned long nelems = ARRAY_SIZE(xen_patch_bundle_elems); unsigned long used; const struct paravirt_patch_bundle_elem *found; -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] [cris] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 6/7] [ia64] " Stoyan Gaydarov @ 2009-07-22 3:02 ` Stoyan Gaydarov 2009-09-01 15:51 ` Jesper Nilsson 0 siblings, 1 reply; 10+ messages in thread From: Stoyan Gaydarov @ 2009-07-22 3:02 UTC (permalink / raw) To: linux-kernel; +Cc: Stoyan Gaydarov, starvik, jesper.nilsson, linux-cris-kernel 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 <sgayda2@uiuc.edu> --- arch/cris/arch-v32/mach-a3/io.c | 2 +- arch/cris/arch-v32/mach-fs/io.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/cris/arch-v32/mach-a3/io.c b/arch/cris/arch-v32/mach-a3/io.c index c22f67e..090ceb9 100644 --- a/arch/cris/arch-v32/mach-a3/io.c +++ b/arch/cris/arch-v32/mach-a3/io.c @@ -36,7 +36,7 @@ struct crisv32_ioport crisv32_ioports[] = { }, }; -#define NBR_OF_PORTS sizeof(crisv32_ioports)/sizeof(struct crisv32_ioport) +#define NBR_OF_PORTS ARRAY_SIZE(crisv32_ioports) struct crisv32_iopin crisv32_led_net0_green; struct crisv32_iopin crisv32_led_net0_red; diff --git a/arch/cris/arch-v32/mach-fs/io.c b/arch/cris/arch-v32/mach-fs/io.c index cb6327b..a695866 100644 --- a/arch/cris/arch-v32/mach-fs/io.c +++ b/arch/cris/arch-v32/mach-fs/io.c @@ -52,7 +52,7 @@ struct crisv32_ioport crisv32_ioports[] = { } }; -#define NBR_OF_PORTS sizeof(crisv32_ioports)/sizeof(struct crisv32_ioport) +#define NBR_OF_PORTS ARRAY_SIZE(crisv32_ioports) struct crisv32_iopin crisv32_led_net0_green; struct crisv32_iopin crisv32_led_net0_red; -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 7/7] [cris] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 7/7] [cris] " Stoyan Gaydarov @ 2009-09-01 15:51 ` Jesper Nilsson 0 siblings, 0 replies; 10+ messages in thread From: Jesper Nilsson @ 2009-09-01 15:51 UTC (permalink / raw) To: Stoyan Gaydarov Cc: linux-kernel@vger.kernel.org, Mikael Starvik, linux-cris-kernel On Wed, Jul 22, 2009 at 05:02:33AM +0200, Stoyan Gaydarov wrote: > These changes were a direct result of using a semantic patch > More information can be found at http://www.emn.fr/x-info/coccinelle/ Thanks, added to the cris-tree. > Signed-off-by: Stoyan Gaydarov <sgayda2@uiuc.edu> > --- > arch/cris/arch-v32/mach-a3/io.c | 2 +- > arch/cris/arch-v32/mach-fs/io.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/cris/arch-v32/mach-a3/io.c b/arch/cris/arch-v32/mach-a3/io.c > index c22f67e..090ceb9 100644 > --- a/arch/cris/arch-v32/mach-a3/io.c > +++ b/arch/cris/arch-v32/mach-a3/io.c > @@ -36,7 +36,7 @@ struct crisv32_ioport crisv32_ioports[] = { > }, > }; > > -#define NBR_OF_PORTS sizeof(crisv32_ioports)/sizeof(struct crisv32_ioport) > +#define NBR_OF_PORTS ARRAY_SIZE(crisv32_ioports) > > struct crisv32_iopin crisv32_led_net0_green; > struct crisv32_iopin crisv32_led_net0_red; > diff --git a/arch/cris/arch-v32/mach-fs/io.c b/arch/cris/arch-v32/mach-fs/io.c > index cb6327b..a695866 100644 > --- a/arch/cris/arch-v32/mach-fs/io.c > +++ b/arch/cris/arch-v32/mach-fs/io.c > @@ -52,7 +52,7 @@ struct crisv32_ioport crisv32_ioports[] = { > } > }; > > -#define NBR_OF_PORTS sizeof(crisv32_ioports)/sizeof(struct crisv32_ioport) > +#define NBR_OF_PORTS ARRAY_SIZE(crisv32_ioports) > > struct crisv32_iopin crisv32_led_net0_green; > struct crisv32_iopin crisv32_led_net0_red; > -- > 1.6.3.3 /^JN - Jesper Nilsson -- Jesper Nilsson -- jesper.nilsson@axis.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/7] [isdn] ARRAY_SIZE changes 2009-07-22 3:02 ` [PATCH 2/7] [isdn] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 3/7] [video] " Stoyan Gaydarov @ 2009-07-24 10:51 ` Karsten Keil 1 sibling, 0 replies; 10+ messages in thread From: Karsten Keil @ 2009-07-24 10:51 UTC (permalink / raw) To: Stoyan Gaydarov; +Cc: linux-kernel Hi Stoyan, On Mittwoch, 22. Juli 2009 05:02:28 Stoyan Gaydarov wrote: > 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 <sgayda2@uiuc.edu> Yes you are right, these defines should be rewritten to use ARRAY_SIZE(), but in most cases the define is only used once, so it would be better to replace it completely, I will prepare a new patch for this stuff in drivers/isdn . > --- > drivers/isdn/act2000/capi.c | 2 +- > drivers/isdn/act2000/module.c | 2 +- > drivers/isdn/hardware/eicon/message.c | 2 +- > drivers/isdn/hardware/eicon/os_4bri.c | 3 +-- > drivers/isdn/hisax/callc.c | 2 +- > drivers/isdn/hisax/isdnl1.c | 6 +++--- > drivers/isdn/hisax/isdnl2.c | 2 +- > drivers/isdn/hisax/isdnl3.c | 2 +- > drivers/isdn/hisax/l3_1tr6.c | 9 +++------ > drivers/isdn/hisax/l3dss1.c | 12 ++++-------- > drivers/isdn/hisax/l3ni1.c | 12 ++++-------- > drivers/isdn/hisax/q931.c | 24 ++++++++++++------------ > drivers/isdn/hisax/tei.c | 2 +- > 13 files changed, 34 insertions(+), 46 deletions(-) > > diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c > index 946c38c..a3428da 100644 > --- a/drivers/isdn/act2000/capi.c > +++ b/drivers/isdn/act2000/capi.c > @@ -78,7 +78,7 @@ static actcapi_msgdsc valid_msg[] = { > #endif > {{ 0x00, 0x00}, NULL}, > }; > -#define num_valid_msg (sizeof(valid_msg)/sizeof(actcapi_msgdsc)) > +#define num_valid_msg ARRAY_SIZE(valid_msg) > #define num_valid_imsg 27 /* MANUFACTURER_IND */ > > /* > diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c > index 8325022..6387baa 100644 > --- a/drivers/isdn/act2000/module.c > +++ b/drivers/isdn/act2000/module.c > @@ -23,7 +23,7 @@ static unsigned short act2000_isa_ports[] = > 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380, > 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60, > }; > -#define ISA_NRPORTS (sizeof(act2000_isa_ports)/sizeof(unsigned short)) > +#define ISA_NRPORTS ARRAY_SIZE(act2000_isa_ports) > > static act2000_card *cards = (act2000_card *) NULL; > > diff --git a/drivers/isdn/hardware/eicon/message.c > b/drivers/isdn/hardware/eicon/message.c index 31f91c1..9253209 100644 > --- a/drivers/isdn/hardware/eicon/message.c > +++ b/drivers/isdn/hardware/eicon/message.c > @@ -552,7 +552,7 @@ word api_put(APPL * appl, CAPI_MSG * msg) > > for(j=0;j<MAX_MSG_PARMS+1;j++) msg_parms[j].length = 0; > for(i=0, ret = _BAD_MSG; > - i<(sizeof(ftable)/sizeof(struct _ftable)); > + i<ARRAY_SIZE(ftable); > i++) { > > if(ftable[i].command==msg->header.command) { > diff --git a/drivers/isdn/hardware/eicon/os_4bri.c > b/drivers/isdn/hardware/eicon/os_4bri.c index c964b8d..cb7616c 100644 > --- a/drivers/isdn/hardware/eicon/os_4bri.c > +++ b/drivers/isdn/hardware/eicon/os_4bri.c > @@ -149,8 +149,7 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) > diva_os_xdi_adapter_t *diva_current; > diva_os_xdi_adapter_t *adapter_list[4]; > PISDN_ADAPTER Slave; > - unsigned long bar_length[sizeof(_4bri_bar_length) / > - sizeof(_4bri_bar_length[0])]; > + unsigned long bar_length[ARRAY_SIZE(_4bri_bar_length)]; > int v2 = _4bri_is_rev_2_card(a->CardOrdinal); > int tasks = _4bri_is_rev_2_bri_card(a->CardOrdinal) ? 1 : > MQ_INSTANCE_COUNT; int factor = (tasks == 1) ? 1 : 2; > diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c > index 025a20d..f90d6a6 100644 > --- a/drivers/isdn/hisax/callc.c > +++ b/drivers/isdn/hisax/callc.c > @@ -833,7 +833,7 @@ static struct FsmNode fnlist[] __initdata = > }; > /* *INDENT-ON* */ > > -#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode)) > +#define FNCOUNT ARRAY_SIZE(fnlist) > > int __init > CallcNew(void) > diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c > index 317f16f..980e099 100644 > --- a/drivers/isdn/hisax/isdnl1.c > +++ b/drivers/isdn/hisax/isdnl1.c > @@ -647,7 +647,7 @@ static struct FsmNode L1SFnList[] __initdata = > {ST_L1_F8, EV_TIMER_DEACT, l1_timer_deact}, > }; > > -#define L1S_FN_COUNT (sizeof(L1SFnList)/sizeof(struct FsmNode)) > +#define L1S_FN_COUNT ARRAY_SIZE(L1SFnList) > > #ifdef HISAX_UINTERFACE > static void > @@ -706,7 +706,7 @@ static struct FsmNode L1UFnList[] __initdata = > {ST_L1_RESET, EV_TIMER_DEACT, l1_timer_deact}, > }; > > -#define L1U_FN_COUNT (sizeof(L1UFnList)/sizeof(struct FsmNode)) > +#define L1U_FN_COUNT ARRAY_SIZE(L1UFnList) > > #endif > > @@ -754,7 +754,7 @@ static struct FsmNode L1BFnList[] __initdata = > {ST_L1_WAIT_DEACT, EV_TIMER_DEACT, l1b_timer_deact}, > }; > > -#define L1B_FN_COUNT (sizeof(L1BFnList)/sizeof(struct FsmNode)) > +#define L1B_FN_COUNT ARRAY_SIZE(L1BFnList) > > int __init > Isdnl1New(void) > diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c > index 3446f24..846a7e6 100644 > --- a/drivers/isdn/hisax/isdnl2.c > +++ b/drivers/isdn/hisax/isdnl2.c > @@ -1623,7 +1623,7 @@ static struct FsmNode L2FnList[] __initdata = > {ST_L2_8, EV_L1_DEACTIVATE, l2_persistent_da}, > }; > > -#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode)) > +#define L2_FN_COUNT ARRAY_SIZE(L2FnList) > > static void > isdnl2_l1l2(struct PStack *st, int pr, void *arg) > diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c > index 935f233..c081fed 100644 > --- a/drivers/isdn/hisax/isdnl3.c > +++ b/drivers/isdn/hisax/isdnl3.c > @@ -543,7 +543,7 @@ static struct FsmNode L3FnList[] __initdata = > }; > /* *INDENT-ON* */ > > -#define L3_FN_COUNT (sizeof(L3FnList)/sizeof(struct FsmNode)) > +#define L3_FN_COUNT ARRAY_SIZE(L3FnList) > > void > l3_msg(struct PStack *st, int pr, void *arg) > diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c > index c5c36ee..ff62679 100644 > --- a/drivers/isdn/hisax/l3_1tr6.c > +++ b/drivers/isdn/hisax/l3_1tr6.c > @@ -698,8 +698,7 @@ static struct stateentry downstl[] = > CC_T308_2, l3_1tr6_t308_2}, > }; > > -#define DOWNSTL_LEN \ > - (sizeof(downstl) / sizeof(struct stateentry)) > +#define DOWNSTL_LEN ARRAY_SIZE(downstl) > > static struct stateentry datastln1[] = > { > @@ -735,8 +734,7 @@ static struct stateentry datastln1[] = > MT_N1_REL_ACK, l3_1tr6_rel_ack} > }; > > -#define DATASTLN1_LEN \ > - (sizeof(datastln1) / sizeof(struct stateentry)) > +#define DATASTLN1_LEN ARRAY_SIZE(datastln1) > > static struct stateentry manstatelist[] = > { > @@ -746,8 +744,7 @@ static struct stateentry manstatelist[] = > DL_RELEASE | INDICATION, l3_1tr6_dl_release}, > }; > > -#define MANSLLEN \ > - (sizeof(manstatelist) / sizeof(struct stateentry)) > +#define MANSLLEN ARRAY_SIZE(manstatelist) > /* *INDENT-ON* */ > > static void > diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c > index 99feae8..c434fa5 100644 > --- a/drivers/isdn/hisax/l3dss1.c > +++ b/drivers/isdn/hisax/l3dss1.c > @@ -2820,8 +2820,7 @@ static struct stateentry downstatelist[] = > CC_T309, l3dss1_dl_release}, > }; > > -#define DOWNSLLEN \ > - (sizeof(downstatelist) / sizeof(struct stateentry)) > +#define DOWNSLLEN ARRAY_SIZE(downstatelist) > > static struct stateentry datastatelist[] = > { > @@ -2875,8 +2874,7 @@ static struct stateentry datastatelist[] = > MT_RESUME_REJECT, l3dss1_resume_rej}, > }; > > -#define DATASLLEN \ > - (sizeof(datastatelist) / sizeof(struct stateentry)) > +#define DATASLLEN ARRAY_SIZE(datastatelist) > > static struct stateentry globalmes_list[] = > { > @@ -2888,8 +2886,7 @@ static struct stateentry globalmes_list[] = > MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack}, > */ > }; > -#define GLOBALM_LEN \ > - (sizeof(globalmes_list) / sizeof(struct stateentry)) > +#define GLOBALM_LEN ARRAY_SIZE(globalmes_list) > > static struct stateentry manstatelist[] = > { > @@ -2903,8 +2900,7 @@ static struct stateentry manstatelist[] = > DL_RELEASE | INDICATION, l3dss1_dl_release}, > }; > > -#define MANSLLEN \ > - (sizeof(manstatelist) / sizeof(struct stateentry)) > +#define MANSLLEN ARRAY_SIZE(manstatelist) > /* *INDENT-ON* */ > > > diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c > index f7041d5..ba05ae3 100644 > --- a/drivers/isdn/hisax/l3ni1.c > +++ b/drivers/isdn/hisax/l3ni1.c > @@ -2755,8 +2755,7 @@ static struct stateentry downstatelist[] = > CC_TSPID, l3ni1_spid_tout }, > }; > > -#define DOWNSLLEN \ > - (sizeof(downstatelist) / sizeof(struct stateentry)) > +#define DOWNSLLEN ARRAY_SIZE(downstatelist) > > static struct stateentry datastatelist[] = > { > @@ -2810,8 +2809,7 @@ static struct stateentry datastatelist[] = > MT_RESUME_REJECT, l3ni1_resume_rej}, > }; > > -#define DATASLLEN \ > - (sizeof(datastatelist) / sizeof(struct stateentry)) > +#define DATASLLEN ARRAY_SIZE(datastatelist) > > static struct stateentry globalmes_list[] = > { > @@ -2825,8 +2823,7 @@ static struct stateentry globalmes_list[] = > { SBIT( 0 ), MT_DL_ESTABLISHED, l3ni1_spid_send }, > { SBIT( 20 ) | SBIT( 21 ) | SBIT( 22 ), MT_INFORMATION, l3ni1_spid_epid > }, }; > -#define GLOBALM_LEN \ > - (sizeof(globalmes_list) / sizeof(struct stateentry)) > +#define GLOBALM_LEN ARRAY_SIZE(globalmes_list) > > static struct stateentry manstatelist[] = > { > @@ -2840,8 +2837,7 @@ static struct stateentry manstatelist[] = > DL_RELEASE | INDICATION, l3ni1_dl_release}, > }; > > -#define MANSLLEN \ > - (sizeof(manstatelist) / sizeof(struct stateentry)) > +#define MANSLLEN ARRAY_SIZE(manstatelist) > /* *INDENT-ON* */ > > > diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c > index aacbf0d..8b853d5 100644 > --- a/drivers/isdn/hisax/q931.c > +++ b/drivers/isdn/hisax/q931.c > @@ -140,7 +140,7 @@ struct MessageType { > } > }; > > -#define MTSIZE sizeof(mtlist)/sizeof(struct MessageType) > +#define MTSIZE ARRAY_SIZE(mtlist) > > static > struct MessageType mt_n0[] = > @@ -157,7 +157,7 @@ struct MessageType mt_n0[] = > {MT_N0_CLO_ACK, "CLOse ACKnowledge"} > }; > > -#define MT_N0_LEN (sizeof(mt_n0) / sizeof(struct MessageType)) > +#define MT_N0_LEN ARRAY_SIZE(mt_n0) > > static > struct MessageType mt_n1[] = > @@ -194,7 +194,7 @@ struct MessageType mt_n1[] = > {MT_N1_STAT, "STATus"} > }; > > -#define MT_N1_LEN (sizeof(mt_n1) / sizeof(struct MessageType)) > +#define MT_N1_LEN ARRAY_SIZE(mt_n1) > > > static int > @@ -438,7 +438,7 @@ struct CauseValue { > }, > }; > > -#define CVSIZE sizeof(cvlist)/sizeof(struct CauseValue) > +#define CVSIZE ARRAY_SIZE(cvlist) > > static > int > @@ -516,7 +516,7 @@ struct MessageType cause_1tr6[] = > {CAUSE_UserInfoDiscarded, "User Info Discarded"} > }; > > -static int cause_1tr6_len = (sizeof(cause_1tr6) / sizeof(struct > MessageType)); +static int cause_1tr6_len = ARRAY_SIZE(cause_1tr6); > > static int > prcause_1tr6(char *dest, u_char * p) > @@ -865,7 +865,7 @@ struct DTag { /* Display tags */ > { 0x96, "Redirection name" }, > { 0x9e, "Text" }, > }; > -#define DTAGSIZE sizeof(dtaglist)/sizeof(struct DTag) > +#define DTAGSIZE ARRAY_SIZE(dtaglist) > > static int > disptext_ni1(char *dest, u_char * p) > @@ -1074,7 +1074,7 @@ struct InformationElement { > }; > > > -#define IESIZE sizeof(ielist)/sizeof(struct InformationElement) > +#define IESIZE ARRAY_SIZE(ielist) > > static > struct InformationElement ielist_ni1[] = { > @@ -1102,7 +1102,7 @@ struct InformationElement ielist_ni1[] = { > }; > > > -#define IESIZE_NI1 sizeof(ielist_ni1)/sizeof(struct InformationElement) > +#define IESIZE_NI1 ARRAY_SIZE(ielist_ni1) > > static > struct InformationElement ielist_ni1_cs5[] = { > @@ -1110,14 +1110,14 @@ struct InformationElement ielist_ni1_cs5[] = { > { 0x2a, "Display text", disptext_ni1 }, > }; > > -#define IESIZE_NI1_CS5 sizeof(ielist_ni1_cs5)/sizeof(struct > InformationElement) +#define IESIZE_NI1_CS5 ARRAY_SIZE(ielist_ni1_cs5) > > static > struct InformationElement ielist_ni1_cs6[] = { > { 0x7b, "Call appearance", general_ni1 }, > }; > > -#define IESIZE_NI1_CS6 sizeof(ielist_ni1_cs6)/sizeof(struct > InformationElement) +#define IESIZE_NI1_CS6 ARRAY_SIZE(ielist_ni1_cs6) > > static struct InformationElement we_0[] = > { > @@ -1133,7 +1133,7 @@ static struct InformationElement we_0[] = > {WE0_userInfo, "User Info", general} > }; > > -#define WE_0_LEN (sizeof(we_0) / sizeof(struct InformationElement)) > +#define WE_0_LEN ARRAY_SIZE(we_0) > > static struct InformationElement we_6[] = > { > @@ -1145,7 +1145,7 @@ static struct InformationElement we_6[] = > {WE6_statusCalled, "Status Called", general}, > {WE6_addTransAttr, "Additional Transmission Attributes", general} > }; > -#define WE_6_LEN (sizeof(we_6) / sizeof(struct InformationElement)) > +#define WE_6_LEN ARRAY_SIZE(we_6) > > int > QuickHex(char *txt, u_char * p, int cnt) > diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c > index ceb0df9..21567af 100644 > --- a/drivers/isdn/hisax/tei.c > +++ b/drivers/isdn/hisax/tei.c > @@ -447,7 +447,7 @@ static struct FsmNode TeiFnList[] __initdata = > {ST_TEI_IDVERIFY, EV_CHKREQ, tei_id_chk_req}, > }; > > -#define TEI_FN_COUNT (sizeof(TeiFnList)/sizeof(struct FsmNode)) > +#define TEI_FN_COUNT ARRAY_SIZE(TeiFnList) > > int __init > TeiNew(void) ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-09-01 15:51 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-07-22 3:02 [PATCH 0/7] ARRAY_SIZE changes Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 1/7] [staging] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 2/7] [isdn] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 3/7] [video] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 4/7] [drivers] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 5/7] [powerpc] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 6/7] [ia64] " Stoyan Gaydarov 2009-07-22 3:02 ` [PATCH 7/7] [cris] " Stoyan Gaydarov 2009-09-01 15:51 ` Jesper Nilsson 2009-07-24 10:51 ` [PATCH 2/7] [isdn] " Karsten Keil
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox