From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 14/16] warn on return <void expression>;
Date: Sun, 24 Jun 2007 09:05:31 +0100 [thread overview]
Message-ID: <E1I2N6B-0003es-7p@ZenIV.linux.org.uk> (raw)
conditional on -Wreturn-void
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
evaluate.c | 2 ++
lib.c | 2 ++
lib.h | 1 +
3 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/evaluate.c b/evaluate.c
index e3b4940..07ebf0c 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2790,6 +2790,8 @@ static struct symbol *evaluate_return_expression(struct statement *stmt)
if (!fntype || fntype == &void_ctype) {
if (expr && expr->ctype != &void_ctype)
expression_error(expr, "return expression in %s function", fntype?"void":"typeless");
+ if (expr && Wreturn_void)
+ warning(stmt->pos, "returning void-valued expression");
return NULL;
}
diff --git a/lib.c b/lib.c
index 4856b65..7f6334c 100644
--- a/lib.c
+++ b/lib.c
@@ -207,6 +207,7 @@ int Wuninitialized = 1;
int Wold_initializer = 1;
int Wnon_pointer_null = 1;
int Wparen_string = 0;
+int Wreturn_void = 0;
int dbg_entry = 0;
int dbg_dead = 0;
@@ -359,6 +360,7 @@ static const struct warning {
{ "old-initializer", &Wold_initializer },
{ "non-pointer-null", &Wnon_pointer_null },
{ "paren-string", &Wparen_string },
+ { "return-void", &Wreturn_void },
};
enum {
diff --git a/lib.h b/lib.h
index 0fe4d2a..bc2a8c2 100644
--- a/lib.h
+++ b/lib.h
@@ -104,6 +104,7 @@ extern int Wuninitialized;
extern int Wold_initializer;
extern int Wnon_pointer_null;
extern int Wparen_string;
+extern int Wreturn_void;
extern int dbg_entry;
extern int dbg_dead;
--
1.5.0-rc2.GIT
reply other threads:[~2007-06-24 8:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E1I2N6B-0003es-7p@ZenIV.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-sparse@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;
as well as URLs for NNTP newsgroup(s).