From ad9c18a721fa7decb2db05e159d83cf52c47df5b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 8 Jul 2013 11:09:53 +0300 Subject: [PATCH] check_overflow: silence some "not allocating enough data" false positives The warning messages from here are mostly caused because you have a call tree that returns an allocated struct. The size of the struct changes but the call tree takes a couple runs of building the database before it is all updated. I have changed it to only warn if the function returning the allocated buffer returns NULL. This will silence the warnings. Signed-off-by: Dan Carpenter --- check_overflow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/check_overflow.c b/check_overflow.c index 618c9e37..2bfe076e 100644 --- a/check_overflow.c +++ b/check_overflow.c @@ -338,20 +338,24 @@ static void match_limited(const char *fn, struct expression *expr, void *_limite static void db_returns_buf_size(struct expression *expr, int param, char *unused, char *math) { struct expression *call; - struct symbol *type; + struct symbol *left_type, *right_type; int bytes; sval_t sval; if (expr->type != EXPR_ASSIGNMENT) return; + right_type = get_pointer_type(expr->right); + if (!right_type || right_type->bit_size != -1) + return; + call = strip_expr(expr->right); - type = get_pointer_type(expr->left); + left_type = get_pointer_type(expr->left); if (!parse_call_math(call, math, &sval) || sval.value == 0) return; - if (!type) + if (!left_type) return; - bytes = bits_to_bytes(type->bit_size); + bytes = bits_to_bytes(left_type->bit_size); if (bytes <= 0) return; if (sval.uvalue >= bytes) -- 2.11.4.GIT