From e2fe75349346772b1246a60f0a68a0bf193cd46c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 29 Aug 2018 12:26:35 +0300 Subject: [PATCH] kernel_printf: silence "specifier is cast from pointer" false positives Sorry, I shouldn't have introduced all these false positives to begin with... I'm not totally sure this is the correct fix but it's pretty simple and it's an improvement. Signed-off-by: Dan Carpenter --- check_kernel_printf.c | 2 +- smatch_type.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/check_kernel_printf.c b/check_kernel_printf.c index 22fead79..fe58d2ae 100644 --- a/check_kernel_printf.c +++ b/check_kernel_printf.c @@ -972,7 +972,7 @@ check_cast_from_pointer(const char *fmt, int len, struct expression *arg, int va return; while (is_cast_expr(arg)) arg = arg->cast_expression; - if (is_ptr_type(get_type(arg))) + if (is_ptr_type(get_final_type(arg))) sm_msg("warn: argument %d to %.*s specifier is cast from pointer", va_idx, len, fmt); } diff --git a/smatch_type.c b/smatch_type.c index af59f390..f59c912c 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -296,8 +296,7 @@ static struct symbol *get_final_type_helper(struct expression *expr) * */ - return NULL; - + expr = strip_parens(expr); if (!expr) return NULL; @@ -312,7 +311,7 @@ static struct symbol *get_final_type_helper(struct expression *expr) left = get_type(expr->left); right = get_type(expr->right); - if (type_is_ptr(left) && type_is_ptr(right)) + if (type_is_ptr(left) || type_is_ptr(right)) return ssize_t_ctype; } } -- 2.11.4.GIT