[apparmor] [PATCH 2/4] libapparmor: Store the string len instead of calling strlen() twice

Tyler Hicks tyhicks at canonical.com
Tue Jun 16 00:33:14 UTC 2015


Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---
 libraries/libapparmor/src/private.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libraries/libapparmor/src/private.c b/libraries/libapparmor/src/private.c
index d237a0d..abe4017 100644
--- a/libraries/libapparmor/src/private.c
+++ b/libraries/libapparmor/src/private.c
@@ -109,14 +109,13 @@ bool atomic_dec_and_test(unsigned int *v)
 
 int _aa_is_blacklisted(const char *name, const char *path)
 {
-	int name_len;
+	size_t name_len = strlen(name);
 	struct ignored_suffix_t *suffix;
 
 	/* skip dot files and files with no name */
-	if (!strlen(name) || *name == '.')
+	if (!name_len || *name == '.')
 		return 1;
 
-	name_len = strlen(name);
 	/* skip blacklisted suffixes */
 	for (suffix = ignored_suffixes; suffix->text; suffix++) {
 		char *found;
-- 
2.1.4




More information about the AppArmor mailing list