mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
parser: cleanup and rework optimization and dump flag handling
In preparation for more flags (not all of the backend dfa based), rework the optimization and dump flag handling which has been exclusively around the dfa up to this point. - split dfa control and dump flags into separate fields. This gives more room for new flags in the existing DFA set - rename DFA_DUMP, and DFA_CONTROL to CONTROL_DFA and DUMP_DFA as this will provide more uniform naming for none dfa flags - group dump and control flags into a structure so they can be passed together. Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -493,11 +493,11 @@ static int process_arg(int c, char *optarg)
|
||||
strcmp(optarg, "dump") == 0 ||
|
||||
strcmp(optarg, "D") == 0) {
|
||||
flagtable_help("--dump=", DUMP_HEADER, progname,
|
||||
dumpflag_table);
|
||||
dfadumpflag_table);
|
||||
} else if (strcmp(optarg, "Optimize") == 0 ||
|
||||
strcmp(optarg, "optimize") == 0 ||
|
||||
strcmp(optarg, "O") == 0) {
|
||||
flagtable_help("-O ", "", progname, optflag_table);
|
||||
flagtable_help("-O ", "", progname, dfaoptflag_table);
|
||||
} else if (strcmp(optarg, "warn") == 0) {
|
||||
flagtable_help("--warn=", "", progname, warnflag_table);
|
||||
} else if (strcmp(optarg, "Werror") == 0) {
|
||||
@@ -568,13 +568,13 @@ static int process_arg(int c, char *optarg)
|
||||
if (!optarg) {
|
||||
dump_vars = 1;
|
||||
} else if (strcmp(optarg, "show") == 0) {
|
||||
print_flags("dump", dumpflag_table, dfaflags);
|
||||
print_flags("dump", dfadumpflag_table, parseopts.dfadump);
|
||||
} 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(dumpflag_table, optarg,
|
||||
&dfaflags)) {
|
||||
} else if (!handle_flag_table(dfadumpflag_table, optarg,
|
||||
&parseopts.dfadump)) {
|
||||
PERROR("%s: Invalid --Dump option %s\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
@@ -582,9 +582,9 @@ static int process_arg(int c, char *optarg)
|
||||
break;
|
||||
case 'O':
|
||||
if (strcmp(optarg, "show") == 0) {
|
||||
print_flags("Optimize", optflag_table, dfaflags);
|
||||
} else if (!handle_flag_table(optflag_table, optarg,
|
||||
&dfaflags)) {
|
||||
print_flags("Optimize", dfaoptflag_table, parseopts.dfaflags);
|
||||
} else if (!handle_flag_table(dfaoptflag_table, optarg,
|
||||
&parseopts.dfaflags)) {
|
||||
PERROR("%s: Invalid --Optimize option %s\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
@@ -665,7 +665,7 @@ static int process_arg(int c, char *optarg)
|
||||
case 'q':
|
||||
conf_verbose = 0;
|
||||
conf_quiet = 1;
|
||||
warnflags = 0;
|
||||
parseopts.warn = 0;
|
||||
break;
|
||||
case 'v':
|
||||
conf_verbose = 1;
|
||||
@@ -723,9 +723,9 @@ static int process_arg(int c, char *optarg)
|
||||
break;
|
||||
case ARG_WARN:
|
||||
if (strcmp(optarg, "show") == 0) {
|
||||
print_flags("warn", warnflag_table, warnflags);
|
||||
print_flags("warn", warnflag_table, parseopts.warn);
|
||||
} else if (!handle_flag_table(warnflag_table, optarg,
|
||||
&warnflags)) {
|
||||
&parseopts.warn)) {
|
||||
PERROR("%s: Invalid --warn option %s\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
@@ -733,18 +733,18 @@ static int process_arg(int c, char *optarg)
|
||||
break;
|
||||
case ARG_WERROR:
|
||||
if (!optarg) {
|
||||
werrflags = -1;
|
||||
parseopts.Werror = -1;
|
||||
} else if (strcmp(optarg, "show") == 0) {
|
||||
print_flags("Werror", warnflag_table, werrflags);
|
||||
print_flags("Werror", warnflag_table, parseopts.Werror);
|
||||
} else if (optarg && !handle_flag_table(warnflag_table, optarg,
|
||||
&werrflags)) {
|
||||
&parseopts.Werror)) {
|
||||
PERROR("%s: Invalid --Werror option %s\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case ARG_DEBUG_CACHE:
|
||||
warnflags |= WARN_DEBUG_CACHE;
|
||||
parseopts.warn |= WARN_DEBUG_CACHE;
|
||||
break;
|
||||
case 'j':
|
||||
jobs = process_jobs_arg("-j", optarg);
|
||||
@@ -1530,7 +1530,7 @@ static bool get_kernel_features(struct aa_features **features)
|
||||
|
||||
if (!kernel_supports_diff_encode)
|
||||
/* clear diff_encode because it is not supported */
|
||||
dfaflags &= ~DFA_CONTROL_DIFF_ENCODE;
|
||||
parseopts.dfaflags &= ~CONTROL_DFA_DIFF_ENCODE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user