[PATCH 5/8] use valid_type to avoid to warn twice on conditionals

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

 



When evaluating a conditional, the expression is first evaluated
and some further verifications and processing are done if
the returned type is not NULL.

However, the returned type can also be 'bad_ctype' and if it is
the case, the additional verifications will just give meaningless
additional warnings.

Fix this by using the new helper valid_type() instead of just
testing for a null ctype.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c                   | 2 +-
 validation/bad-type-twice1.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 1fc6111e4..3c4a25325 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -879,7 +879,7 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator
 		warning(expr->pos, "assignment expression in conditional");
 
 	ctype = evaluate_expression(expr);
-	if (!ctype)
+	if (!valid_type(ctype))
 		return NULL;
 	if (is_safe_type(ctype))
 		warning(expr->pos, "testing a 'safe expression'");
diff --git a/validation/bad-type-twice1.c b/validation/bad-type-twice1.c
index 2f4e2838f..95cfd9e01 100644
--- a/validation/bad-type-twice1.c
+++ b/validation/bad-type-twice1.c
@@ -7,7 +7,6 @@ static unsigned long foo(unsigned long val, void *ref)
 
 /*
  * check-name: bad-type-twice1
- * check-known-to-fail
  *
  * check-error-start
 bad-type-twice1.c:3:17: error: incompatible types for operation (>=)
-- 
2.16.0

--
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