user_data, db: remove some false tagging as "user_data" (false positives)
[smatch.git] / check_array_condition.c
blob5e9559af972b2b71bfdfe8feb08fe4b89c0fcbfe
1 /*
2 * smatch/check_array_condition.c
4 * Copyright (C) 2013 Oracle.
6 * Licensed under the Open Software License version 1.1
8 */
11 * struct foo { char buf[10]; };
13 * struct foo *p = something();
14 * if (p->buf) { ...
18 #include "smatch.h"
20 static int my_id;
22 static void match_condition(struct expression *expr)
24 struct symbol *type;
25 char *str;
27 if (expr->type != EXPR_DEREF)
28 return;
29 type = get_type(expr);
30 if (!type || type->type != SYM_ARRAY)
31 return;
32 if (get_macro_name(expr->pos))
33 return;
35 str = expr_to_str(expr);
36 sm_msg("warn: this array is probably non-NULL. '%s'", str);
37 free_string(str);
40 void check_array_condition(int id)
42 my_id = id;
43 add_hook(&match_condition, CONDITION_HOOK);