Print this page
11506 smatch resync

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/check_return_cast.c
          +++ new/usr/src/tools/smatch/src/check_return_cast.c
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  
  22   22  #include "smatch.h"
  23   23  
  24   24  static int my_id;
  25   25  
  26   26  static void match_return(struct expression *ret_value)
  27   27  {
  28   28          struct symbol *func_type = get_real_base_type(cur_func_sym);
  29   29          sval_t sval;
  30   30  
       31 +        if (!func_type || func_type->type != SYM_FN)
       32 +                return;
       33 +        func_type = get_real_base_type(func_type);
  31   34          if (!func_type)
  32   35                  return;
  33   36          if (!type_unsigned(func_type))
  34   37                  return;
  35   38          if (type_bits(func_type) > 16)
  36   39                  return;
  37   40          if (!get_fuzzy_min(ret_value, &sval))
  38   41                  return;
  39   42          if (sval_is_positive(sval) || sval_cmp_val(sval, -1) == 0)
  40   43                  return;
  41   44  
  42   45          sm_warning("signedness bug returning '%s'", sval_to_str(sval));
  43   46  }
  44   47  
  45   48  void check_return_cast(int id)
  46   49  {
  47   50          my_id = id;
  48   51          add_hook(&match_return, RETURN_HOOK);
  49   52  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX