From: spam@altium.nl (Dick Streefland)
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] security_sk_free void return fixup
Date: Wed, 16 Jun 2004 12:11:41 -0000 [thread overview]
Message-ID: <d69.40d038fd.d9853@altium.nl> (raw)
In-Reply-To: Pine.LNX.4.58.0406151946220.4142@ppc970.osdl.org
Linus Torvalds <torvalds@osdl.org> wrote:
| I'm going to remove this warning from sparse. Apparently it is valid C99,
| and somebody (I think Richard Henderson) made the excellent point that it
| allows for type-independent code where you do something like
|
| mytype myfunc1(xxx);
|
| mytype myfunc2(xxx)
| {
| ...
| return myfunc1(...);
| }
|
| and it just works regardless of what type it is.
It may work in gcc, but it is invalid according to ISO C99. First
sentence from section 6.8.6.4:
A return statement with an expression shall not appear in a
function whose return type is void.
Now, a function call is obviously an expression.
| sparse will obviously warn about expressions with non-void types being
| returned from a void function, but the case where the expression exists
| and has the right type should be ok.
|
| I'm not sure it's wonderful C in general, but I certainly can't claim it
| is actively offensive, and since gcc accepts it and we have these things
| in the kernel, why complain?
Gcc warns about this with the -pedantic option:
$ gcc-3.3 -pedantic -c return.c
return.c: In function `myfunc2':
return.c:5: warning: `return' with a value, in function returning void
--
Dick Streefland //// Altium BV
dick.streefland@altium.nl (@ @) http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
prev parent reply other threads:[~2004-06-16 12:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-15 23:16 [PATCH] security_sk_free void return fixup Chris Wright
2004-06-16 2:53 ` Linus Torvalds
2004-06-16 3:00 ` Andrew Morton
2004-06-16 3:04 ` Linus Torvalds
2004-06-16 12:11 ` Dick Streefland [this message]
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=d69.40d038fd.d9853@altium.nl \
--to=spam@altium.nl \
--cc=dick.streefland@altium.nl \
--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