2 * Copyright (C) 2011 Dan Carpenter.
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
22 static void match_assign(struct expression
*expr
)
25 sval_t max_left
, max_right
;
31 macro
= get_macro_name(expr
->pos
);
34 if (strcmp(macro
, "min_t"))
37 if (!get_absolute_max(expr
->left
, &max_left
))
39 if (!get_absolute_max(expr
->right
, &max_right
))
42 if (sval_cmp(max_left
, max_right
) >= 0)
45 name
= expr_to_str(expr
->right
);
46 sm_warning("min_t truncates here '%s' (%s vs %s)", name
, sval_to_str(max_left
), sval_to_str(max_right
));
50 void check_min_t(int id
)
53 if (option_project
!= PROJ_KERNEL
)
55 add_hook(&match_assign
, ASSIGNMENT_HOOK
);