2 * Copyright (C) 2012 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 * Complains about places that return -1 instead of -ENOMEM
26 static void match_return(struct expression
*ret_value
)
28 struct symbol
*func_type
= get_real_base_type(cur_func_sym
);
31 if (!func_type
|| func_type
->type
!= SYM_FN
)
33 func_type
= get_real_base_type(func_type
);
36 if (!type_unsigned(func_type
))
38 if (type_bits(func_type
) > 16)
40 if (!get_fuzzy_min(ret_value
, &sval
))
42 if (sval_is_positive(sval
) || sval_cmp_val(sval
, -1) == 0)
45 sm_warning("signedness bug returning '%s'", sval_to_str(sval
));
48 void check_return_cast(int id
)
51 add_hook(&match_return
, RETURN_HOOK
);