[PATCH] returns the correct type when evaluating NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux