Print this page
12257 resync smatch to 0.6.1-rc1-il-4

*** 766,785 **** */ sql_insert_caller_info(expr, INTERNAL, -1, "%call_marker%", type_to_str(type)); } - static char *show_offset(int offset) - { - static char buf[64]; - - buf[0] = '\0'; - if (offset != -1) - snprintf(buf, sizeof(buf), "(-%d)", offset); - return buf; - } - int is_recursive_member(const char *name) { char buf[256]; const char *p, *next; int size; --- 766,775 ----
*** 858,868 **** free: free_string(name); return ret; } ! static void print_struct_members(struct expression *call, struct expression *expr, int param, int offset, struct stree *stree, void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm)) { struct sm_state *sm; const char *sm_name; char *name; --- 848,858 ---- free: free_string(name); return ret; } ! static void print_struct_members(struct expression *call, struct expression *expr, int param, struct stree *stree, void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm)) { struct sm_state *sm; const char *sm_name; char *name;
*** 900,926 **** sm_name++; } // FIXME: simplify? if (!add_star && strcmp(name, sm_name) == 0) { if (is_address) ! snprintf(printed_name, sizeof(printed_name), "*$%s", show_offset(offset)); else /* these are already handled. fixme: handle them here */ continue; } else if (add_star && strcmp(name, sm_name) == 0) { ! snprintf(printed_name, sizeof(printed_name), "%s*$%s", ! is_address ? "*" : "", show_offset(offset)); } else if (strncmp(name, sm_name, len) == 0) { if (sm_name[len] != '.' && sm_name[len] != '-') continue; if (is_address) snprintf(printed_name, sizeof(printed_name), ! "%s$%s->%s", add_star ? "*" : "", ! show_offset(offset), sm_name + len + 1); else snprintf(printed_name, sizeof(printed_name), ! "%s$%s%s", add_star ? "*" : "", ! show_offset(offset), sm_name + len); } else { continue; } if (is_recursive_member(printed_name)) continue; --- 890,916 ---- sm_name++; } // FIXME: simplify? if (!add_star && strcmp(name, sm_name) == 0) { if (is_address) ! snprintf(printed_name, sizeof(printed_name), "*$"); else /* these are already handled. fixme: handle them here */ continue; } else if (add_star && strcmp(name, sm_name) == 0) { ! snprintf(printed_name, sizeof(printed_name), "%s*$", ! is_address ? "*" : ""); } else if (strncmp(name, sm_name, len) == 0) { if (sm_name[len] != '.' && sm_name[len] != '-') continue; if (is_address) snprintf(printed_name, sizeof(printed_name), ! "%s$->%s", add_star ? "*" : "", ! sm_name + len + 1); else snprintf(printed_name, sizeof(printed_name), ! "%s$%s", add_star ? "*" : "", ! sm_name + len); } else { continue; } if (is_recursive_member(printed_name)) continue;
*** 928,998 **** } END_FOR_EACH_SM(sm); free: free_string(name); } - static int param_used_callback(void *_container, int argc, char **argv, char **azColName) - { - char **container = _container; - static char buf[256]; - - snprintf(buf, sizeof(buf), "%s", argv[0]); - *container = buf; - return 0; - } - - static void print_container_struct_members(struct expression *call, struct expression *expr, int param, struct stree *stree, - void (*callback)(struct expression *call, int param, char *printed_name, struct sm_state *sm)) - { - struct expression *tmp; - char *container = NULL; - int offset; - int holder_offset; - char *p; - - if (!call->fn || call->fn->type != EXPR_SYMBOL || !call->fn->symbol) - return; - - /* - * We can't use the in-mem DB because we have to parse the function - * first, then we know if it takes a container, then we know to pass it - * the container data. - * - */ - run_sql(&param_used_callback, &container, - "select key from return_implies where %s and type = %d and key like '%%$(%%' and parameter = %d limit 1;", - get_static_filter(call->fn->symbol), CONTAINER, param); - if (!container) - return; - - p = strchr(container, '-'); - if (!p) - return; - offset = atoi(p); - p = strchr(p, ')'); - if (!p) - return; - p++; - - tmp = get_assigned_expr(expr); - if (tmp) - expr = tmp; - - if (expr->type != EXPR_PREOP || expr->op != '&') - return; - expr = strip_expr(expr->unop); - holder_offset = get_member_offset_from_deref(expr); - if (-holder_offset != offset) - return; - - expr = strip_expr(expr->deref); - if (expr->type == EXPR_PREOP && expr->op == '*') - expr = strip_expr(expr->unop); - - print_struct_members(call, expr, param, holder_offset, stree, callback); - } - static void match_call_info(struct expression *call) { struct member_info_callback *cb; struct expression *arg; struct stree *stree; --- 918,927 ----
*** 1005,1016 **** FOR_EACH_PTR(member_callbacks, cb) { stree = get_all_states_stree(cb->owner); i = 0; FOR_EACH_PTR(call->args, arg) { ! print_struct_members(call, arg, i, -1, stree, cb->callback); ! print_container_struct_members(call, arg, i, stree, cb->callback); i++; } END_FOR_EACH_PTR(arg); free_stree(&stree); } END_FOR_EACH_PTR(cb); --- 934,944 ---- FOR_EACH_PTR(member_callbacks, cb) { stree = get_all_states_stree(cb->owner); i = 0; FOR_EACH_PTR(call->args, arg) { ! print_struct_members(call, arg, i, stree, cb->callback); i++; } END_FOR_EACH_PTR(arg); free_stree(&stree); } END_FOR_EACH_PTR(cb);