[apparmor] [PATCH v2 35/42] parser: Don't use gettext(3) in code that will be moved to libapparmor

Tyler Hicks tyhicks at canonical.com
Fri Mar 6 21:48:51 UTC 2015


Remove the use of the "_" macro, which translates into gettext(3), from
code that will be used from the parser to libapparmor since libapparmor
will not support gettext(3) for debug messages and syslog messages.

Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---
 parser/features.c     |  9 +++------
 parser/policy_cache.c | 13 +++++--------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/parser/features.c b/parser/features.c
index d0153ad..8b9844f 100644
--- a/parser/features.c
+++ b/parser/features.c
@@ -26,9 +26,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <libintl.h>
-#include <locale.h>
-#define _(s) gettext(s)
 
 #include "features.h"
 #include "lib.h"
@@ -56,7 +53,7 @@ static int features_snprintf(struct features_struct *fst, const char *fmt, ...)
 
 	if (remaining < 0) {
 		errno = EINVAL;
-		PERROR(_("Invalid features buffer offset\n"));
+		PERROR("Invalid features buffer offset\n");
 		return -1;
 	}
 
@@ -66,11 +63,11 @@ static int features_snprintf(struct features_struct *fst, const char *fmt, ...)
 
 	if (i < 0) {
 		errno = EIO;
-		PERROR(_("Failed to write to features buffer\n"));
+		PERROR("Failed to write to features buffer\n");
 		return -1;
 	} else if (i >= remaining) {
 		errno = ENOBUFS;
-		PERROR(_("Feature buffer full."));
+		PERROR("Feature buffer full.");
 		return -1;
 	}
 
diff --git a/parser/policy_cache.c b/parser/policy_cache.c
index ec73cc4..35dc235 100644
--- a/parser/policy_cache.c
+++ b/parser/policy_cache.c
@@ -18,8 +18,6 @@
 
 #include <ctype.h>
 #include <dirent.h>
-#include <libintl.h>
-#include <locale.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -27,7 +25,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#define _(s) gettext(s)
 
 #include "lib.h"
 #include "parser.h"
@@ -50,7 +47,7 @@ bool valid_cached_file_version(const char *cachename)
 	char buffer[16];
 	autofclose FILE *f;
 	if (!(f = fopen(cachename, "r"))) {
-		PERROR(_("Error: Could not read cache file '%s', skipping...\n"), cachename);
+		PERROR("Error: Could not read cache file '%s', skipping...\n", cachename);
 		return false;
 	}
 	size_t res = fread(buffer, 1, 16, f);
@@ -133,15 +130,15 @@ error:
 		if (mkdir(policy_cache->path, 0700) == 0)
 			goto create_file;
 		if (show_cache)
-			PERROR(_("Can't create cache directory: %s\n"),
+			PERROR("Can't create cache directory: %s\n",
 			       policy_cache->path);
 	} else if (!S_ISDIR(stat_file.st_mode)) {
 		if (show_cache)
-			PERROR(_("File in cache directory location: %s\n"),
+			PERROR("File in cache directory location: %s\n",
 			       policy_cache->path);
 	} else {
 		if (show_cache)
-			PERROR(_("Can't update cache directory: %s\n"),
+			PERROR("Can't update cache directory: %s\n",
 			       policy_cache->path);
 	}
 
@@ -158,7 +155,7 @@ char *cache_filename(const char *cachedir, const char *basename)
 	char *cachename;
 
 	if (asprintf(&cachename, "%s/%s", cachedir, basename) < 0) {
-		PERROR(_("Memory allocation error."));
+		PERROR("Memory allocation error.");
 		exit(1);
 	}
 
-- 
2.1.4




More information about the AppArmor mailing list