Exemplo n.º 1
0
static void match_capable(const char *fn, struct expression *expr, void *_param)
{
	struct expression *arg;
	sval_t sval;
	char buf[32];

	arg = get_argument_from_call_expr(expr->args, 0);
	if (!get_implied_value(arg, &sval))
		return;
	snprintf(buf, sizeof(buf), "%s", sval_to_str(sval));
	set_state(capable_id, buf, NULL, &capable);
}
Exemplo n.º 2
0
static void check_size_matches(int data_size, struct expression *size_expr)
{
	sval_t sval;

	if (data_size == 1)  /* this is generic a buffer */
		return;

	if (!get_implied_value(size_expr, &sval))
		return;
	if (sval_cmp_val(sval, data_size) != 0)
		sm_msg("warn: double check that we're allocating correct size: %d vs %s", data_size, sval_to_str(sval));
}
Exemplo n.º 3
0
static void match_free(const char *fn, struct expression *expr, void *data)
{
	struct expression *arg_expr;
	char *name;
	sval_t sval;

	arg_expr = get_argument_from_call_expr(expr->args, 0);
	if (!get_implied_value(arg_expr, &sval))
		return;
	if (sval.value != 0)
		return;
	name = expr_to_var(arg_expr);
	sm_msg("warn: calling %s() when '%s' is always NULL.", fn, name);
	free_string(name);
}
Exemplo n.º 4
0
static void match_return(struct expression *ret_value)
{
	sval_t rval;
	sval_t lret;
	char *name;

	if (!get_value(ret_value, &rval) || rval.value >= 0)
		return;
	if (get_implied_value(last_return, &lret))
		return;
	if (!get_implied_max(last_return, &lret) || lret.value >= 0)
		return;
	if (get_implied_min(last_return, &lret) && !sval_is_min(lret))
		return;
	name = expr_to_var(last_return);
	sm_msg("info: why not propagate '%s' from %s() instead of %s?",
		name, get_fn_name(last_func), sval_to_str(rval));
	free_string(name);
}