Print this page
12257 resync smatch to 0.6.1-rc1-il-4
*** 213,259 ****
if (get_param_sym_from_num(param) == container->symbol)
return buf;
return NULL;
}
! char *get_container_name(struct expression *container, struct expression *expr)
{
struct symbol *container_sym, *sym;
- struct expression *tmp;
static char buf[64];
char *ret, *shared;
bool star;
- int cnt;
expr = strip_expr(expr);
container = strip_expr(container);
ret = get_stored_container_name(container, expr);
if (ret)
return ret;
sym = expr_to_sym(expr);
container_sym = expr_to_sym(container);
! if (sym && sym == container_sym)
! goto found;
- cnt = 0;
- while ((tmp = get_assigned_expr(container))) {
- container = strip_expr(tmp);
- if (cnt++ > 3)
- break;
- }
-
- cnt = 0;
- while ((tmp = get_assigned_expr(expr))) {
- expr = strip_expr(tmp);
- if (cnt++ > 3)
- break;
- }
-
- found:
-
if (container->type == EXPR_DEREF)
star = true;
else
star = false;
--- 213,245 ----
if (get_param_sym_from_num(param) == container->symbol)
return buf;
return NULL;
}
! static char *get_container_name_helper(struct expression *container, struct expression *expr)
{
struct symbol *container_sym, *sym;
static char buf[64];
char *ret, *shared;
bool star;
expr = strip_expr(expr);
container = strip_expr(container);
+ if (!expr || !container)
+ return NULL;
ret = get_stored_container_name(container, expr);
if (ret)
return ret;
sym = expr_to_sym(expr);
container_sym = expr_to_sym(container);
! if (!sym || !container_sym)
! return NULL;
! if (sym != container_sym)
! return NULL;
if (container->type == EXPR_DEREF)
star = true;
else
star = false;
*** 260,276 ****
if (container->type == EXPR_PREOP && container->op == '&')
container = strip_expr(container->unop);
if (expr->type == EXPR_PREOP && expr->op == '&')
expr = strip_expr(expr->unop);
- sym = expr_to_sym(expr);
- if (!sym)
- return NULL;
- container_sym = expr_to_sym(container);
- if (!container_sym || sym != container_sym)
- return NULL;
-
shared = get_shared_str(expr, container);
if (!shared)
return NULL;
if (star)
snprintf(buf, sizeof(buf), "*(%s)", shared);
--- 246,255 ----
*** 278,287 ****
--- 257,290 ----
snprintf(buf, sizeof(buf), "%s", shared);
return buf;
}
+ char *get_container_name(struct expression *container, struct expression *expr)
+ {
+ char *ret;
+
+ ret = get_container_name_helper(container, expr);
+ if (ret)
+ return ret;
+
+ ret = get_container_name_helper(get_assigned_expr(container), expr);
+ if (ret)
+ return ret;
+
+ ret = get_container_name_helper(container, get_assigned_expr(expr));
+ if (ret)
+ return ret;
+
+ ret = get_container_name_helper(get_assigned_expr(container),
+ get_assigned_expr(expr));
+ if (ret)
+ return ret;
+
+ return NULL;
+ }
+
static bool is_fn_ptr(struct expression *expr)
{
struct symbol *type;
if (!expr)