* [PATCH] fix checking if type is void
@ 2020-08-09 11:49 Luc Van Oostenryck
0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-08-09 11:49 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
Sparse warns if a void function returns a non-void expression.
But the check directly compares the returned type with void_ctype,
without taking in account the presence of a SYM_NODE. In
consequence, sparse issues a few false warnings.
Fix this by using is_void_type() to test the returned type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
evaluate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/evaluate.c b/evaluate.c
index dddea76182ad..6d5bbca50bb3 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3544,7 +3544,7 @@ static struct symbol *evaluate_return_expression(struct statement *stmt)
fntype = current_fn->ctype.base_type;
rettype = fntype->ctype.base_type;
if (!rettype || rettype == &void_ctype) {
- if (expr && expr->ctype != &void_ctype)
+ if (expr && !is_void_type(expr->ctype))
expression_error(expr, "return expression in %s function", rettype?"void":"typeless");
if (expr && Wreturn_void)
warning(stmt->pos, "returning void-valued expression");
base-commit: e1578773182e8f69c3a0cd8add8dfbe7561a8240
--
2.28.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-09 11:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-09 11:49 [PATCH] fix checking if type is void Luc Van Oostenryck
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).