Print this page
12724 update smatch to 0.6.1-rc1-il-5


  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))
  60                 return;
  61         if (!get_implied_value(left->right, &mask))
  62                 return;
  63 
  64         if (mask.uvalue >> shift.uvalue)
  65                 return;
  66 
  67         sm_warning("mask and shift to zero");
  68 }
  69 
  70 static void match_assign(struct expression *expr)
  71 {
  72         struct symbol *type;
  73         sval_t bits;
  74 
  75         if (expr->op != SPECIAL_SHR_ASSIGN)
  76                 return;
  77 
  78         if (!get_implied_value(expr->right, &bits))
  79                 return;
  80         type = get_type(expr->left);
  81         if (!type)


  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_value(expr->right, &shift))
  60                 return;
  61         if (!get_value(left->right, &mask))
  62                 return;
  63 
  64         if (mask.uvalue >> shift.uvalue)
  65                 return;
  66 
  67         sm_warning("mask and shift to zero");
  68 }
  69 
  70 static void match_assign(struct expression *expr)
  71 {
  72         struct symbol *type;
  73         sval_t bits;
  74 
  75         if (expr->op != SPECIAL_SHR_ASSIGN)
  76                 return;
  77 
  78         if (!get_implied_value(expr->right, &bits))
  79                 return;
  80         type = get_type(expr->left);
  81         if (!type)