From: Dan Carpenter Date: Tue, 22 Jan 2013 20:22:05 +0000 (+0300) Subject: all: rename expr_to_str_complex() to expr_to_str() X-Git-Tag: 1.57~45 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/5f257898ea504dd9e699bcba4d80c714fedf8e3a all: rename expr_to_str_complex() to expr_to_str() The _complex part of the name was misleading. Signed-off-by: Dan Carpenter --- diff --git a/check_access_ok_math.c b/check_access_ok_math.c index db99f2a1..257ca8eb 100644 --- a/check_access_ok_math.c +++ b/check_access_ok_math.c @@ -51,7 +51,7 @@ static void match_size(struct expression *size_expr) if (!can_overflow(size_expr)) return; - name = expr_to_str_complex(size_expr); + name = expr_to_str(size_expr); sm_msg("warn: math in access_ok() is dangerous '%s'", name); free_string(name); diff --git a/check_assigned_expr.c b/check_assigned_expr.c index 1db6ad5c..ac6f747f 100644 --- a/check_assigned_expr.c +++ b/check_assigned_expr.c @@ -35,7 +35,7 @@ static struct smatch_state *alloc_my_state(struct expression *expr) state = __alloc_smatch_state(0); expr = strip_expr(expr); - name = expr_to_str_complex(expr); + name = expr_to_str(expr); state->name = alloc_sname(name); free_string(name); state->data = expr; diff --git a/check_debug.c b/check_debug.c index fc88abb4..588ce381 100644 --- a/check_debug.c +++ b/check_debug.c @@ -57,7 +57,7 @@ static void match_print_implied(const char *fn, struct expression *expr, void *i arg = get_argument_from_call_expr(expr->args, 0); get_implied_rl(arg, &rl); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); sm_msg("implied: %s = '%s'", name, show_rl(rl)); free_string(name); } @@ -69,7 +69,7 @@ static void match_print_implied_min(const char *fn, struct expression *expr, voi char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (get_implied_min(arg, &sval)) sm_msg("implied min: %s = %s", name, sval_to_str(sval)); @@ -86,7 +86,7 @@ static void match_print_implied_max(const char *fn, struct expression *expr, voi char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (get_implied_max(arg, &sval)) sm_msg("implied max: %s = %s", name, sval_to_str(sval)); @@ -103,7 +103,7 @@ static void match_print_hard_max(const char *fn, struct expression *expr, void * char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (get_hard_max(arg, &sval)) sm_msg("hard max: %s = %s", name, sval_to_str(sval)); @@ -120,7 +120,7 @@ static void match_print_fuzzy_max(const char *fn, struct expression *expr, void char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (get_fuzzy_max(arg, &sval)) sm_msg("fuzzy max: %s = %s", name, sval_to_str(sval)); @@ -137,7 +137,7 @@ static void match_print_absolute_min(const char *fn, struct expression *expr, vo char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (get_absolute_min(arg, &sval)) sm_msg("absolute min: %s = %s", name, sval_to_str(sval)); @@ -156,7 +156,7 @@ static void match_print_absolute_max(const char *fn, struct expression *expr, vo arg = get_argument_from_call_expr(expr->args, 0); get_absolute_max(arg, &sval); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); sm_msg("absolute max: %s = %s", name, sval_to_str(sval)); free_string(name); } @@ -168,7 +168,7 @@ static void match_sval_info(const char *fn, struct expression *expr, void *info) char *name; arg = get_argument_from_call_expr(expr->args, 0); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (!get_implied_value(arg, &sval)) { sm_msg("no sval for '%s'", name); @@ -221,7 +221,7 @@ static void match_buf_size(const char *fn, struct expression *expr, void *info) elements = get_array_size(arg); bytes = get_array_size_bytes(arg); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); sm_msg("buf size: '%s' %d elements, %d bytes", name, elements, bytes); free_string(name); } diff --git a/check_dma_on_stack.c b/check_dma_on_stack.c index 56290d39..f1d15c6c 100644 --- a/check_dma_on_stack.c +++ b/check_dma_on_stack.c @@ -24,7 +24,7 @@ static void match_dma_func(const char *fn, struct expression *expr, void *param) if (arg->type == EXPR_PREOP && arg->op == '&') { if (arg->unop->type != EXPR_SYMBOL) return; - name = expr_to_str_complex(arg); + name = expr_to_str(arg); sm_msg("error: doing dma on the stack (%s)", name); free_string(name); return; diff --git a/check_leaks.c b/check_leaks.c index 6bfe4a77..b6475a04 100644 --- a/check_leaks.c +++ b/check_leaks.c @@ -62,7 +62,7 @@ static char *get_parent_from_expr(struct expression *expr, struct symbol **sym) expr = strip_expr(expr); - name = expr_to_str_sym_complex(expr, sym); + name = expr_to_str_sym(expr, sym); free_string(name); if (!name || !*sym || !(*sym)->ident) { *sym = NULL; @@ -77,7 +77,7 @@ static int is_local(struct expression *expr) struct symbol *sym; int ret = 0; - name = expr_to_str_sym_complex(expr, &sym); + name = expr_to_str_sym(expr, &sym); if (!name || !sym) goto out; if (sym->ctype.modifiers & (MOD_NONLOCAL | MOD_STATIC | MOD_ADDRESSABLE)) @@ -95,7 +95,7 @@ static int is_param(struct expression *expr) struct symbol *tmp; int ret = 0; - name = expr_to_str_sym_complex(expr, &sym); + name = expr_to_str_sym(expr, &sym); if (!name || !sym) goto out; FOR_EACH_PTR(cur_func_sym->ctype.base_type->arguments, tmp) { diff --git a/check_locking.c b/check_locking.c index 8329123b..be0ed002 100644 --- a/check_locking.c +++ b/check_locking.c @@ -377,7 +377,7 @@ static char *get_full_name(struct expression *expr, int index) if (!arg) goto free; arg = remove_spinlock_check(arg); - name = expr_to_str_complex(arg); + name = expr_to_str(arg); if (!name) goto free; full_name = make_full_name(lock->name, name); diff --git a/check_macro_side_effects.c b/check_macro_side_effects.c index 3178f734..91e7422e 100644 --- a/check_macro_side_effects.c +++ b/check_macro_side_effects.c @@ -24,7 +24,7 @@ static struct smatch_state *alloc_my_state(struct expression *expr) state = __alloc_smatch_state(0); expr = strip_expr(expr); - name = expr_to_str_complex(expr); + name = expr_to_str(expr); state->name = alloc_sname(name); free_string(name); state->data = expr; @@ -109,7 +109,7 @@ static void match_unop(struct expression *raw_expr) if (!positions_eq(old_pos, expr->pos)) return; - name = expr_to_str_complex(raw_expr); + name = expr_to_str(raw_expr); sm_msg("warn: side effect in macro '%s' doing '%s'", macro, name); free_string(name); diff --git a/check_memory.c b/check_memory.c index cb625a14..5421e462 100644 --- a/check_memory.c +++ b/check_memory.c @@ -175,7 +175,7 @@ static void match_assign(struct expression *expr) struct sm_state *tmp; left = strip_expr(expr->left); - left_name = expr_to_str_sym_complex(left, &left_sym); + left_name = expr_to_str_sym(left, &left_sym); right = strip_expr(expr->right); while (right->type == EXPR_ASSIGNMENT) @@ -189,7 +189,7 @@ static void match_assign(struct expression *expr) goto exit; } - right_name = expr_to_str_sym_complex(right, &right_sym); + right_name = expr_to_str_sym(right, &right_sym); if (right_name && (state = get_state(my_id, right_name, right_sym))) { if (state == &isfree && !is_complex(right)) @@ -319,7 +319,7 @@ static void match_return(struct expression *ret_value) char *name; struct symbol *sym; - name = expr_to_str_sym_complex(ret_value, &sym); + name = expr_to_str_sym(ret_value, &sym); if (sym) assign_parent(sym); free_string(name); @@ -382,7 +382,7 @@ static void match_function_call(struct expression *expr) FOR_EACH_PTR(expr->args, tmp) { tmp = strip_expr(tmp); - name = expr_to_str_sym_complex(tmp, &sym); + name = expr_to_str_sym(tmp, &sym); if (!name) continue; if ((state = get_sm_state(my_id, name, sym))) { diff --git a/check_min_t.c b/check_min_t.c index da8eef35..362c13c6 100644 --- a/check_min_t.c +++ b/check_min_t.c @@ -34,7 +34,7 @@ static void match_assign(struct expression *expr) if (sval_cmp(max_left, max_right) >= 0) return; - name = expr_to_str_complex(expr->right); + name = expr_to_str(expr->right); sm_msg("warn: min_t truncates here '%s' (%s vs %s)", name, sval_to_str(max_left), sval_to_str(max_right)); free_string(name); } diff --git a/check_missing_break.c b/check_missing_break.c index 01445731..2c78112f 100644 --- a/check_missing_break.c +++ b/check_missing_break.c @@ -44,7 +44,7 @@ static struct smatch_state *alloc_my_state(struct expression *expr) state = __alloc_smatch_state(0); expr = strip_expr(expr); - name = expr_to_str_complex(expr); + name = expr_to_str(expr); if (!name) name = alloc_string(""); state->name = alloc_sname(name); diff --git a/check_or_vs_and.c b/check_or_vs_and.c index 3e31b4fa..18ec7578 100644 --- a/check_or_vs_and.c +++ b/check_or_vs_and.c @@ -34,10 +34,10 @@ static int expr_equiv(struct expression *one, struct expression *two) if (does_inc_dec(one) || does_inc_dec(two)) return 0; - one_name = expr_to_str_sym_complex(one, &one_sym); + one_name = expr_to_str_sym(one, &one_sym); if (!one_name || !one_sym) goto free; - two_name = expr_to_str_sym_complex(two, &two_sym); + two_name = expr_to_str_sym(two, &two_sym); if (!two_name || !two_sym) goto free; if (one_sym != two_sym) diff --git a/check_overflow.c b/check_overflow.c index f0274a77..ee4ed316 100644 --- a/check_overflow.c +++ b/check_overflow.c @@ -119,7 +119,7 @@ static void array_check(struct expression *expr) return; } - name = expr_to_str_complex(array_expr); + name = expr_to_str(array_expr); /* Blast. Smatch can't figure out glibc's strcmp __strcmp_cg() * so it prints an error every time you compare to a string * literal array with 4 or less chars. @@ -195,8 +195,8 @@ static void match_strcpy(const char *fn, struct expression *expr, void *unused) if (data_size && dest_size >= data_size) return; - dest_name = expr_to_str_complex(dest); - data_name = expr_to_str_complex(data); + dest_name = expr_to_str(dest); + data_name = expr_to_str(data); if (data_size) sm_msg("error: %s() '%s' too large for '%s' (%d vs %d)", @@ -237,7 +237,7 @@ static void match_snprintf(const char *fn, struct expression *expr, void *unused return; if (strcmp(format, "\"%s\"")) goto free; - data_name = expr_to_str_complex(data); + data_name = expr_to_str(data); data_size = get_array_size_bytes(data); if (limit_size.value < data_size) sm_msg("error: snprintf() chops off the last chars of '%s': %d vs %s", @@ -269,7 +269,7 @@ static void match_sprintf(const char *fn, struct expression *expr, void *unused) return; if (strcmp(format, "\"%s\"")) goto free; - data_name = expr_to_str_complex(data); + data_name = expr_to_str(data); data_size = get_array_size_bytes(data); if (dest_size < data_size) sm_msg("error: sprintf() copies too much data from '%s': %d vs %d", @@ -298,7 +298,7 @@ static void match_limited(const char *fn, struct expression *expr, void *_limite if (has >= needed.value) return; - dest_name = expr_to_str_complex(dest); + dest_name = expr_to_str(dest); sm_msg("error: %s() '%s' too small (%d vs %s)", fn, dest_name, has, sval_to_str(needed)); free_string(dest_name); } diff --git a/check_passes_sizeof.c b/check_passes_sizeof.c index 0d28f1de..202c96c7 100644 --- a/check_passes_sizeof.c +++ b/check_passes_sizeof.c @@ -27,10 +27,10 @@ static int expr_equiv(struct expression *one, struct expression *two) if (one->type != two->type) return 0; - one_name = expr_to_str_sym_complex(one, &one_sym); + one_name = expr_to_str_sym(one, &one_sym); if (!one_name || !one_sym) goto free; - two_name = expr_to_str_sym_complex(two, &two_sym); + two_name = expr_to_str_sym(two, &two_sym); if (!two_name || !two_sym) goto free; if (one_sym != two_sym) diff --git a/check_pointer_math.c b/check_pointer_math.c index b82ce844..d90a93c3 100644 --- a/check_pointer_math.c +++ b/check_pointer_math.c @@ -69,7 +69,7 @@ static void match_binop(struct expression *expr) if (!is_size_in_bytes(expr->right)) return; - name = expr_to_str_complex(expr->left); + name = expr_to_str(expr->left); sm_msg("warn: potential pointer math issue ('%s' is a %d bit pointer)", name, type->bit_size); free_string(name); diff --git a/check_signed.c b/check_signed.c index c94d4894..9938186d 100644 --- a/check_signed.c +++ b/check_signed.c @@ -45,8 +45,8 @@ static void match_assign(struct expression *expr) return; max = sval_type_max(sym); if (sval_cmp(max, sval) < 0 && !(sval.value < 256 && max.value == 127)) { - left_name = expr_to_str_complex(expr->left); - right_name = expr_to_str_complex(expr->right); + left_name = expr_to_str(expr->left); + right_name = expr_to_str(expr->right); sm_msg("warn: '%s' %s can't fit into %s '%s'", right_name, sval_to_numstr(sval), sval_to_numstr(max), left_name); free_string(left_name); @@ -61,7 +61,7 @@ static void match_assign(struct expression *expr) return; if (sval_positive_bits(sval) == 7) return; - left_name = expr_to_str_complex(expr->left); + left_name = expr_to_str(expr->left); if (min.value == 0) { sm_msg("warn: assigning %s to unsigned variable '%s'", sval_to_str(sval), left_name); @@ -102,11 +102,11 @@ static int cap_gt_zero_and_lt(struct expression *expr) right->op != SPECIAL_UNSIGNED_LTE) return 0; - name1 = expr_to_str_complex(var); + name1 = expr_to_str(var); if (!name1) goto free; - name2 = expr_to_str_complex(right->left); + name2 = expr_to_str(right->left); if (!name2) goto free; if (!strcmp(name1, name2)) @@ -152,11 +152,11 @@ static int cap_lt_zero_or_gt(struct expression *expr) right->op != SPECIAL_UNSIGNED_GTE) return 0; - name1 = expr_to_str_complex(var); + name1 = expr_to_str(var); if (!name1) goto free; - name2 = expr_to_str_complex(right->left); + name2 = expr_to_str(right->left); if (!name2) goto free; if (!strcmp(name1, name2)) @@ -205,7 +205,7 @@ static int print_unsigned_never_less_than_zero(struct expression *expr) if (!get_value(expr->right, &known) || known.value != 0) return 0; - name = expr_to_str_complex(expr->left); + name = expr_to_str(expr->left); sm_msg("warn: unsigned '%s' is never less than zero.", name); free_string(name); return 1; @@ -268,7 +268,7 @@ static void match_condition(struct expression *expr) } if (!possibly_true_rl(rl_left, expr->op, rl_right)) { - char *name = expr_to_str_complex(expr); + char *name = expr_to_str(expr); sm_msg("warn: impossible condition '(%s) => (%s %s %s)'", name, show_rl(rl_left), show_special(expr->op), @@ -277,7 +277,7 @@ static void match_condition(struct expression *expr) } if (!possibly_false_rl(rl_left, expr->op, rl_right)) { - char *name = expr_to_str_complex(expr); + char *name = expr_to_str(expr); sm_msg("warn: always true condition '(%s) => (%s %s %s)'", name, show_rl(rl_left_orig), show_special(expr->op), diff --git a/check_sizeof.c b/check_sizeof.c index 4b8de5bd..55901267 100644 --- a/check_sizeof.c +++ b/check_sizeof.c @@ -22,7 +22,7 @@ static void check_pointer(struct expression *expr, char *ptr_name) get_value(expr, &sval); expr = strip_expr(expr->cast_expression); - name = expr_to_str_complex(expr); + name = expr_to_str(expr); if (!name) return; @@ -40,7 +40,7 @@ static void match_call_assignment(struct expression *expr) if (!is_pointer(expr->left)) return; - ptr_name = expr_to_str_complex(expr->left); + ptr_name = expr_to_str(expr->left); if (!ptr_name) return; diff --git a/check_type.c b/check_type.c index 1a37c433..e8398581 100644 --- a/check_type.c +++ b/check_type.c @@ -33,7 +33,7 @@ static void match_free(const char *fn, struct expression *expr, void *data) if (!type || !type->ident) return; - name = expr_to_str_complex(arg_expr); + name = expr_to_str(arg_expr); if (!strcmp("sk_buff", type->ident->name)) { sm_msg("error: use kfree_skb() here instead of kfree(%s)", name); diff --git a/check_user_data.c b/check_user_data.c index 6f3cbcad..efbeddf1 100644 --- a/check_user_data.c +++ b/check_user_data.c @@ -152,7 +152,7 @@ int is_user_data(struct expression *expr) if (tmp) return slist_has_state(tmp->possible, &user_data); - name = expr_to_str_sym_complex(expr, &sym); + name = expr_to_str_sym(expr, &sym); if (!name || !sym) goto free; diff --git a/check_wait_for_common.c b/check_wait_for_common.c index 99241e5e..1e00ad65 100644 --- a/check_wait_for_common.c +++ b/check_wait_for_common.c @@ -17,7 +17,7 @@ static void match_wait_for_common(const char *fn, struct expression *expr, void if (!expr_unsigned(expr->left)) return; - name = expr_to_str_complex(expr->left); + name = expr_to_str(expr->left); sm_msg("error: '%s()' returns negative and '%s' is unsigned", fn, name); free_string(name); } diff --git a/smatch.h b/smatch.h index 20854ad2..109521d4 100644 --- a/smatch.h +++ b/smatch.h @@ -224,8 +224,8 @@ struct expression *get_argument_from_call_expr(struct expression_list *args, int num); char *expr_to_var(struct expression *expr); -char *expr_to_str_complex(struct expression *expr); -char *expr_to_str_sym_complex(struct expression *expr, +char *expr_to_str(struct expression *expr); +char *expr_to_str_sym(struct expression *expr, struct symbol **sym_ptr); char *expr_to_var_sym(struct expression *expr, struct symbol **sym_ptr); diff --git a/smatch_conditions.c b/smatch_conditions.c index 67544fe9..616cd5b5 100644 --- a/smatch_conditions.c +++ b/smatch_conditions.c @@ -338,7 +338,7 @@ static void hackup_unsigned_compares(struct expression *expr) static void split_conditions(struct expression *expr) { if (option_debug) { - char *cond = expr_to_str_complex(expr); + char *cond = expr_to_str(expr); sm_debug("%d in split_conditions (%s)\n", get_lineno(), cond); free_string(cond); diff --git a/smatch_helper.c b/smatch_helper.c index 474ee575..de3057b1 100644 --- a/smatch_helper.c +++ b/smatch_helper.c @@ -242,7 +242,7 @@ static void __get_variable_from_expr(struct symbol **sym_ptr, char *buf, * */ -char *expr_to_str_sym_complex(struct expression *expr, struct symbol **sym_ptr) +char *expr_to_str_sym(struct expression *expr, struct symbol **sym_ptr) { static char var_name[VAR_LEN]; int complicated = 0; @@ -261,9 +261,9 @@ char *expr_to_str_sym_complex(struct expression *expr, struct symbol **sym_ptr) return NULL; } -char *expr_to_str_complex(struct expression *expr) +char *expr_to_str(struct expression *expr) { - return expr_to_str_sym_complex(expr, NULL); + return expr_to_str_sym(expr, NULL); } /* diff --git a/smatch_type.c b/smatch_type.c index db69acb6..9426e4d8 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -342,7 +342,7 @@ int is_static(struct expression *expr) struct symbol *sym; int ret = 0; - name = expr_to_str_sym_complex(expr, &sym); + name = expr_to_str_sym(expr, &sym); if (!name || !sym) goto free; @@ -463,7 +463,7 @@ struct symbol *get_member_type_from_key(struct expression *expr, char *key) return get_real_base_type(sym); } - name = expr_to_str_sym_complex(expr, &sym); + name = expr_to_str_sym(expr, &sym); free_string(name); if (!sym) return NULL;