mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "J . A . Magallon" <jamagallon@able.es>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: "Justin T . Gibbs" <gibbs@scsiguy.com>
Subject: aic7xxx funcs without return values
Date: Thu, 8 Mar 2001 01:21:49 +0100	[thread overview]
Message-ID: <20010308012149.A1158@werewolf.able.es> (raw)

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


             reply	other threads:[~2001-03-08  0:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-08  0:21 J . A . Magallon [this message]
2001-03-08  0:53 ` Justin T. Gibbs
2001-03-08 11:56   ` Alan Cox
2001-03-08 18:53     ` Justin T. Gibbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010308012149.A1158@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=gibbs@scsiguy.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®