2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 14:25:52 +00:00

parser: convert remaining pwarn() to flag controlled warns

Make all warnings that go through pwarn() controllable by warning
flags. This adds several new warning control flags, documented in

  --help=warn

Convert --debug-cache to be unified with warning flags. So it can be
set by either
    --debug-cache
  or
    --warn=debug-cache

Also add an "all" option to be able to turn on all warnings.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/600
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen
2020-08-28 08:35:45 -07:00
parent d50ada7159
commit f5c4927c85
8 changed files with 69 additions and 46 deletions

View File

@@ -52,11 +52,31 @@ class rule_t;
extern int parser_token;
#define WARN_RULE_NOT_ENFORCED 1
#define WARN_RULE_DOWNGRADED 2
#define WARN_ABI 4
#define WARN_DEPRECATED 8
#define WARN_DEV (WARN_RULE_NOT_ENFORCED | WARN_RULE_DOWNGRADED | WARN_ABI | WARN_DEPRECATED)
#define WARN_RULE_NOT_ENFORCED 0x1
#define WARN_RULE_DOWNGRADED 0x2
#define WARN_ABI 0x4
#define WARN_DEPRECATED 0x8
#define WARN_CONFIG 0x10
#define WARN_CACHE 0x20
#define WARN_DEBUG_CACHE 0x40
#define WARN_JOBS 0x80
#define WARN_DANGEROUS 0x100
#define WARN_UNEXPECTED 0x200
#define WARN_FORMAT 0x400
#define WARN_MISSING 0x800
#define WARN_OVERRIDE 0x1000
#define WARN_DEV (WARN_RULE_NOT_ENFORCED | WARN_RULE_DOWNGRADED | WARN_ABI | \
WARN_DEPRECATED | WARN_DANGEROUS | WARN_UNEXPECTED | \
WARN_FORMAT | WARN_MISSING | WARN_OVERRIDE | WARN_DEBUG_CACHE)
#define DEFAULT_WARNINGS (WARN_CONFIG | WARN_CACHE | WARN_JOBS | \
WARN_UNEXPECTED | WARN_OVERRIDE)
#define WARN_ALL (WARN_RULE_NOT_ENFORCED | WARN_RULE_DOWNGRADED | WARN_ABI | \
WARN_DEPRECATED | WARN_CONFIG | WARN_CACHE | \
WARN_DEBUG_CACHE | WARN_JOBS | WARN_DANGEROUS | \
WARN_UNEXPECTED | WARN_FORMAT | WARN_MISSING | WARN_OVERRIDE)
extern dfaflags_t warnflags;
@@ -331,10 +351,10 @@ extern char *profile_ns;
extern char *current_filename;
extern FILE *ofile;
extern int read_implies_exec;
extern void pwarn(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
extern void pwarnf(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
extern void common_warn_once(const char *name, const char *msg, const char **warned_name);
#define pwarn_onflag(F, args...) do { if (warnflags & (F)) pwarn(args); } while (0)
#define pwarn(F, args...) do { if (warnflags & (F)) pwarnf(args); } while (0)
/* from parser_main (cannot be used in tst builds) */
extern int force_complain;