mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: fix --warn and --Werror so they work with --config-file
--config-file is processed early in a separate argument processing pass. Adjust --warn and --Werror processing so they are done in both the early and late arg processing pass. --warn and --Werror must be run in both argument processing passes so that 1. They can be used with --config-file as long as they are specified before --config-file (early pass) 2. They are not overriden by any flags set in the config file, as command line options take priority over what is in the config file (hence the need for reprocessing in the second pass) MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/600 Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
3d7cfb29f9
commit
dadc39507b
1 changed files with 15 additions and 5 deletions
|
@ -413,14 +413,24 @@ static long process_jobs_arg(const char *arg, const char *val) {
|
|||
return n;
|
||||
}
|
||||
|
||||
#define EARLY_ARG 1
|
||||
#define LATE_ARG 2
|
||||
#define TWOPASS_ARG (EARLY_ARG | LATE_ARG)
|
||||
|
||||
bool early_arg(int c) {
|
||||
int arg_pass(int c) {
|
||||
switch(c) {
|
||||
case EARLY_ARG_CONFIG_FILE:
|
||||
return true;
|
||||
return EARLY_ARG;
|
||||
break;
|
||||
case ARG_WARN:
|
||||
return TWOPASS_ARG;
|
||||
break;
|
||||
case ARG_WERROR:
|
||||
return TWOPASS_ARG;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
return LATE_ARG;
|
||||
}
|
||||
|
||||
/* process a single argment from getopt_long
|
||||
|
@ -753,7 +763,7 @@ static void process_early_args(int argc, char *argv[])
|
|||
|
||||
while ((c = getopt_long(argc, argv, short_options, long_options, &o)) != -1)
|
||||
{
|
||||
if (early_arg(c))
|
||||
if (arg_pass(c) & EARLY_ARG)
|
||||
process_arg(c, optarg);
|
||||
}
|
||||
|
||||
|
@ -770,7 +780,7 @@ static int process_args(int argc, char *argv[])
|
|||
opterr = 1;
|
||||
while ((c = getopt_long(argc, argv, short_options, long_options, &o)) != -1)
|
||||
{
|
||||
if (!early_arg(c))
|
||||
if (arg_pass(c) & LATE_ARG)
|
||||
count += process_arg(c, optarg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue