18 #include "smatch.h"
19
20 static int my_id;
21
22 static void match_binop(struct expression *expr)
23 {
24 struct symbol *type;
25 sval_t bits;
26
27 if (expr->op != SPECIAL_RIGHTSHIFT)
28 return;
29
30 if (!get_implied_value(expr->right, &bits))
31 return;
32
33 type = get_type(expr->left);
34 if (!type)
35 return;
36 if (type_bits(type) == -1 || type_bits(type) > bits.value)
37 return;
38 sm_warning("right shifting more than type allows %d vs %lld", type_bits(type), bits.value);
39 }
40
41 static void match_binop2(struct expression *expr)
42 {
43 struct expression *left;
44 struct expression *tmp;
45 sval_t mask, shift;
46
47 if (expr->op != SPECIAL_RIGHTSHIFT)
48 return;
49
50 left = strip_expr(expr->left);
51 tmp = get_assigned_expr(left);
52 if (tmp)
53 left = tmp;
54 if (left->type != EXPR_BINOP || left->op != '&')
55 return;
56
57 if (!get_implied_value(expr->right, &shift))
|
18 #include "smatch.h"
19
20 static int my_id;
21
22 static void match_binop(struct expression *expr)
23 {
24 struct symbol *type;
25 sval_t bits;
26
27 if (expr->op != SPECIAL_RIGHTSHIFT)
28 return;
29
30 if (!get_implied_value(expr->right, &bits))
31 return;
32
33 type = get_type(expr->left);
34 if (!type)
35 return;
36 if (type_bits(type) == -1 || type_bits(type) > bits.value)
37 return;
38 if (is_ignored_expr(my_id, expr))
39 return;
40 sm_warning("right shifting more than type allows %d vs %lld", type_bits(type), bits.value);
41 }
42
43 static void match_binop2(struct expression *expr)
44 {
45 struct expression *left;
46 struct expression *tmp;
47 sval_t mask, shift;
48
49 if (expr->op != SPECIAL_RIGHTSHIFT)
50 return;
51
52 left = strip_expr(expr->left);
53 tmp = get_assigned_expr(left);
54 if (tmp)
55 left = tmp;
56 if (left->type != EXPR_BINOP || left->op != '&')
57 return;
58
59 if (!get_implied_value(expr->right, &shift))
|