Powered by Linux
[PATCH 1/3] smatch_type.c: fix type of pointer diff — Semantic Matching Tool

[PATCH 1/3] smatch_type.c: fix type of pointer diff

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

 



Signed-off-by: Rasmus Villemoes <rv@xxxxxxxxxxxxxxxxxx>
---
 smatch_type.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/smatch_type.c b/smatch_type.c
index bb9a816a..0fa61725 100644
--- a/smatch_type.c
+++ b/smatch_type.c
@@ -71,13 +71,17 @@ static struct symbol *get_binop_type(struct expression *expr)
 			return &int_ctype;
 		return left;
 	}
-	if (left->type == SYM_PTR || left->type == SYM_ARRAY)
-		return left;
-
 	right = get_type(expr->right);
 	if (!right)
 		return NULL;
 
+	if (expr->op == '-' &&
+	    (left->type == SYM_PTR || left->type == SYM_ARRAY) &&
+	    (right->type == SYM_PTR || right->type == SYM_ARRAY))
+		return ssize_t_ctype;
+
+	if (left->type == SYM_PTR || left->type == SYM_ARRAY)
+		return left;
 	if (right->type == SYM_PTR || right->type == SYM_ARRAY)
 		return right;
 
-- 
2.11.0

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



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux