Print this page
11506 smatch resync

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_flow.c
          +++ new/usr/src/tools/smatch/src/smatch_flow.c
↓ open down ↓ 68 lines elided ↑ open up ↑
  69   69  static void split_declaration(struct symbol_list *sym_list);
  70   70  static void split_expr_list(struct expression_list *expr_list, struct expression *parent);
  71   71  static void add_inline_function(struct symbol *sym);
  72   72  static void parse_inline(struct expression *expr);
  73   73  
  74   74  int option_assume_loops = 0;
  75   75  int option_two_passes = 0;
  76   76  struct symbol *cur_func_sym = NULL;
  77   77  struct stree *global_states;
  78   78  
  79      -long long valid_ptr_min = 4096;
  80      -long long valid_ptr_max = 2117777777;
  81      -sval_t valid_ptr_min_sval = {
       79 +const unsigned long valid_ptr_min = 4096;
       80 +unsigned long valid_ptr_max = ULONG_MAX & ~(MTAG_OFFSET_MASK);
       81 +const sval_t valid_ptr_min_sval = {
  82   82          .type = &ptr_ctype,
  83   83          {.value = 4096},
  84   84  };
  85   85  sval_t valid_ptr_max_sval = {
  86   86          .type = &ptr_ctype,
  87      -        {.value = LONG_MAX - 100000},
       87 +        {.value = ULONG_MAX & ~(MTAG_OFFSET_MASK)},
  88   88  };
  89   89  struct range_list *valid_ptr_rl;
  90   90  
  91      -static void set_valid_ptr_max(void)
       91 +void alloc_valid_ptr_rl(void)
  92   92  {
  93      -        if (type_bits(&ptr_ctype) == 32)
  94      -                valid_ptr_max = 2117777777;
  95      -        else if (type_bits(&ptr_ctype) == 64)
  96      -                valid_ptr_max = 2117777777777777777LL;
  97      -
       93 +        valid_ptr_max = sval_type_max(&ulong_ctype).value & ~(MTAG_OFFSET_MASK);
  98   94          valid_ptr_max_sval.value = valid_ptr_max;
  99      -}
 100   95  
 101      -static void alloc_valid_ptr_rl(void)
 102      -{
 103   96          valid_ptr_rl = alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval);
 104   97          valid_ptr_rl = cast_rl(&ptr_ctype, valid_ptr_rl);
 105   98          valid_ptr_rl = clone_rl_permanent(valid_ptr_rl);
 106   99  }
 107  100  
 108  101  int outside_of_function(void)
 109  102  {
 110  103          return cur_func_sym == NULL;
 111  104  }
 112  105  
↓ open down ↓ 384 lines elided ↑ open up ↑
 497  490                  __pass_to_client(expr, CAST_HOOK);
 498  491                  __split_expr(expr->cast_expression);
 499  492                  break;
 500  493          case EXPR_SIZEOF:
 501  494                  if (expr->cast_expression)
 502  495                          __pass_to_client(strip_parens(expr->cast_expression),
 503  496                                           SIZEOF_HOOK);
 504  497                  break;
 505  498          case EXPR_OFFSETOF:
 506  499          case EXPR_ALIGNOF:
 507      -                evaluate_expression(expr);
 508  500                  break;
 509  501          case EXPR_CONDITIONAL:
 510  502          case EXPR_SELECT:
 511  503                  expr_set_parent_expr(expr->conditional, expr);
 512  504                  expr_set_parent_expr(expr->cond_true, expr);
 513  505                  expr_set_parent_expr(expr->cond_false, expr);
 514  506  
 515  507                  if (known_condition_true(expr->conditional)) {
 516  508                          __split_expr(expr->cond_true);
 517  509                          break;
↓ open down ↓ 353 lines elided ↑ open up ↑
 871  863          if (!stmt->case_expression)
 872  864                  __set_default();
 873  865          __split_stmt(stmt->case_statement);
 874  866  }
 875  867  
 876  868  int time_parsing_function(void)
 877  869  {
 878  870          return ms_since(&fn_start_time) / 1000;
 879  871  }
 880  872  
 881      -static int taking_too_long(void)
      873 +/*
      874 + * This defaults to 60 * 5 == 5 minutes, so we'll just multiply
      875 + * whatever we're given by 5.
      876 + */
      877 +bool taking_too_long(void)
 882  878  {
 883      -        if ((ms_since(&outer_fn_start_time) / 1000) > 60 * 5) /* five minutes */
      879 +        if (option_timeout &&
      880 +            (ms_since(&outer_fn_start_time) / 1000) > option_timeout * 5)
 884  881                  return 1;
 885  882          return 0;
 886  883  }
 887  884  
 888  885  static int is_last_stmt(struct statement *cur_stmt)
 889  886  {
 890  887          struct symbol *fn;
 891  888          struct statement *stmt;
 892  889  
 893  890          if (!cur_func_sym)
↓ open down ↓ 1007 lines elided ↑ open up ↑
1901 1898          sql_outfd = fopen(buf, "w");
1902 1899          if (!sql_outfd)
1903 1900                  sm_fatal("Error:  Cannot open %s", buf);
1904 1901  
1905 1902          snprintf(buf, sizeof(buf), "%s.smatch.caller_info", base_file);
1906 1903          caller_info_fd = fopen(buf, "w");
1907 1904          if (!caller_info_fd)
1908 1905                  sm_fatal("Error:  Cannot open %s", buf);
1909 1906  }
1910 1907  
1911      -void smatch(int argc, char **argv)
     1908 +void smatch(struct string_list *filelist)
1912 1909  {
1913      -        struct string_list *filelist = NULL;
1914 1910          struct symbol_list *sym_list;
1915 1911          struct timeval stop, start;
1916 1912          char *path;
1917 1913          int len;
1918 1914  
1919 1915          gettimeofday(&start, NULL);
1920 1916  
1921      -        sparse_initialize(argc, argv, &filelist);
1922      -        set_valid_ptr_max();
1923      -        alloc_valid_ptr_rl();
1924 1917          FOR_EACH_PTR_NOTAG(filelist, base_file) {
1925 1918                  path = getcwd(NULL, 0);
1926 1919                  free(full_base_file);
1927 1920                  if (path) {
1928 1921                          len = strlen(path) + 1 + strlen(base_file) + 1;
1929 1922                          full_base_file = malloc(len);
1930 1923                          snprintf(full_base_file, len, "%s/%s", path, base_file);
1931 1924                  } else {
1932 1925                          full_base_file = alloc_string(base_file);
1933 1926                  }
1934 1927                  if (option_file_output)
1935 1928                          open_output_files(base_file);
1936 1929                  sym_list = sparse_keep_tokens(base_file);
1937 1930                  split_c_file_functions(sym_list);
1938 1931          } END_FOR_EACH_PTR_NOTAG(base_file);
1939 1932  
1940 1933          gettimeofday(&stop, NULL);
1941 1934  
1942 1935          set_position(last_pos);
     1936 +        final_pass = 1;
1943 1937          if (option_time)
1944 1938                  sm_msg("time: %lu", stop.tv_sec - start.tv_sec);
1945 1939          if (option_mem)
1946 1940                  sm_msg("mem: %luKb", get_max_memory());
1947 1941  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX