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

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/check_allocating_enough_data.c
          +++ new/usr/src/tools/smatch/src/check_allocating_enough_data.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   */
  17   17  
  18   18  #include "smatch.h"
  19   19  
  20   20  static void db_returns_buf_size(struct expression *expr, int param, char *unused, char *math)
  21   21  {
  22   22          struct expression *call;
  23   23          struct symbol *left_type, *right_type;
  24   24          int bytes;
  25   25          sval_t sval;
       26 +        char *str;
  26   27  
  27   28          if (expr->type != EXPR_ASSIGNMENT)
  28   29                  return;
  29   30          right_type = get_pointer_type(expr->right);
  30   31          if (!right_type || type_bits(right_type) != -1)
  31   32                  return;
  32   33  
  33   34          call = strip_expr(expr->right);
  34   35          left_type = get_pointer_type(expr->left);
  35   36  
  36   37          if (!parse_call_math(call, math, &sval) || sval.value == 0)
  37   38                  return;
  38   39          if (!left_type)
  39   40                  return;
  40   41          bytes = type_bytes(left_type);
  41   42          if (bytes <= 0)
  42   43                  return;
  43   44          if (sval.uvalue >= bytes)
  44   45                  return;
  45      -        sm_error("not allocating enough data %d vs %s", bytes, sval_to_str(sval));
       46 +
       47 +        str = expr_to_str(expr->left);
       48 +        sm_error("not allocating enough for = '%s' %d vs %s", str, bytes, sval_to_str(sval));
       49 +        free_string(str);
  46   50  }
  47   51  
  48   52  void check_allocating_enough_data(int id)
  49   53  {
  50   54          select_return_states_hook(BUF_SIZE, &db_returns_buf_size);
  51   55  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX