Print this page
11972 resync smatch
*** 586,595 ****
--- 586,598 ----
run_sql(db_buf_size_callback, NULL,
"select value from return_states where type=%d and %s",
BUF_SIZE, sql_filter);
if (!buf_size_recipe || strcmp(buf_size_recipe, "invalid") == 0)
return NULL;
+ /* Known sizes should be handled in smatch_buf_size.c */
+ if (!strchr(buf_size_recipe, '$'))
+ return NULL;
return swap_format(expr, buf_size_recipe);
}
static void match_call_assignment(struct expression *expr)
{
*** 599,656 ****
if (!sname)
return;
set_state_expr(my_id, expr->left, alloc_state_sname(sname));
}
! static void match_returns_call(int return_id, char *return_ranges, struct expression *call)
{
- char *sname;
-
- sname = get_allocation_recipe_from_call(call);
- if (option_debug)
- sm_msg("sname = %s", sname);
- if (!sname)
- return;
-
- sql_insert_return_states(return_id, return_ranges, BUF_SIZE, -1, "",
- sname);
- }
-
- static void print_returned_allocations(int return_id, char *return_ranges, struct expression *expr)
- {
struct expression *tmp;
struct smatch_state *state;
- struct symbol *sym;
- char *name;
int cnt = 0;
expr = strip_expr(expr);
while ((tmp = get_assigned_expr(expr))) {
if (cnt++ > 5) /* assignments to self cause infinite loops */
break;
expr = strip_expr(tmp);
}
if (!expr)
! return;
! if (expr->type == EXPR_CALL) {
! match_returns_call(return_id, return_ranges, expr);
! return;
! }
! name = expr_to_var_sym(expr, &sym);
! if (!name || !sym)
! goto free;
!
! state = get_state(my_id, name, sym);
if (!state || !state->data)
! goto free;
! sql_insert_return_states(return_id, return_ranges, BUF_SIZE, -1, "",
! state->name);
! free:
! free_string(name);
}
void register_parse_call_math(int id)
{
int i;
--- 602,634 ----
if (!sname)
return;
set_state_expr(my_id, expr->left, alloc_state_sname(sname));
}
! const char *get_allocation_math(struct expression *expr)
{
struct expression *tmp;
struct smatch_state *state;
int cnt = 0;
expr = strip_expr(expr);
while ((tmp = get_assigned_expr(expr))) {
if (cnt++ > 5) /* assignments to self cause infinite loops */
break;
expr = strip_expr(tmp);
}
if (!expr)
! return NULL;
! if (expr->type == EXPR_CALL)
! return get_allocation_recipe_from_call(expr);
! state = get_state_expr(my_id, expr);
if (!state || !state->data)
! return NULL;
! return state->name;
}
void register_parse_call_math(int id)
{
int i;
*** 661,668 ****
for (i = 0; i < ARRAY_SIZE(alloc_functions); i++)
add_function_assign_hook(alloc_functions[i].func, &match_alloc,
INT_PTR(alloc_functions[i].param));
add_hook(&match_call_assignment, CALL_ASSIGNMENT_HOOK);
- add_split_return_callback(print_returned_allocations);
}
--- 639,645 ----