mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* 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

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®