make some vars static. other random sparse stuff.
[smatch.git] / smatch.c
blobd9f4d0d1fb47589fb1fc974e0cf4722ee712bf2b
1 /*
2 * sparse/smatch.c
4 * Copyright (C) 2006 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include <stdio.h>
11 #include "smatch.h"
13 typedef void (*reg_func) (int id);
14 void register_smatch_extra(int id);
15 void register_smatch_ignore(int id);
16 void register_implications(int id);
17 void check_null_deref(int id);
18 void check_overflow(int id);
19 void check_locking(int id);
20 void check_memory(int id);
21 void check_frees_argument(int id);
22 /* <- your test goes here */
23 /* void register_template(int id); */
25 static const reg_func reg_funcs[] = {
26 &register_smatch_extra, /* smatch_extra always has to be first */
27 &register_smatch_ignore,
28 &check_null_deref,
29 &check_overflow,
30 &check_locking,
31 &check_memory,
32 // &register_frees_argument,
34 /* <- your test goes here */
35 /* &register_template, */
37 &register_implications, /* implications always has to be last */
38 NULL
41 static void help(void)
43 printf("Usage: smatch [smatch arguments][sparse arguments] file.c\n");
44 printf("--debug: print lots of debug output.\n");
45 printf("--debug-implied: print debug output about implications.\n");
46 printf("--assume-loops: assume loops always go through at least once.\n");
47 printf("--known-conditions: don't branch for known conditions.");
48 exit(1);
51 int main(int argc, char **argv)
53 int i;
54 reg_func func;
56 /* The script IDs start at 1.
57 0 is used for internal stuff. */
58 for(i = 0; (func = reg_funcs[i]); i++){
59 func(i + 1);
62 while(argc >= 2) {
63 if (!strcmp(argv[1], "--debug")) {
64 debug_states = 1;
65 } else if (!strcmp(argv[1], "--debug-implied")) {
66 debug_implied_states = 1;
67 } else if (!strcmp(argv[1], "--no-implied")) {
68 option_no_implied = 1;
69 } else if (!strcmp(argv[1], "--assume-loops")) {
70 option_assume_loops = 1;
71 } else if (!strcmp(argv[1], "--known-conditions")) {
72 option_known_conditions = 1;
73 } else if (!strcmp(argv[1], "--help")) {
74 help();
75 } else {
76 break;
78 argc--;
79 argv++;
82 smatch(argc, argv);
83 return 0;