Broken inlines all over the source tree
GCC can only inline functions when the function definition comes before its use.
Unfortunately a lot of code hasn't been written with this in mind.
Here is a list of files containing forward declarations for inline functions (that are either broken or redundant).
The list was made with grep -E '(inline|inline__)[ '$'\t''][^{]*;' so it's not very accurate.
gcc -Winline would provide better results.
How about adding it to the build CFLAGS?
Here is the list (excluding mm/rmap.c that I already fixed).
./drivers/hotplug/ibmphp_res.c./drivers/net/hamradio/dmascc.c./drivers/net/tulip/dmfe.c./drivers/net/au1000_eth.c./drivers/net/wan/lmc/lmc_debug.h./drivers/net/wan/lmc/lmc_media.c./drivers/net/wan/dscc4.c./drivers/net/e1000/e1000_main.c./drivers/net/sb1000.c./drivers/net/ioc3-eth.c./drivers/net/seeq8005.c./drivers/net/mace.c./drivers/net/eql.c./drivers/net/bonding.c./drivers/net/via-rhine.c./drivers/net/hamachi.c./drivers/net/smc9194.c./drivers/isdn/hisax/isar.c./drivers/isdn/hisax/ipacx.c./drivers/isdn/sc/command.c./drivers/video/riva/fbdev.c./drivers/video/fbcon.c./drivers/video/cyberfb.h./drivers/video/virgefb.c./drivers/video/platinumfb.c./drivers/video/valkyriefb.c./drivers/media/video/w9966.c./drivers/media/video/planb.c./drivers/media/radio/radio-maestro.c./drivers/char/ftape/zftape/zftape-vtbl.h./drivers/char/istallion.c./drivers/char/stallion.c./drivers/char/dz.h./drivers/char/ser_a2232.c./drivers/char/qtronix.c./drivers/char/rtc.c./drivers/char/epca.c./drivers/char/pcxx.c./drivers/char/mxser.c./drivers/char/ip2main.c./drivers/acorn/block/fd1772.c./drivers/scsi/aic7xxx/aic7xxx_osm.h./drivers/scsi/aic7xxx/aic7xxx_linux.c./drivers/scsi/aic7xxx/aic7xxx_inline.h./drivers/scsi/ips.c./drivers/scsi/sun3_scsi.c./drivers/scsi/sim710.c./drivers/scsi/advansys.c./drivers/scsi/fastlane.c./drivers/scsi/sg.c./drivers/scsi/AM53C974.c./drivers/scsi/mac_esp.c./drivers/scsi/tmscsim.c./drivers/scsi/ultrastor.c./drivers/scsi/megaraid.h./drivers/scsi/qla1280.c./drivers/s390/char/tape.c./drivers/s390/char/tape.h./drivers/mtd/devices/doc1000.c./drivers/usb/media/se401.h./drivers/usb/serial/whiteheat.c./drivers/usb/net/rtl8150.c./drivers/usb/host/hc_simple.h./drivers/block/cpqarray.c./drivers/block/ataflop.c./drivers/block/xd.h./drivers/block/cciss.c./drivers/sgi/char/ds1286.c./drivers/cdrom/sonycd535.c./arch/mips/au1000/common/irq.c./arch/ia64/sn/io/l1.c./include/net/irda/timer.h./include/net/ip.h./include/linux/fsfilter.h./include/linux/elevator.h./include/linux/sched.h./include/linux/coda_linux.h./include/linux/blkdev.h./include/linux/intermezzo_fs.h./include/linux/bio.h./include/linux/reiserfs_fs.h./include/asm-ppc64/tlb.h./include/asm-ia64/unistd.h./include/asm-x86_64/apic.h./include/asm-s390x/processor.h./include/asm-arm/thread_info.h./include/asm-arm/current.h./include/asm-arm/unistd.h./include/asm-i386/apic.h./net/core/sock.c./net/irda/wrapper.c./net/bluetooth/sco.c./net/bluetooth/l2cap.c./net/atm/lec.c./net/wanrouter/af_wanpipe.c./net/appletalk/ddp.c./fs/jfs/resize.c./fs/ntfs/ntfs.h./fs/intermezzo/super.c./fs/freevxfs/vxfs_extern.h./fs/affs/file.c
Quoted 1 line · Luca Barbieri
./drivers/acorn/block/fd1772.c
False positive; set_head_settle_flag is declared with code before use. False positive; get_head_settle_flag is declared with code before use. Correct positive; copy_buffer needs fixing, thanks for finding that.
Quoted 1 line
./include/asm-arm/thread_info.h
False positive; current_thread_info is declared with code before use.
Quoted 1 line
./include/asm-arm/current.h
False positive; get_current is declared with code before use.
Quoted 1 line
./include/asm-arm/unistd.h
False positive; _syscall3 is a macro containing code.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 1 line · Luca Barbieri
./drivers/net/via-rhine.c
via_restart_tx() was already defined before use.clear_tally_counters() is now fixed in my tree.
Thx.
From: Luca Barbieri <[email protected]>
Date: 25 Aug 2002 01:47:18 +0200
./include/net/ip.h
False positive, ip_finish_output is merely declared extern here with the __inline__ attribute so that the functions args+attributes match with what the real function definition has in net/ipv4/ip_output.c
We don't intend it to get inlined when called from other files :-)
./net/core/sock.c
ROFL, maybe your script is matching sk->urginline :-) I can't find anything else in this file.
Franks a lot,
David S. Miller
[email protected]
Quoted 1 line · Luca Barbieri
./drivers/usb/media/se401.h
Should be fixed, Jeroen, do you want to do this?
Quoted 1 line
./drivers/usb/serial/whiteheat.c
False positive, those functions are never even called :)
Quoted 1 line
./drivers/usb/net/rtl8150.c
Should be fixed, Petko want to do it?
Quoted 1 line
./drivers/usb/host/hc_simple.h
Hm, these also need to be fixed, but there doesn't seem to be a maintainer for the code. I'll just take the inline marking off of them, if no one minds.
thanks,
greg k-h
Quoted 3 lines
Quoted 1 line
./drivers/usb/serial/whiteheat.cFalse positive, those functions are never even called :)
Remove them :)
Quoted 5 lines
Quoted 1 line
./drivers/usb/host/hc_simple.hHm, these also need to be fixed, but there doesn't seem to be a maintainer for the code. I'll just take the inline marking off of them, if no one minds.
Or you could fix them by removing the declarations and moving the definitions where the declarations were (if they use something declared between the declaration and the definition more changes are required).
Quoted 3 lines
Quoted 1 line
./drivers/usb/net/rtl8150.cShould be fixed, Petko want to do it?
Will send you a patch soon.
Petko
Quoted 4 lines · On 2002.08.26 18:22:05 +0200 Greg KH wrote:
Quoted 1 line · Luca Barbieri
./drivers/usb/media/se401.hShould be fixed, Jeroen, do you want to do this?
Ok, already located the cause, I will check the other inlines to and send a patch.
Jeroen
Quoted 4 lines · On 2002.08.26 18:22:05 +0200 Greg KH wrote:
Quoted 1 line · Luca Barbieri
./drivers/usb/media/se401.hShould be fixed, Jeroen, do you want to do this?
Attached is a patch against 2.4.20-pre5 that updates the se401 driver to update it to version 0.24.
This fixes the inline problem, a memory leak on disconnect and disables the button for cameras that don't support it.
I haven't been folowing 2.5 for a while, but I think it will apply without problems.
Jeroen
drivers/usb/se401.c renamed from drivers/usb/se401.c.org +66 -63
@@ -25,7 +25,7 @@* - Jeroen Vreeken */ -static const char version[] ="0.23" ; +static const char version[] ="0.24" ;#include <linux/config.h> #include <linux/module.h>
@@ -986,6 +986,35 @@return 0 ; } +static void usb_se401_remove_disconnected (struct usb_se401 *se401) +{ +int i; + + se401->dev =NULL ; + +for (i=0 ; i<SE401_NUMSBUF ; i++)if (se401->urb[i]) { + se401->urb[i]->next =NULL ; +usb_unlink_urb (se401->urb[i]); +usb_free_urb (se401->urb[i]); + se401->urb[i] =NULL ; +kfree (se401->sbuf[i].data); + } +for (i=0 ; i<SE401_NUMSCRATCH ; i++)if (se401->scratch[i].data) { +kfree (se401->scratch[i].data); + } +if (se401->inturb) { +usb_unlink_urb (se401->inturb); +usb_free_urb (se401->inturb); + } +info ("%s disconnected" , se401->camera_name); + +/* Free the memory */ +kfree (se401->width); +kfree (se401->height); +kfree (se401); +} + +/**************************************************************************** *
@@ -1020,21 +1049,17 @@struct usb_se401 *se401 = (struct usb_se401 *)dev;int i; -for (i=0 ; i<SE401_NUMFRAMES ; i++) - se401->frame[i].grabstate=FRAME_UNUSED ; -if (se401->streaming) -se401_stop_stream (se401); -rvfree (se401->fbuf, se401->maxframesize *SE401_NUMFRAMES ); - se401->user=0 ; -if (se401->removed) {video_unregister_device (&se401->vdev); -kfree (se401->width); -kfree (se401->height); -kfree (se401); - se401 =NULL ; +usb_se401_remove_disconnected (se401);info ("device unregistered" ); + }else { +for (i=0 ; i<SE401_NUMFRAMES ; i++) + se401->frame[i].grabstate=FRAME_UNUSED ; +if (se401->streaming) +se401_stop_stream (se401); + se401->user=0 ; }MOD_DEC_USE_COUNT ;
@@ -1350,7 +1375,7 @@/***************************/ -static int se401_init (struct usb_se401 *se401) +static int se401_init (struct usb_se401 *se401,int button) {int i=0 , rc;unsigned char cp[0x40 ];
@@ -1415,22 +1440,25 @@ se401->readcount=0 ;/* Start interrupt transfers for snapshot button */ - se401->inturb=usb_alloc_urb (0 ); -if (!se401->inturb) { -info ("Allocation of inturb failed" ); -return 1 ; - } -FILL_INT_URB (se401->inturb, se401->dev, -usb_rcvintpipe (se401->dev,SE401_BUTTON_ENDPOINT ), - &se401->button,sizeof (se401->button), - se401_button_irq, - se401, -HZ /10 - ); -if (usb_submit_urb (se401->inturb)) { -info ("int urb burned down" ); -return 1 ; - } +if (button) { + se401->inturb=usb_alloc_urb (0 ); +if (!se401->inturb) { +info ("Allocation of inturb failed" ); +return 1 ; + } +FILL_INT_URB (se401->inturb, se401->dev, +usb_rcvintpipe (se401->dev,SE401_BUTTON_ENDPOINT ), + &se401->button,sizeof (se401->button), + se401_button_irq, + se401, +HZ /10 + ); +if (usb_submit_urb (se401->inturb)) { +info ("int urb burned down" ); +return 1 ; + } + }else + se401->inturb=NULL ;/* Flash the led */ se401_sndctrl (1 , se401,SE401_REQ_CAMERA_POWER ,1 ,NULL ,0 );
@@ -1447,6 +1475,7 @@struct usb_interface_descriptor *interface;struct usb_se401 *se401;char *camera_name=NULL ; +int button=1 ;/* We don't handle multi-config cameras */ if (dev->descriptor.bNumConfigurations !=1 )
@@ -1470,6 +1499,7 @@ }else if (dev->descriptor.idVendor ==0x047d && dev->descriptor.idProduct ==0x5003 ) { camera_name="Kensington VideoCAM 67016" ; + button=0 ; }else return NULL ;
@@ -1495,7 +1525,7 @@info ("firmware version: %02x" , dev->descriptor.bcdDevice &255 ); -if (se401_init (se401)) { +if (se401_init (se401, button)) {kfree (se401);return NULL ; }
@@ -1526,47 +1556,20 @@video_unregister_device (&se401->vdev);usb_se401_remove_disconnected (se401); }else { - se401->removed =1 ; - } -unlock_kernel (); -} + se401->frame[0 ].grabstate =FRAME_ERROR ; + se401->frame[1 ].grabstate =FRAME_ERROR ; -static inline void usb_se401_remove_disconnected (struct usb_se401 *se401) -{ -int i; - - se401->dev =NULL ; - se401->frame[0 ].grabstate =FRAME_ERROR ; - se401->frame[1 ].grabstate =FRAME_ERROR ; + se401->streaming =0 ; - se401->streaming =0 ; - -wake_up_interruptible (&se401->wq); - -for (i=0 ; i<SE401_NUMSBUF ; i++)if (se401->urb[i]) { - se401->urb[i]->next =NULL ; -usb_unlink_urb (se401->urb[i]); -usb_free_urb (se401->urb[i]); - se401->urb[i] =NULL ; -kfree (se401->sbuf[i].data); - } -for (i=0 ; i<SE401_NUMSCRATCH ; i++)if (se401->scratch[i].data) { -kfree (se401->scratch[i].data); - } -if (se401->inturb) { -usb_unlink_urb (se401->inturb); -usb_free_urb (se401->inturb); +wake_up_interruptible (&se401->wq); + se401->removed =1 ; } -info ("%s disconnected" , se401->camera_name);#if defined(CONFIG_PROC_FS ) && defined(CONFIG_VIDEO_PROC_FS )destroy_proc_se401_cam (se401);#endif -/* Free the memory */ -kfree (se401->width); -kfree (se401->height); -kfree (se401); +unlock_kernel (); }static struct usb_driver se401_driver = {
drivers/usb/se401.h renamed from drivers/usb/se401.h.org +0 -1
@@ -230,7 +230,6 @@ int nullpackets; }; -static inline void usb_se401_remove_disconnected (struct usb_se401 *se401);#endif
Quoted 6 lines · Jeroen Vreeken
Quoted 4 lines · On 2002.08.26 18:22:05 +0200 Greg KH wrote:
Quoted 1 line · Luca Barbieri
./drivers/usb/media/se401.hShould be fixed, Jeroen, do you want to do this?
Quoted 7 lines
Attached is a patch against 2.4.20-pre5 that updates the se401 driver to update it to version 0.24.
This fixes the inline problem, a memory leak on disconnect and disables the button for cameras that don't support it.I haven't been folowing 2.5 for a while, but I think it will apply without problems.
Sorry, but the patch does not apply (even after adjusting the path). I get lots of failed hunks.
thanks,
greg k-h
Quoted 12 lines · On 2002.09.04 20:17:23 +0200 Greg KH wrote:
Quoted 7 lines · Jeroen Vreeken
Quoted 4 lines · On 2002.08.26 18:22:05 +0200 Greg KH wrote:
Quoted 1 line · Luca Barbieri
./drivers/usb/media/se401.hShould be fixed, Jeroen, do you want to do this?
Attached is a patch against 2.4.20-pre5 that updates the se401 driver
to
Quoted 2 lines
update it to version 0.24.
This fixes the inline problem, a memory leak on disconnect and disablesthe
Quoted 8 lines
Quoted 3 lines
button for cameras that don't support it.
I haven't been folowing 2.5 for a while, but I think it will apply
without
Quoted 1 line
problems.
Sorry, but the patch does not apply (even after adjusting the path). I get lots of failed hunks.
I made a new patch against 2.5.33, it was mostly litle things like the v4l changes.
Jeroen
drivers/usb/media/se401.c renamed from drivers/usb/media/se401.c.org +65 -63
@@ -25,7 +25,7 @@* - Jeroen Vreeken */ -static const char version[] ="0.23" ; +static const char version[] ="0.24" ;#include <linux/config.h> #include <linux/module.h>
@@ -980,6 +980,34 @@return 0 ; } +static void usb_se401_remove_disconnected (struct usb_se401 *se401) +{ +int i; + + se401->dev =NULL ; + +for (i=0 ; i<SE401_NUMSBUF ; i++)if (se401->urb[i]) { +usb_unlink_urb (se401->urb[i]); +usb_free_urb (se401->urb[i]); + se401->urb[i] =NULL ; +kfree (se401->sbuf[i].data); + } +for (i=0 ; i<SE401_NUMSCRATCH ; i++)if (se401->scratch[i].data) { +kfree (se401->scratch[i].data); + } +if (se401->inturb) { +usb_unlink_urb (se401->inturb); +usb_free_urb (se401->inturb); + } +info ("%s disconnected" , se401->camera_name); + +/* Free the memory */ +kfree (se401->width); +kfree (se401->height); +kfree (se401); +} + +/**************************************************************************** *
@@ -1015,20 +1043,16 @@struct usb_se401 *se401 = (struct usb_se401 *)dev;int i; -for (i=0 ; i<SE401_NUMFRAMES ; i++) - se401->frame[i].grabstate=FRAME_UNUSED ; -if (se401->streaming) -se401_stop_stream (se401); -rvfree (se401->fbuf, se401->maxframesize *SE401_NUMFRAMES ); - se401->user=0 ; -if (se401->removed) { -kfree (se401->width); -kfree (se401->height); -kfree (se401); - se401 =NULL ; +usb_se401_remove_disconnected (se401);info ("device unregistered" ); + }else { +for (i=0 ; i<SE401_NUMFRAMES ; i++) + se401->frame[i].grabstate=FRAME_UNUSED ; +if (se401->streaming) +se401_stop_stream (se401); + se401->user=0 ; } file->private_data =NULL ;return 0 ;
@@ -1302,7 +1326,7 @@/***************************/ -static int se401_init (struct usb_se401 *se401) +static int se401_init (struct usb_se401 *se401,int button) {int i=0 , rc;unsigned char cp[0x40 ];
@@ -1367,22 +1391,25 @@ se401->readcount=0 ;/* Start interrupt transfers for snapshot button */ - se401->inturb=usb_alloc_urb (0 ,GFP_KERNEL ); -if (!se401->inturb) { -info ("Allocation of inturb failed" ); -return 1 ; - } -FILL_INT_URB (se401->inturb, se401->dev, -usb_rcvintpipe (se401->dev,SE401_BUTTON_ENDPOINT ), - &se401->button,sizeof (se401->button), - se401_button_irq, - se401, -HZ /10 - ); -if (usb_submit_urb (se401->inturb,GFP_KERNEL )) { -info ("int urb burned down" ); -return 1 ; - } +if (button) { + se401->inturb=usb_alloc_urb (0 ,GFP_KERNEL ); +if (!se401->inturb) { +info ("Allocation of inturb failed" ); +return 1 ; + } +FILL_INT_URB (se401->inturb, se401->dev, +usb_rcvintpipe (se401->dev,SE401_BUTTON_ENDPOINT ), + &se401->button,sizeof (se401->button), + se401_button_irq, + se401, +HZ /10 + ); +if (usb_submit_urb (se401->inturb,GFP_KERNEL )) { +info ("int urb burned down" ); +return 1 ; + } + }else + se401->inturb=NULL ;/* Flash the led */ se401_sndctrl (1 , se401,SE401_REQ_CAMERA_POWER ,1 ,NULL ,0 );
@@ -1399,6 +1426,7 @@struct usb_interface_descriptor *interface;struct usb_se401 *se401;char *camera_name=NULL ; +int button=1 ;/* We don't handle multi-config cameras */ if (dev->descriptor.bNumConfigurations !=1 )
@@ -1422,6 +1450,7 @@ }else if (dev->descriptor.idVendor ==0x047d && dev->descriptor.idProduct ==0x5003 ) { camera_name="Kensington VideoCAM 67016" ; + button=0 ; }else return NULL ;
@@ -1447,7 +1476,7 @@info ("firmware version: %02x" , dev->descriptor.bcdDevice &255 ); -if (se401_init (se401)) { +if (se401_init (se401, button)) {kfree (se401);return NULL ; }
@@ -1479,45 +1508,18 @@if (!se401->user){usb_se401_remove_disconnected (se401); }else { - se401->removed =1 ; - } -} + se401->frame[0 ].grabstate =FRAME_ERROR ; + se401->frame[0 ].grabstate =FRAME_ERROR ; -static inline void usb_se401_remove_disconnected (struct usb_se401 *se401) -{ -int i; - - se401->dev =NULL ; - se401->frame[0 ].grabstate =FRAME_ERROR ; - se401->frame[1 ].grabstate =FRAME_ERROR ; - - se401->streaming =0 ; - -wake_up_interruptible (&se401->wq); - -for (i=0 ; i<SE401_NUMSBUF ; i++)if (se401->urb[i]) { -usb_unlink_urb (se401->urb[i]); -usb_free_urb (se401->urb[i]); - se401->urb[i] =NULL ; -kfree (se401->sbuf[i].data); - } -for (i=0 ; i<SE401_NUMSCRATCH ; i++)if (se401->scratch[i].data) { -kfree (se401->scratch[i].data); - } -if (se401->inturb) { -usb_unlink_urb (se401->inturb); -usb_free_urb (se401->inturb); + se401->streaming =0 ; + +wake_up_interruptible (&se401->wq); + se401->removed =1 ; } -info ("%s disconnected" , se401->camera_name); -#if defined(CONFIG_PROC_FS ) && defined(CONFIG_VIDEO_PROC_FS )destroy_proc_se401_cam (se401);#endif -/* Free the memory */ -kfree (se401->width); -kfree (se401->height); -kfree (se401); }static struct usb_driver se401_driver = {
drivers/usb/media/se401.h renamed from drivers/usb/media/se401.h.org +0 -1
@@ -230,7 +230,6 @@ int nullpackets; }; -static inline void usb_se401_remove_disconnected (struct usb_se401 *se401);#endif
Quoted 3 lines · Jeroen Vreeken
I made a new patch against 2.5.33, it was mostly litle things like the v4l changes.
This works fine, applied.
thanks,
greg k-h