static void match_condition(struct expression *expr)
{
	struct smatch_state *left_max_true = NULL;
	struct smatch_state *left_max_false = NULL;
	struct smatch_state *right_max_true = NULL;
	struct smatch_state *right_max_false = NULL;

	struct smatch_state *left_min_true = NULL;
	struct smatch_state *left_min_false = NULL;
	struct smatch_state *right_min_true = NULL;
	struct smatch_state *right_min_false = NULL;

	switch (expr->op) {
	case '<':
	case SPECIAL_LTE:
	case SPECIAL_UNSIGNED_LT:
	case SPECIAL_UNSIGNED_LTE:
		left_max_true = &capped;
		right_max_false = &capped;
		right_min_true = &capped;
		left_min_false = &capped;
		break;
	case '>':
	case SPECIAL_GTE:
	case SPECIAL_UNSIGNED_GT:
	case SPECIAL_UNSIGNED_GTE:
		left_max_false = &capped;
		right_max_true = &capped;
		left_min_true = &capped;
		right_min_false = &capped;
		break;
	case SPECIAL_EQUAL:
		left_max_true = &capped;
		right_max_true = &capped;
		left_min_true = &capped;
		right_min_true = &capped;
		break;
	case SPECIAL_NOTEQUAL:
		left_max_false = &capped;
		right_max_false = &capped;
		left_min_false = &capped;
		right_min_false = &capped;
		break;
	default:
		return;
	}

	if (get_state_expr(my_max_id, expr->left)) {
		set_true_false_states_expr(my_max_id, expr->left, left_max_true, left_max_false);
		set_true_false_states_expr(my_min_id, expr->left, left_min_true, left_min_false);
	}
	if (get_state_expr(my_max_id, expr->right)) {
		set_true_false_states_expr(my_max_id, expr->right, right_max_true, right_max_false);
		set_true_false_states_expr(my_min_id, expr->right, right_min_true, right_min_false);
	}
}
static void match_normal_assign(struct expression *expr)
{
	if (get_state_expr(my_max_id, expr->left)) {
		set_state_expr(my_max_id, expr->left, &capped);
		set_state_expr(my_min_id, expr->left, &capped);
	}
}
Beispiel #3
0
static void handle_assigned_expr(struct expression *expr)
{
	struct smatch_state *state;

	state = get_state_expr(check_assigned_expr_id, expr);
	if (!state || !state->data)
		return;
	expr = (struct expression *)state->data;
	verify_size_expr(expr);
}
static void match_condition(struct expression *expr)
{
	if (expr->type == EXPR_ASSIGNMENT)
		match_condition(expr->left);

	if (get_state_expr(my_id, expr) == &filehandle) {
		char *name;

		name = expr_to_var(expr);
		sm_msg("error: comparing a filehandle against zero '%s'", name);
		set_state_expr(my_id, expr, &oktocheck);
		free_string(name);
	}
}
Beispiel #5
0
static void match_assign(struct expression *expr)
{
	struct expression *left;

	if (expr->op != '=')
		return;
	if (!get_switch_expr())
		return;
	left = strip_expr(expr->left);
	if (get_state_expr(my_id, left) == &no_break)
		print_missing_break(left);

	set_state_expr(my_id, left, alloc_my_state(get_switch_expr()));
	skip_this = left;
}