* aic7xxx funcs without return values
@ 2001-03-08 0:21 J . A . Magallon
2001-03-08 0:53 ` Justin T. Gibbs
0 siblings, 1 reply; 4+ messages in thread
From: J . A . Magallon @ 2001-03-08 0:21 UTC (permalink / raw)
To: Linux Kernel; +Cc: Justin T . Gibbs
Hi,
Just a note to make gcc 2.96 (and future) happy. The aic7xxx driver is full of
inline funcs that should return a value and do not do that:
gcc -D__KERNEL__ -I/usr/src/linux-2.4.2-ac14/include -Wall -Wstrict-prototypes
-O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -mpreferred-stack-boundary=2
-march=i686 -c -o aic7xxx_linux.o aic7xxx_linux.c
In file included from aic7xxx_linux.c:131:
aic7xxx_osm.h: In function `ahc_pci_read_config':
aic7xxx_osm.h:839: warning: control reaches end of non-void function
That function, for example, is missing the returns and the breaks:
static __inline uint32_t
ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
{
switch (width) {
case 1:
{
uint8_t retval;
pci_read_config_byte(pci, reg, &retval);
return (retval);
}
case 2:
{
uint16_t retval;
pci_read_config_word(pci, reg, &retval);
return (retval);
}
case 4:
{
uint32_t retval;
pci_read_config_dword(pci, reg, &retval);
return (retval);
}
default:
panic("ahc_pci_read_config: Read size too big");
/* NOTREACHED */
}
}
Or if you are so worried about early returns and fast paths:
static __inline uint32_t
ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
{
uint8_t b_val;
uint16_t s_val;
uint32_t l_val;
switch (width) {
case 1:
pci_read_config_byte(pci, reg, &b_val);
return b_bal;
break;
case 2:
pci_read_config_word(pci, reg, &s_val);
return s_bal;
break;
case 4:
pci_read_config_dword(pci, reg, &l_val);
return l_bal;
break;
}
panic("ahc_pci_read_config: Read size too big");
return 0;
}
Stack is changed only once, gcc is happy, and perhaps the explicit breaks
help gcc to optimize the code.
--
J.A. Magallon $> cd pub
mailto:jamagallon@able.es $> more beer
Linux werewolf 2.4.2-ac13 #3 SMP Wed Mar 7 00:09:17 CET 2001 i686
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: aic7xxx funcs without return values
2001-03-08 0:21 aic7xxx funcs without return values J . A . Magallon
@ 2001-03-08 0:53 ` Justin T. Gibbs
2001-03-08 11:56 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Justin T. Gibbs @ 2001-03-08 0:53 UTC (permalink / raw)
To: J . A . Magallon; +Cc: Linux Kernel
>Hi,
>
>Just a note to make gcc 2.96 (and future) happy. The aic7xxx driver is full of
>inline funcs that should return a value and do not do that:
They don't return a value because doing so is meaningless. You aren't
going to get past the panic. The compiler should know that assuming
panic is properly tagged as a function that cannot return.
You may also want to check up on your C since having a break after
a return is, well, kinda silly. In all the usage of this inline, the
width is constant, so gcc should completely optimize away the switch
and surrounding code.
--
Justin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: aic7xxx funcs without return values
2001-03-08 0:53 ` Justin T. Gibbs
@ 2001-03-08 11:56 ` Alan Cox
2001-03-08 18:53 ` Justin T. Gibbs
0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2001-03-08 11:56 UTC (permalink / raw)
To: Justin T. Gibbs; +Cc: J . A . Magallon, Linux Kernel
> They don't return a value because doing so is meaningless. You aren't
> going to get past the panic. The compiler should know that assuming
> panic is properly tagged as a function that cannot return.
>
> You may also want to check up on your C since having a break after
> a return is, well, kinda silly. In all the usage of this inline, the
> width is constant, so gcc should completely optimize away the switch
> and surrounding code.
Yep.
The bigger problem with that driver for pedants is that it contains globals with
names like 'hard_error' which are asking for clashes . Bizarrely all
the static functions are carefully named ahc_* and the globals are called
things like 'restart_squencer'
The EISA probe code is also horrible, but thats not Justin's fault. Someone
needs to put some eisa_* bus functions into the kernel for that and some
of the other drivers.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: aic7xxx funcs without return values
2001-03-08 11:56 ` Alan Cox
@ 2001-03-08 18:53 ` Justin T. Gibbs
0 siblings, 0 replies; 4+ messages in thread
From: Justin T. Gibbs @ 2001-03-08 18:53 UTC (permalink / raw)
To: Alan Cox; +Cc: J . A . Magallon, Linux Kernel
>The bigger problem with that driver for pedants is that it contains globals
>with names like 'hard_error' which are asking for clashes . Bizarrely all
>the static functions are carefully named ahc_* and the globals are called
>things like 'restart_squencer'
Such is the evolutionary nature of most drivers. I just spent a bit
of time cleaning this up. Some of the exported symbols didn't even
need to be in the current layout of the driver.
Thanks for the reminder.
Justin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-03-08 18:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-08 0:21 aic7xxx funcs without return values J . A . Magallon
2001-03-08 0:53 ` Justin T. Gibbs
2001-03-08 11:56 ` Alan Cox
2001-03-08 18:53 ` Justin T. Gibbs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®