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

parser: replace duplicate warn_once() with common function

The warn_once() function is duplicated in 6 different places. A common,
reusable version has been added to parser_common.c.

Signed-off-by: Mike Salvatore <mike.salvatore@canonical.com>
This commit is contained in:
Mike Salvatore
2020-08-09 14:51:55 -04:00
parent 4aabc40d1f
commit 52d9529d1b
15 changed files with 57 additions and 87 deletions

View File

@@ -15,6 +15,7 @@
* along with this program; if not, contact Novell, Inc. or Canonical,
* Ltd.
*/
#include <iostream>
#include <stdlib.h>
#include <stdarg.h>
@@ -120,3 +121,17 @@ void pwarn(const char *fmt, ...)
free(newfmt);
}
/* do we want to warn once/profile or just once per compile?? */
void common_warn_once(const char *name, const char *msg, const char **warned_name)
{
if ((warnflags & WARN_RULE_NOT_ENFORCED) && *warned_name != name) {
cerr << "Warning from profile " << name << " (";
if (current_filename)
cerr << current_filename;
else
cerr << "stdin";
cerr << "): " << msg << "\n";
*warned_name = name;
}
}