Print this page
11506 smatch resync

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_ignore.c
          +++ new/usr/src/tools/smatch/src/smatch_ignore.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   *
  14   14   * You should have received a copy of the GNU General Public License
  15   15   * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16   16   */
  17   17  
  18   18  #include "smatch.h"
  19   19  #include "smatch_slist.h"
  20   20  
  21   21  STATE(ignore);
  22   22  static struct stree *ignored;
       23 +static struct stree *ignored_from_file;
  23   24  
  24   25  void add_ignore(int owner, const char *name, struct symbol *sym)
  25   26  {
  26   27          set_state_stree(&ignored, owner, name, sym, &ignore);
  27   28  }
  28   29  
  29   30  int is_ignored(int owner, const char *name, struct symbol *sym)
  30   31  {
  31   32          return !!get_state_stree(ignored, owner, name, sym);
  32   33  }
↓ open down ↓ 14 lines elided ↑ open up ↑
  47   48  {
  48   49          struct symbol *sym;
  49   50          char *name;
  50   51          int ret;
  51   52  
  52   53          name = expr_to_str_sym(expr, &sym);
  53   54          if (!name && !sym)
  54   55                  return 0;
  55   56          ret = is_ignored(owner, name, sym);
  56   57          free_string(name);
  57      -        return ret;
       58 +        if (ret)
       59 +                return true;
       60 +
       61 +        name = get_macro_name(expr->pos);
       62 +        if (name && get_state_stree(ignored_from_file, owner, name, NULL))
       63 +                return true;
       64 +
       65 +        name = get_function();
       66 +        if (name && get_state_stree(ignored_from_file, owner, name, NULL))
       67 +                return true;
       68 +
       69 +        return false;
  58   70  }
  59   71  
  60   72  static void clear_ignores(void)
  61   73  {
  62   74          if (__inline_fn)
  63   75                  return;
  64   76          free_stree(&ignored);
  65   77  }
  66   78  
       79 +static void load_ignores(void)
       80 +{
       81 +        struct token *token;
       82 +        const char *name, *str;
       83 +        int owner;
       84 +        char buf[64];
       85 +
       86 +        snprintf(buf, sizeof(buf), "%s.ignored_warnings", option_project_str);
       87 +        token = get_tokens_file(buf);
       88 +        if (!token)
       89 +                return;
       90 +        if (token_type(token) != TOKEN_STREAMBEGIN)
       91 +                return;
       92 +        token = token->next;
       93 +        while (token_type(token) != TOKEN_STREAMEND) {
       94 +                if (token_type(token) != TOKEN_IDENT)
       95 +                        break;
       96 +                name = show_ident(token->ident);
       97 +                token = token->next;
       98 +                owner = id_from_name(name);
       99 +
      100 +                if (token_type(token) != TOKEN_IDENT)
      101 +                        break;
      102 +                str = show_ident(token->ident);
      103 +                token = token->next;
      104 +
      105 +                set_state_stree_perm(&ignored_from_file, owner, str, NULL, &ignore);
      106 +        }
      107 +        clear_token_alloc();
      108 +}
      109 +
  67  110  void register_smatch_ignore(int id)
  68  111  {
  69  112          add_hook(&clear_ignores, AFTER_FUNC_HOOK);
      113 +        load_ignores();
  70  114  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX