parser: Cleanup parser control flags, so they display as expected to user

Instead of having multiple tables, since we have room post split
of optimization and dump flags just move all the optimization and
dump flags into a common table.

We can if needed switch the flag entry size to a long in the future.

Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2023-07-08 19:49:34 -07:00
parent 1754b4da69
commit 501e87a3f2
13 changed files with 74 additions and 94 deletions

View file

@ -22,10 +22,8 @@
typedef int optflags_t;
typedef struct optflags {
optflags_t dfaflags;
optflags_t dfadump;
optflags_t frontflags;
optflags_t frontdump;
optflags_t control;
optflags_t dump;
optflags_t warn;
optflags_t Werror;
} optflags;

View file

@ -27,7 +27,7 @@
#include "common_optarg.h"
#include "parser.h"
optflag_table_t dfadumpflag_table[] = {
optflag_table_t dumpflag_table[] = {
{ 1, "rule-exprs", "Dump rule to expr tree conversions",
DUMP_DFA_RULE_EXPR },
{ 1, "expr-stats", "Dump stats on expr tree", DUMP_DFA_TREE_STATS },
@ -70,6 +70,7 @@ optflag_table_t dfadumpflag_table[] = {
DUMP_DFA_DIFF_STATS },
{ 1, "diff-progress", "Dump progress of differential encoding",
DUMP_DFA_DIFF_PROGRESS | DUMP_DFA_DIFF_STATS },
{ 1, "rule-merge", "dump information about rule merging", DUMP_RULE_MERGE},
{ 0, NULL, NULL, 0 },
};
@ -100,6 +101,7 @@ optflag_table_t dfaoptflag_table[] = {
CONTROL_DFA_TRANS_HIGH },
{ 1, "diff-encode", "Differentially encode transitions",
CONTROL_DFA_DIFF_ENCODE },
{ 1, "rule-merge", "turn on rule merging", CONTROL_RULE_MERGE},
{ 0, NULL, NULL, 0 },
};

View file

@ -38,7 +38,7 @@ typedef struct {
optflags_t flags;
} optflag_table_t;
extern optflag_table_t dfadumpflag_table[];
extern optflag_table_t dumpflag_table[];
extern optflag_table_t dfaoptflag_table[];

View file

@ -110,7 +110,7 @@ bool aare_rules::add_rule_vec(int deny, uint32_t perms, uint32_t audit,
accept = unique_perms.insert(deny, perms, audit, exact_match);
if (opts.dfadump & DUMP_DFA_RULE_EXPR) {
if (opts.dump & DUMP_DFA_RULE_EXPR) {
const char *separator;
if (oob)
separator = "\\-x01";
@ -158,7 +158,7 @@ bool aare_rules::append_rule(const char *rule, bool oob, bool with_perm,
if (regex_parse(&tree, rule))
return false;
if (opts.dfadump & DUMP_DFA_RULE_EXPR) {
if (opts.dump & DUMP_DFA_RULE_EXPR) {
cerr << "rule: ";
cerr << rule;
cerr << " -> ";
@ -204,14 +204,14 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
* set nodes */
PermExprMap::iterator i = expr_map.begin();
if (i != expr_map.end()) {
if (opts.dfaflags & CONTROL_DFA_TREE_SIMPLE) {
if (opts.control & CONTROL_DFA_TREE_SIMPLE) {
Node *tmp = simplify_tree(i->second, opts);
root = new CatNode(tmp, i->first);
} else
root = new CatNode(i->second, i->first);
for (i++; i != expr_map.end(); i++) {
Node *tmp;
if (opts.dfaflags & CONTROL_DFA_TREE_SIMPLE) {
if (opts.control & CONTROL_DFA_TREE_SIMPLE) {
tmp = simplify_tree(i->second, opts);
} else
tmp = i->second;
@ -226,13 +226,13 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
* this debug dump.
*/
label_nodes(root);
if (opts.dfadump & DUMP_DFA_TREE) {
if (opts.dump & DUMP_DFA_TREE) {
cerr << "\nDFA: Expression Tree\n";
root->dump(cerr);
cerr << "\n\n";
}
if (opts.dfaflags & CONTROL_DFA_TREE_SIMPLE) {
if (opts.control & CONTROL_DFA_TREE_SIMPLE) {
/* This is old total tree, simplification point
* For now just do simplification up front. It gets most
* of the benefit running on the smaller chains, and is
@ -241,7 +241,7 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
*/
//root = simplify_tree(root, opts);
if (opts.dfadump & DUMP_DFA_SIMPLE_TREE) {
if (opts.dump & DUMP_DFA_SIMPLE_TREE) {
cerr << "\nDFA: Simplified Expression Tree\n";
root->dump(cerr);
cerr << "\n\n";
@ -251,18 +251,18 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
stringstream stream;
try {
DFA dfa(root, opts, filedfa);
if (opts.dfadump & DUMP_DFA_UNIQ_PERMS)
if (opts.dump & DUMP_DFA_UNIQ_PERMS)
dfa.dump_uniq_perms("dfa");
if (opts.dfaflags & CONTROL_DFA_MINIMIZE) {
if (opts.control & CONTROL_DFA_MINIMIZE) {
dfa.minimize(opts);
if (opts.dfadump & DUMP_DFA_MIN_UNIQ_PERMS)
if (opts.dump & DUMP_DFA_MIN_UNIQ_PERMS)
dfa.dump_uniq_perms("minimized dfa");
}
if (opts.dfaflags & CONTROL_DFA_FILTER_DENY &&
opts.dfaflags & CONTROL_DFA_MINIMIZE &&
if (opts.control & CONTROL_DFA_FILTER_DENY &&
opts.control & CONTROL_DFA_MINIMIZE &&
dfa.apply_and_clear_deny()) {
/* Do a second minimization pass as removal of deny
* information has moved some states from accepting
@ -273,40 +273,40 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
*/
dfa.minimize(opts);
if (opts.dfadump & DUMP_DFA_MIN_UNIQ_PERMS)
if (opts.dump & DUMP_DFA_MIN_UNIQ_PERMS)
dfa.dump_uniq_perms("minimized dfa");
}
if (opts.dfaflags & CONTROL_DFA_REMOVE_UNREACHABLE)
if (opts.control & CONTROL_DFA_REMOVE_UNREACHABLE)
dfa.remove_unreachable(opts);
if (opts.dfadump & DUMP_DFA_STATES)
if (opts.dump & DUMP_DFA_STATES)
dfa.dump(cerr);
if (opts.dfadump & DUMP_DFA_GRAPH)
if (opts.dump & DUMP_DFA_GRAPH)
dfa.dump_dot_graph(cerr);
map<transchar, transchar> eq;
if (opts.dfaflags & CONTROL_DFA_EQUIV) {
if (opts.control & CONTROL_DFA_EQUIV) {
eq = dfa.equivalence_classes(opts);
dfa.apply_equivalence_classes(eq);
if (opts.dfadump & DUMP_DFA_EQUIV) {
if (opts.dump & DUMP_DFA_EQUIV) {
cerr << "\nDFA equivalence class\n";
dump_equivalence_classes(cerr, eq);
}
} else if (opts.dfadump & DUMP_DFA_EQUIV)
} else if (opts.dump & DUMP_DFA_EQUIV)
cerr << "\nDFA did not generate an equivalence class\n";
if (opts.dfaflags & CONTROL_DFA_DIFF_ENCODE) {
if (opts.control & CONTROL_DFA_DIFF_ENCODE) {
dfa.diff_encode(opts);
if (opts.dfadump & DUMP_DFA_DIFF_ENCODE)
if (opts.dump & DUMP_DFA_DIFF_ENCODE)
dfa.dump_diff_encode(cerr);
}
CHFA chfa(dfa, eq, opts);
if (opts.dfadump & DUMP_DFA_TRANS_TABLE)
if (opts.dump & DUMP_DFA_TRANS_TABLE)
chfa.dump(cerr);
chfa.flex_table(stream, "");
}

View file

@ -30,6 +30,8 @@
#define CONTROL_DFA_REMOVE_UNREACHABLE (1 << 7)
#define CONTROL_DFA_TRANS_HIGH (1 << 8)
#define CONTROL_DFA_DIFF_ENCODE (1 << 9)
#define CONTROL_RULE_MERGE (1 << 10)
#define DUMP_DFA_DIFF_PROGRESS (1 << 0)
#define DUMP_DFA_DIFF_ENCODE (1 << 1)
@ -53,5 +55,6 @@
#define DUMP_DFA_UNREACHABLE (1 << 19)
#define DUMP_DFA_RULE_EXPR (1 << 20)
#define DUMP_DFA_NODE_TO_DFA (1 << 21)
#define DUMP_RULE_MERGE (1 << 22)
#endif /* APPARMOR_RE_H */

View file

@ -52,7 +52,7 @@ void CHFA::init_free_list(vector<pair<size_t, size_t> > &free_list,
CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
eq(eq)
{
if (opts.dfadump & DUMP_DFA_TRANS_PROGRESS)
if (opts.dump & DUMP_DFA_TRANS_PROGRESS)
fprintf(stderr, "Compressing HFA:\r");
chfaflags = 0;
@ -83,7 +83,7 @@ CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
if (*i == dfa.start || *i == dfa.nonmatching)
continue;
optimal += (*i)->trans.size();
if (opts.dfaflags & CONTROL_DFA_TRANS_HIGH) {
if (opts.control & CONTROL_DFA_TRANS_HIGH) {
size_t range = 0;
if ((*i)->trans.size())
range =
@ -117,7 +117,7 @@ CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
int count = 2;
if (!(opts.dfaflags & CONTROL_DFA_TRANS_HIGH)) {
if (!(opts.control & CONTROL_DFA_TRANS_HIGH)) {
for (Partition::iterator i = dfa.states.begin(); i != dfa.states.end(); i++) {
if (*i != dfa.nonmatching && *i != dfa.start) {
insert_state(free_list, *i, dfa);
@ -125,7 +125,7 @@ CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
accept2[num.size()] = PACK_AUDIT_CTL((*i)->perms.audit, (*i)->perms.quiet & (*i)->perms.deny);
num.insert(make_pair(*i, num.size()));
}
if (opts.dfadump & (DUMP_DFA_TRANS_PROGRESS)) {
if (opts.dump & (DUMP_DFA_TRANS_PROGRESS)) {
count++;
if (count % 100 == 0)
fprintf(stderr, "\033[2KCompressing trans table: insert state: %d/%zd\r",
@ -142,7 +142,7 @@ CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
accept2[num.size()] = PACK_AUDIT_CTL(i->second->perms.audit, i->second->perms.quiet & i->second->perms.deny);
num.insert(make_pair(i->second, num.size()));
}
if (opts.dfadump & (DUMP_DFA_TRANS_PROGRESS)) {
if (opts.dump & (DUMP_DFA_TRANS_PROGRESS)) {
count++;
if (count % 100 == 0)
fprintf(stderr, "\033[2KCompressing trans table: insert state: %d/%zd\r",
@ -151,7 +151,7 @@ CHFA::CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts):
}
}
if (opts.dfadump & (DUMP_DFA_TRANS_STATS | DUMP_DFA_TRANS_PROGRESS)) {
if (opts.dump & (DUMP_DFA_TRANS_STATS | DUMP_DFA_TRANS_PROGRESS)) {
ssize_t size = 4 * next_check.size() + 6 * dfa.states.size();
fprintf(stderr, "\033[2KCompressed trans table: states %zd, next/check %zd, optimal next/check %zd avg/state %.2f, compression %zd/%zd = %.2f %%\n",
dfa.states.size(), next_check.size(), optimal,

View file

@ -580,7 +580,7 @@ Node *simplify_tree(Node *t, optflags const &opts)
bool update = true;
int i;
if (opts.dfadump & DUMP_DFA_TREE_STATS) {
if (opts.dump & DUMP_DFA_TREE_STATS) {
struct node_counts counts = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
count_tree_nodes(t, &counts);
fprintf(stderr,
@ -598,25 +598,25 @@ Node *simplify_tree(Node *t, optflags const &opts)
// the dfa having about 7 thousands states,
// and it having about 1.25 million states
int dir = 1;
if (opts.dfaflags & CONTROL_DFA_TREE_LEFT)
if (opts.control & CONTROL_DFA_TREE_LEFT)
dir = 0;
for (int count = 0; count < 2; count++) {
bool modified;
do {
modified = false;
if (opts.dfaflags & CONTROL_DFA_TREE_NORMAL)
if (opts.control & CONTROL_DFA_TREE_NORMAL)
t->normalize(dir);
t = simplify_tree_base(t, dir, modified);
if (modified)
update = true;
} while (modified);
if (opts.dfaflags & CONTROL_DFA_TREE_LEFT)
if (opts.control & CONTROL_DFA_TREE_LEFT)
dir++;
else
dir--;
}
}
if (opts.dfadump & DUMP_DFA_TREE_STATS) {
if (opts.dump & DUMP_DFA_TREE_STATS) {
struct node_counts counts = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
count_tree_nodes(t, &counts);
fprintf(stderr,

View file

@ -396,7 +396,7 @@ void DFA::process_work_queue(const char *header, optflags const &opts)
int i = 0;
while (!work_queue.empty()) {
if (i % 1000 == 0 && (opts.dfadump & DUMP_DFA_PROGRESS)) {
if (i % 1000 == 0 && (opts.dump & DUMP_DFA_PROGRESS)) {
cerr << "\033[2K" << header << ": queue "
<< work_queue.size()
<< "\tstates "
@ -428,7 +428,7 @@ DFA::DFA(Node *root, optflags const &opts, bool buildfiledfa): root(root), filed
oob_range = 0;
ord_range = 8;
if (opts.dfadump & DUMP_DFA_PROGRESS)
if (opts.dump & DUMP_DFA_PROGRESS)
fprintf(stderr, "Creating dfa:\r");
for (depth_first_traversal i(root); i; i++) {
@ -437,7 +437,7 @@ DFA::DFA(Node *root, optflags const &opts, bool buildfiledfa): root(root), filed
(*i)->compute_lastpos();
}
if (opts.dfadump & DUMP_DFA_PROGRESS)
if (opts.dump & DUMP_DFA_PROGRESS)
fprintf(stderr, "Creating dfa: followpos\r");
for (depth_first_traversal i(root); i; i++) {
(*i)->compute_followpos();
@ -471,10 +471,10 @@ DFA::DFA(Node *root, optflags const &opts, bool buildfiledfa): root(root), filed
(*i)->followpos.clear();
}
if (opts.dfadump & DUMP_DFA_NODE_TO_DFA)
if (opts.dump & DUMP_DFA_NODE_TO_DFA)
dump_node_to_dfa();
if (opts.dfadump & (DUMP_DFA_STATS)) {
if (opts.dump & (DUMP_DFA_STATS)) {
cerr << "\033[2KCreated dfa: states "
<< states.size()
<< " proto { "
@ -571,7 +571,7 @@ void DFA::remove_unreachable(optflags const &opts)
next = i;
next++;
if (reachable.find(*i) == reachable.end()) {
if (opts.dfadump & DUMP_DFA_UNREACHABLE) {
if (opts.dump & DUMP_DFA_UNREACHABLE) {
cerr << "unreachable: " << **i;
if (*i == start)
cerr << " <==";
@ -586,7 +586,7 @@ void DFA::remove_unreachable(optflags const &opts)
}
}
if (count && (opts.dfadump & DUMP_DFA_STATS))
if (count && (opts.dump & DUMP_DFA_STATS))
cerr << "DFA: states " << states.size() << " removed "
<< count << " unreachable states\n";
}
@ -680,7 +680,7 @@ void DFA::minimize(optflags const &opts)
p->second->push_back(*i);
}
if ((opts.dfadump & DUMP_DFA_PROGRESS) && (partitions.size() % 1000 == 0))
if ((opts.dump & DUMP_DFA_PROGRESS) && (partitions.size() % 1000 == 0))
cerr << "\033[2KMinimize dfa: partitions "
<< partitions.size() << "\tinit " << partitions.size()
<< " (accept " << accept_count << ")\r";
@ -692,7 +692,7 @@ void DFA::minimize(optflags const &opts)
perm_map.clear();
int init_count = partitions.size();
if (opts.dfadump & DUMP_DFA_PROGRESS)
if (opts.dump & DUMP_DFA_PROGRESS)
cerr << "\033[2KMinimize dfa: partitions " << partitions.size()
<< "\tinit " << init_count << " (accept "
<< accept_count << ")\r";
@ -734,7 +734,7 @@ void DFA::minimize(optflags const &opts)
(*m)->partition = new_part;
}
}
if ((opts.dfadump & DUMP_DFA_PROGRESS) && (partitions.size() % 100 == 0))
if ((opts.dump & DUMP_DFA_PROGRESS) && (partitions.size() % 100 == 0))
cerr << "\033[2KMinimize dfa: partitions "
<< partitions.size() << "\tinit "
<< init_count << " (accept "
@ -743,7 +743,7 @@ void DFA::minimize(optflags const &opts)
} while (new_part_count);
if (partitions.size() == states.size()) {
if (opts.dfadump & DUMP_DFA_STATS)
if (opts.dump & DUMP_DFA_STATS)
cerr << "\033[2KDfa minimization no states removed: partitions "
<< partitions.size() << "\tinit " << init_count
<< " (accept " << accept_count << ")\n";
@ -757,13 +757,13 @@ void DFA::minimize(optflags const &opts)
* to states within the same partitions, however this can slow
* down compressed dfa compression as there are more states,
*/
if (opts.dfadump & DUMP_DFA_MIN_PARTS)
if (opts.dump & DUMP_DFA_MIN_PARTS)
cerr << "Partitions after minimization\n";
for (list<Partition *>::iterator p = partitions.begin();
p != partitions.end(); p++) {
/* representative state for this partition */
State *rep = *((*p)->begin());
if (opts.dfadump & DUMP_DFA_MIN_PARTS)
if (opts.dump & DUMP_DFA_MIN_PARTS)
cerr << *rep << " : ";
/* update representative state's transitions */
@ -782,17 +782,17 @@ void DFA::minimize(optflags const &opts)
/* clear the state label for all non representative states,
* and accumulate permissions */
for (Partition::iterator i = ++(*p)->begin(); i != (*p)->end(); i++) {
if (opts.dfadump & DUMP_DFA_MIN_PARTS)
if (opts.dump & DUMP_DFA_MIN_PARTS)
cerr << **i << ", ";
(*i)->label = -1;
rep->perms.add((*i)->perms, filedfa);
}
if (rep->perms.is_accept())
final_accept++;
if (opts.dfadump & DUMP_DFA_MIN_PARTS)
if (opts.dump & DUMP_DFA_MIN_PARTS)
cerr << "\n";
}
if (opts.dfadump & DUMP_DFA_STATS)
if (opts.dump & DUMP_DFA_STATS)
cerr << "\033[2KMinimized dfa: final partitions "
<< partitions.size() << " (accept " << final_accept
<< ")" << "\tinit " << init_count << " (accept "
@ -965,7 +965,7 @@ void DFA::diff_encode(optflags const &opts)
}
}
if ((opts.dfadump & DUMP_DFA_DIFF_PROGRESS) && (i % 100 == 0))
if ((opts.dump & DUMP_DFA_DIFF_PROGRESS) && (i % 100 == 0))
cerr << "\033[2KDiff Encode: " << i << " of "
<< tail << ". Diff states " << xcount
<< " Savings " << xweight << "\r";
@ -992,7 +992,7 @@ void DFA::diff_encode(optflags const &opts)
}
}
if (opts.dfadump & DUMP_DFA_DIFF_STATS)
if (opts.dump & DUMP_DFA_DIFF_STATS)
cerr << "Diff encode states: " << diffcount << " of "
<< tail << " reached @ depth " << depth << ". "
<< aweight << " trans removed\n";
@ -1251,7 +1251,7 @@ map<transchar, transchar> DFA::equivalence_classes(optflags const &opts)
}
}
if (opts.dfadump & DUMP_DFA_EQUIV_STATS)
if (opts.dump & DUMP_DFA_EQUIV_STATS)
fprintf(stderr, "Equiv class reduces to %d classes\n",
next_class.c - 1);
return classes;

View file

@ -83,9 +83,6 @@ extern int parser_token;
WARN_OVERRIDE | WARN_INCLUDE)
#define CONTROL_RULE_MERGE 0x1
#define DUMP_RULE_MERGE 0x1
typedef enum pattern_t pattern_t;

View file

@ -100,10 +100,8 @@ FILE *ofile = NULL;
IncludeCache_t *g_includecache;
optflags parseopts = {
.dfaflags = (optflags_t)(CONTROL_DFA_TREE_NORMAL | CONTROL_DFA_TREE_SIMPLE | CONTROL_DFA_MINIMIZE | CONTROL_DFA_DIFF_ENCODE),
.dfadump = 0,
.frontflags = (optflags_t)(CONTROL_RULE_MERGE),
.frontdump = 0,
.control = (optflags_t)(CONTROL_DFA_TREE_NORMAL | CONTROL_DFA_TREE_SIMPLE | CONTROL_DFA_MINIMIZE | CONTROL_DFA_DIFF_ENCODE | CONTROL_RULE_MERGE),
.dump = 0,
.warn = DEFAULT_WARNINGS,
.Werror = 0
};

View file

@ -277,15 +277,6 @@ optflag_table_t warnflag_table[] = {
{ 0, NULL, NULL, 0 },
};
optflag_table_t frontopts_table[] = {
{ 1, "rule-merge", "turn on rule merging", CONTROL_RULE_MERGE},
{ 0, NULL, NULL, 0 },
};
optflag_table_t frontdump_table[] = {
{ 1, "rule-merge", "dump information about rule merging", DUMP_RULE_MERGE},
{ 0, NULL, NULL, 0 },
};
/* Parse comma separated cachelocations. Commas can be escaped by \, */
static int parse_cacheloc(const char *arg, const char **cacheloc, int max_size)
@ -506,14 +497,11 @@ static int process_arg(int c, char *optarg)
strcmp(optarg, "dump") == 0 ||
strcmp(optarg, "D") == 0) {
flagtable_help("--dump=", DUMP_HEADER, progname,
dfadumpflag_table);
flagtable_help("--dump=", DUMP_HEADER, progname,
frontopts_table);
dumpflag_table);
} else if (strcmp(optarg, "Optimize") == 0 ||
strcmp(optarg, "optimize") == 0 ||
strcmp(optarg, "O") == 0) {
flagtable_help("-O ", "", progname, dfaoptflag_table);
flagtable_help("-O ", "", progname, frontopts_table);
} else if (strcmp(optarg, "warn") == 0) {
flagtable_help("--warn=", "", progname, warnflag_table);
} else if (strcmp(optarg, "Werror") == 0) {
@ -584,16 +572,13 @@ static int process_arg(int c, char *optarg)
if (!optarg) {
dump_vars = 1;
} else if (strcmp(optarg, "show") == 0) {
print_flags("dump", dfadumpflag_table, parseopts.dfadump);
print_flags("dump", frontdump_table, parseopts.frontdump);
print_flags("dump", dumpflag_table, parseopts.dump);
} else if (strcmp(optarg, "variables") == 0) {
dump_vars = 1;
} else if (strcmp(optarg, "expanded-variables") == 0) {
dump_expanded_vars = 1;
} else if (!handle_flag_table(dfadumpflag_table, optarg,
&parseopts.dfadump) &&
!handle_flag_table(frontdump_table, optarg,
&parseopts.frontdump)) {
} else if (!handle_flag_table(dumpflag_table, optarg,
&parseopts.dump)) {
PERROR("%s: Invalid --Dump option %s\n",
progname, optarg);
exit(1);
@ -601,12 +586,9 @@ static int process_arg(int c, char *optarg)
break;
case 'O':
if (strcmp(optarg, "show") == 0) {
print_flags("Optimize", dfaoptflag_table, parseopts.dfaflags);
print_flags("Optimize", frontopts_table, parseopts.frontflags);
print_flags("Optimize", dfaoptflag_table, parseopts.control);
} else if (!handle_flag_table(dfaoptflag_table, optarg,
&parseopts.dfaflags) &&
!handle_flag_table(frontopts_table, optarg,
&parseopts.frontflags)) {
&parseopts.control)) {
PERROR("%s: Invalid --Optimize option %s\n",
progname, optarg);
exit(1);
@ -1552,7 +1534,7 @@ static bool get_kernel_features(struct aa_features **features)
if (!kernel_supports_diff_encode)
/* clear diff_encode because it is not supported */
parseopts.dfaflags &= ~CONTROL_DFA_DIFF_ENCODE;
parseopts.control &= ~CONTROL_DFA_DIFF_ENCODE;
return true;
}

View file

@ -111,7 +111,7 @@ static int process_file_entries(Profile *prof)
int profile_merge_rules(Profile *prof)
{
if (!(parseopts.frontflags & CONTROL_RULE_MERGE))
if (!(parseopts.control & CONTROL_RULE_MERGE))
return 0;
int res, tmp = process_file_entries(prof);
@ -120,7 +120,7 @@ int profile_merge_rules(Profile *prof)
res = prof->merge_rules();
if (res < 0)
return -res;
if (parseopts.frontdump & DUMP_RULE_MERGE)
if (parseopts.dump & DUMP_RULE_MERGE)
fprintf(stderr, "RULE MERGE: deleted %d file rules, %d rules\n", tmp, res);
return 0;
}

View file

@ -128,7 +128,7 @@ pattern_t convert_aaregex_to_pcre(const char *aare, int anchor, int glob,
sptr = aare;
if (parseopts.dfadump & DUMP_DFA_RULE_EXPR)
if (parseopts.dump & DUMP_DFA_RULE_EXPR)
fprintf(stderr, "aare: %s -> ", aare);
if (anchor)
@ -427,7 +427,7 @@ out:
if (ret == FALSE)
ptype = ePatternInvalid;
if (parseopts.dfadump & DUMP_DFA_RULE_EXPR)
if (parseopts.dump & DUMP_DFA_RULE_EXPR)
fprintf(stderr, "%s\n", pcre.c_str());
return ptype;