From 85e89c07b8e4e7541765a0f460d6b74fdc8b2e84 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 25 Aug 2014 14:00:36 +0300 Subject: [PATCH] remove null tests for arrays. Smatch complains about a bunch of these useless tests. warn: this array is probably non-NULL. 'sym->ident->name' Signed-off-by: Dan Carpenter --- check_kernel.c | 2 +- smatch_buf_size.c | 2 +- smatch_db.c | 4 ++-- smatch_helper.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/check_kernel.c b/check_kernel.c index 1547e549..2c5d5ddf 100644 --- a/check_kernel.c +++ b/check_kernel.c @@ -184,7 +184,7 @@ static void find_module_init_exit(struct symbol_list *sym_list) continue; if (fn->type != SYM_FN) continue; - if (!sym->ident || !sym->ident->name) + if (!sym->ident) continue; if (!fn->inline_stmt) continue; diff --git a/smatch_buf_size.c b/smatch_buf_size.c index c051212c..5d9ce627 100644 --- a/smatch_buf_size.c +++ b/smatch_buf_size.c @@ -381,7 +381,7 @@ static int get_stored_size_end_struct_bytes(struct expression *expr) name = expr_to_var_sym(expr, &sym); free_string(name); - if (!sym || !sym->ident || !sym->ident->name) + if (!sym || !sym->ident) return 0; if (!type_bytes(sym)) return 0; diff --git a/smatch_db.c b/smatch_db.c index 473b5c3d..45f47a2e 100644 --- a/smatch_db.c +++ b/smatch_db.c @@ -524,7 +524,7 @@ static int get_param(int param, char **name, struct symbol **sym) */ if (arg->ident->name < (char *)100) continue; - if (i == param && arg->ident->name) { + if (i == param) { *name = arg->ident->name; *sym = arg; return TRUE; @@ -640,7 +640,7 @@ static void match_data_from_db(struct symbol *sym) struct sm_state *sm; struct stree *stree; - if (!sym || !sym->ident || !sym->ident->name) + if (!sym || !sym->ident) return; __push_fake_cur_stree(); diff --git a/smatch_helper.c b/smatch_helper.c index 3895ef83..6c6f1656 100644 --- a/smatch_helper.c +++ b/smatch_helper.c @@ -130,7 +130,7 @@ static void __get_variable_from_expr(struct symbol **sym_ptr, char *buf, else append(buf, ".", len); - if (expr->member && expr->member->name) + if (expr->member) append(buf, expr->member->name, len); else append(buf, "unknown_member", len); @@ -216,7 +216,7 @@ static void __get_variable_from_expr(struct symbol **sym_ptr, char *buf, } case EXPR_STRING: append(buf, "\"", len); - if (expr->string && expr->string->data) + if (expr->string) append(buf, expr->string->data, len); append(buf, "\"", len); return; @@ -254,7 +254,7 @@ static void __get_variable_from_expr(struct symbol **sym_ptr, char *buf, } case EXPR_IDENTIFIER: *complicated = 1; - if (expr->expr_ident && expr->expr_ident->name) + if (expr->expr_ident) append(buf, expr->expr_ident->name, len); return; default: -- 2.11.4.GIT