linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] returns the correct type when evaluating NULL
@ 2017-03-06  4:43 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2017-03-06  4:43 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Dibyendu Majumdar, Luc Van Oostenryck

In evaluate_cast(), the expression '(void*)<some zero constant>',
aka 'NULL', is detected and given the type 'null_ctype',
a special kind of pointer type.
However the returned type is the original one: 'void *'.

This doesn't seem to be intented as in all other cases, the
evaluate_...() functions and ultimately evaluate_expression()
always return the type of the expression.

Fix this by returning the type given to the expression: null_ctype.

Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
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 47eeaef2e..440d05da6 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2844,7 +2844,7 @@ static struct symbol *evaluate_cast(struct expression *expr)
 				expr->type = EXPR_VALUE;
 				expr->ctype = &null_ctype;
 				expr->value = 0;
-				return ctype;
+				return expr->ctype;
 			}
 		}
 	}
-- 
2.11.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-06  4:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-06  4:43 [PATCH] returns the correct type when evaluating NULL 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).