Re: lots of code could be simplified by using ARRAY_SIZE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  so here's the end result of my experiment to replace unnecessary
code snippets with an invocation of the ARRAY_SIZE() macro from
include/linux/kernel.h.  i've attached the script that i ran on the
entire tree, then (after adding al viro's connector patch), did:

  $ make allyesconfig	# for the stress factor
  $ make

to see what would happen.

  amazingly, the compile worked all the way down to:

  AS      arch/i386/boot/bootsect.o
  LD      arch/i386/boot/bootsect
  AS      arch/i386/boot/setup.o
  LD      arch/i386/boot/setup
  AS      arch/i386/boot/compressed/head.o
  CC      arch/i386/boot/compressed/misc.o
  OBJCOPY arch/i386/boot/compressed/vmlinux.bin
  HOSTCC  arch/i386/boot/compressed/relocs
arch/i386/boot/compressed/relocs.c: In function 'sym_type':
arch/i386/boot/compressed/relocs.c:72: warning: implicit declaration of function 'ARRAY_SIZE'
/tmp/ccRTpFxM.o: In function `main':
relocs.c:(.text+0xb13): undefined reference to `ARRAY_SIZE'
relocs.c:(.text+0xddb): undefined reference to `ARRAY_SIZE'
relocs.c:(.text+0xe10): undefined reference to `ARRAY_SIZE'
relocs.c:(.text+0xe2b): undefined reference to `ARRAY_SIZE'
collect2: ld returned 1 exit status
make[2]: *** [arch/i386/boot/compressed/relocs] Error 1
make[1]: *** [arch/i386/boot/compressed/vmlinux] Error 2
make: *** [bzImage] Error 2

  not surprisingly, the diff is fairly sizable (2408 lines), and
that's *way* outside of my comfort zone in terms of what i would
submit as a patch.  others higher up the food chain can decide if they
want to do anything with this.  (for the information value, i also
attached the "diffstat" output.)

  at this point, i think it's someone else's call.

rday

p.s.  clearly, this didn't even hit all of the possible
transformations, such as the ones based on typedefs, or even the ones
that are broken over two lines.  you can see from the script that i
just went after the low-hanging fruit.

p.p.s.  i didn't bother fixing relocs.c yet to see if the build would
actually finish.  i thought i'd better stop here and wait to hear what
others think.

Attachment: arraysize.sh
Description: Bourne shell script

 Documentation/hpet.txt                            |    2 
 arch/arm/kernel/dma-isa.c                         |    2 
 arch/arm/kernel/ecard.c                           |    2 
 arch/arm26/kernel/ecard.c                         |    2 
 arch/avr32/kernel/setup.c                         |    2 
 arch/cris/arch-v10/drivers/axisflashmap.c         |    2 
 arch/cris/arch-v10/kernel/setup.c                 |    4 -
 arch/cris/mm/tlb.c                                |    2 
 arch/i386/boot/compressed/relocs.c                |    8 +--
 arch/m68k/amiga/amisound.c                        |    2 
 arch/m68k/kernel/ptrace.c                         |    4 -
 arch/m68k/kernel/traps.c                          |    2 
 arch/m68knommu/kernel/ptrace.c                    |    4 -
 arch/m68knommu/kernel/traps.c                     |    2 
 arch/mips/arc/identify.c                          |    2 
 arch/mips/jmr3927/rbhma3100/setup.c               |    2 
 arch/mips/mips-boards/atlas/atlas_int.c           |    4 -
 arch/mips/pci/fixup-vr4133.c                      |    2 
 arch/powerpc/lib/rheap.c                          |    2 
 arch/powerpc/xmon/ppc-opc.c                       |    4 -
 arch/powerpc/xmon/spu-opc.c                       |    2 
 arch/ppc/lib/rheap.c                              |    2 
 arch/ppc/syslib/m8xx_setup.c                      |    2 
 arch/ppc/xmon/ppc-opc.c                           |    4 -
 arch/um/kernel/tt/ptproxy/ptrace.c                |   12 ++--
 arch/v850/kernel/anna.c                           |    2 
 arch/v850/kernel/as85ep1.c                        |    2 
 arch/v850/kernel/fpga85e2c.c                      |    2 
 arch/v850/kernel/gbus_int.c                       |    4 -
 arch/v850/kernel/ma.c                             |    2 
 arch/v850/kernel/me2.c                            |    2 
 arch/v850/kernel/rte_cb.c                         |    2 
 arch/v850/kernel/rte_mb_a_pci.c                   |    2 
 arch/v850/kernel/rte_me2_cb.c                     |    2 
 arch/v850/kernel/teg.c                            |    2 
 arch/x86_64/kernel/smpboot.c                      |    2 
 drivers/acorn/block/fd1772.c                      |    2 
 drivers/acpi/toshiba_acpi.c                       |    2 
 drivers/atm/he.c                                  |    2 
 drivers/atm/idt77252.c                            |    8 +--
 drivers/block/acsi.c                              |    4 -
 drivers/block/acsi_slm.c                          |    4 -
 drivers/char/drm/drm_proc.c                       |    2 
 drivers/char/synclink_gt.c                        |    2 
 drivers/connector/connector.c                     |    3 -
 drivers/ide/ide-cd.h                              |    2 
 drivers/infiniband/core/device.c                  |    2 
 drivers/isdn/capi/capi.c                          |    4 -
 drivers/isdn/capi/capidrv.c                       |    4 -
 drivers/isdn/hardware/eicon/debug.c               |   30 ++++++------
 drivers/isdn/hardware/eicon/message.c             |   22 ++++----
 drivers/kvm/kvm_svm.h                             |    2 
 drivers/kvm/svm.c                                 |    4 -
 drivers/kvm/vmx.c                                 |    4 -
 drivers/macintosh/apm_emu.c                       |    2 
 drivers/md/md.c                                   |    4 -
 drivers/media/dvb/bt8xx/dvb-bt8xx.c               |    2 
 drivers/media/dvb/frontends/cx24110.c             |    4 -
 drivers/media/dvb/frontends/cx24123.c             |    6 +-
 drivers/media/video/cpia2/cpia2_v4l.c             |    8 +--
 drivers/media/video/ov7670.c                      |    6 +-
 drivers/media/video/pvrusb2/pvrusb2-audio.c       |    4 -
 drivers/media/video/pvrusb2/pvrusb2-ctrl.c        |    2 
 drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c |    4 -
 drivers/media/video/pvrusb2/pvrusb2-debugifc.c    |    4 -
 drivers/media/video/pvrusb2/pvrusb2-eeprom.c      |    2 
 drivers/media/video/pvrusb2/pvrusb2-encoder.c     |   16 +++---
 drivers/media/video/pvrusb2/pvrusb2-hdw.c         |   16 +++---
 drivers/media/video/pvrusb2/pvrusb2-i2c-core.c    |    2 
 drivers/media/video/pvrusb2/pvrusb2-std.c         |   14 ++---
 drivers/media/video/pvrusb2/pvrusb2-sysfs.c       |    2 
 drivers/media/video/pvrusb2/pvrusb2-video-v4l.c   |    4 -
 drivers/media/video/pvrusb2/pvrusb2-wm8775.c      |    4 -
 drivers/media/video/tveeprom.c                    |    6 +-
 drivers/media/video/tvp5150.c                     |    2 
 drivers/media/video/usbvideo/quickcam_messenger.c |    2 
 drivers/message/fusion/mptbase.c                  |    2 
 drivers/mmc/au1xmmc.c                             |    2 
 drivers/net/apne.c                                |    2 
 drivers/net/arm/am79c961a.c                       |    2 
 drivers/net/atarilance.c                          |    2 
 drivers/net/cs89x0.c                              |    6 +-
 drivers/net/e1000/e1000_ethtool.c                 |    2 
 drivers/net/fec_8xx/fec_mii.c                     |    4 -
 drivers/net/ibm_emac/ibm_emac_debug.c             |    8 +--
 drivers/net/irda/actisys-sir.c                    |    2 
 drivers/net/ixgb/ixgb_param.c                     |    2 
 drivers/net/ne-h8300.c                            |    2 
 drivers/net/ne.c                                  |    2 
 drivers/net/ne2.c                                 |    2 
 drivers/net/ne2k-pci.c                            |    2 
 drivers/net/netxen/netxen_nic_hw.c                |    2 
 drivers/net/pcmcia/axnet_cs.c                     |    2 
 drivers/net/pcmcia/pcnet_cs.c                     |    2 
 drivers/net/sk98lin/skgemib.c                     |    2 
 drivers/net/sk98lin/skgesirq.c                    |    2 
 drivers/net/skfp/smt.c                            |    2 
 drivers/net/skfp/srf.c                            |    4 -
 drivers/net/wireless/airo.c                       |    4 -
 drivers/net/wireless/hostap/hostap.h              |    2 
 drivers/net/wireless/ipw2100.c                    |   12 ++--
 drivers/net/wireless/prism54/oid_mgt.c            |    2 
 drivers/net/wireless/wavelan.p.h                  |    2 
 drivers/net/zorro8390.c                           |    2 
 drivers/s390/cio/device_id.c                      |    2 
 drivers/serial/68328serial.c                      |    6 +-
 drivers/serial/mcfserial.c                        |    2 
 drivers/w1/slaves/w1_therm.c                      |    6 +-
 fs/reiserfs/do_balan.c                            |    4 -
 include/asm-parisc/mmzone.h                       |    2 
 include/linux/netfilter/xt_sctp.h                 |    2 
 include/net/ip_vs.h                               |    2 
 include/video/sgivw.h                             |    2 
 kernel/rcutorture.c                               |    2 
 net/atm/proc.c                                    |    2 
 sound/oss/au1550_ac97.c                           |    4 -
 sound/oss/es1371.c                                |    2 
 sound/oss/nec_vrc5477.c                           |    4 -
 sound/oss/swarm_cs4297a.c                         |    2 
 119 files changed, 223 insertions(+), 224 deletions(-)

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux