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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user