From b3d73e117634df47b2c85ea97ad267ab28ff792d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 10 Feb 2015 22:45:47 +0100 Subject: [PATCH] check_kernel_printf.c: Strip parentheses A common source of 'non-constant format argument' is macros wrapping every argument in parentheses, and I was stupid enough not to strip those. Well, better late than never. --- check_kernel_printf.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/check_kernel_printf.c b/check_kernel_printf.c index 404c924f..1f5fab41 100644 --- a/check_kernel_printf.c +++ b/check_kernel_printf.c @@ -769,6 +769,7 @@ check_printf_call(const char *name, struct expression *expr, void *_info) sm_msg("error: call of %s with no format argument", name); return; } + fmtexpr = strip_parens(fmtexpr); if (fmtexpr->type != EXPR_STRING) { /* * If the format is given by a conditional, we can check the format in each case. @@ -776,22 +777,24 @@ check_printf_call(const char *name, struct expression *expr, void *_info) if (fmtexpr->type == EXPR_CONDITIONAL) { switch(cond_arg) { case 0: - if (fmtexpr->cond_true->type == EXPR_STRING) + if (strip_parens(fmtexpr->cond_true)->type == EXPR_STRING) check_printf_call(name, expr, INT_PTR(PTR_INT(_info) | (1 << 16))); else sm_msg("warn: true branch of ? : is not a literal string"); - if (fmtexpr->cond_false->type == EXPR_STRING) + if (strip_parens(fmtexpr->cond_false)->type == EXPR_STRING) check_printf_call(name, expr, INT_PTR(PTR_INT(_info) | (2 << 16))); else sm_msg("warn: false branch of ? : is not a literal string"); return; case 1: - assert(fmtexpr->cond_true->type == EXPR_STRING); fmtexpr = fmtexpr->cond_true; + fmtexpr = strip_parens(fmtexpr); + assert(fmtexpr->type == EXPR_STRING); break; case 2: - assert(fmtexpr->cond_false->type == EXPR_STRING); fmtexpr = fmtexpr->cond_false; + fmtexpr = strip_parens(fmtexpr); + assert(fmtexpr->type == EXPR_STRING); break; default: assert(0); -- 2.11.4.GIT