Skip to contentSkip to conversation

policycoreutils: s/int/bool/ and use null character

PATCH In review Kalevi Kolttonen 2 participants 5 messages Jun 14 – Jun 15 SELinux security module

lore
Share & tools
lore
#0 lore raw

cover policycoreutils: s/int/bool/ and use null character

Use bool instead of int. Use null character in a string.

Kalevi Kolttonen (2):
policycoreutils: use null character in a string
policycoreutils: use bool instead of int

 policycoreutils/setfiles/setfiles.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 policycoreutils: use null character in a string

---
 policycoreutils/setfiles/setfiles.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
policycoreutils/setfiles/setfiles.c +1 -1
index 9016db5f..656848e3 100644
@@ -454,7 +454,7 @@ int main(int argc, char **argv)
 
 		delim = (null_terminated != 0) ? '\0' : '\n';
 		while ((len = getdelim(&buf, &buf_len, delim, f)) > 0) {
-			buf[len - 1] = 0;
+			buf[len - 1] = '\0';
 			if (!strcmp(buf, "/"))
 				r_opts.mass_relabel =
 					SELINUX_RESTORECON_MASS_RELABEL;
Signature · 1 line
2.54.0
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] policycoreutils: use null character in a string

Quoted 2 lines · Kalevi Kolttonen
Quoted 21 lines
---
 policycoreutils/setfiles/setfiles.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
policycoreutils/setfiles/setfiles.c +1 -2
index 9016db5f..656848e3 100644
@@ -454,7 +454,7 @@ int main(int argc, char **argv)
 
                delim = (null_terminated != 0) ? '\0' : '\n';
                while ((len = getdelim(&buf, &buf_len, delim, f)) > 0) {
-                       buf[len - 1] = 0;
+                       buf[len - 1] = '\0';
                        if (!strcmp(buf, "/"))
                                r_opts.mass_relabel =
                                        SELINUX_RESTORECON_MASS_RELABEL;
--

2.54.0

#3 lore raw

PATCH 2/2 policycoreutils: use bool instead of int

In reply to Kalevi Kolttonen
---
 policycoreutils/setfiles/setfiles.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
policycoreutils/setfiles/setfiles.c +4 -3
index 656848e3..2d38ea8f 100644
@@ -1,4 +1,5 @@
 #include "restore.h"
+#include <stdbool.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -23,7 +24,7 @@ static struct restore_opts r_opts;
 
 #define SETFILES "setfiles"
 #define RESTORECON "restorecon"
-static int iamrestorecon;
+static bool iamrestorecon;
 
 /* Behavior flags determined based on setfiles vs. restorecon */
 static int ctx_validate; /* Validate contexts */
@@ -181,7 +182,7 @@ int main(int argc, char **argv)
 		 * Does not follow mounts (sets SELINUX_RESTORECON_XDEV),
 		 * Validates all file contexts at init time.
 		 */
-		iamrestorecon = 0;
+		iamrestorecon = false;
 		r_opts.recurse = SELINUX_RESTORECON_RECURSE;
 		r_opts.userealpath = 0; /* SELINUX_RESTORECON_REALPATH */
 		r_opts.add_assoc = SELINUX_RESTORECON_ADD_ASSOC;
@@ -204,7 +205,7 @@ int main(int argc, char **argv)
 				"Executed with unrecognized name (%s), defaulting to %s behavior.\n",
 				base, RESTORECON);
 
-		iamrestorecon = 1;
+		iamrestorecon = true;
 		r_opts.recurse = 0;
 		r_opts.userealpath = SELINUX_RESTORECON_REALPATH;
 		r_opts.add_assoc = 0;
Signature · 1 line
2.54.0
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] policycoreutils: use bool instead of int

Quoted 2 lines · Kalevi Kolttonen
Quoted 45 lines
---
 policycoreutils/setfiles/setfiles.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
policycoreutils/setfiles/setfiles.c +4 -4
index 656848e3..2d38ea8f 100644
@@ -1,4 +1,5 @@
 #include "restore.h"
+#include <stdbool.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -23,7 +24,7 @@ static struct restore_opts r_opts;
 
 #define SETFILES "setfiles"
 #define RESTORECON "restorecon"
-static int iamrestorecon;
+static bool iamrestorecon;
 
 /* Behavior flags determined based on setfiles vs. restorecon */
 static int ctx_validate; /* Validate contexts */
@@ -181,7 +182,7 @@ int main(int argc, char **argv)
                 * Does not follow mounts (sets SELINUX_RESTORECON_XDEV),
                 * Validates all file contexts at init time.
                 */
-               iamrestorecon = 0;
+               iamrestorecon = false;
                r_opts.recurse = SELINUX_RESTORECON_RECURSE;
                r_opts.userealpath = 0; /* SELINUX_RESTORECON_REALPATH */
                r_opts.add_assoc = SELINUX_RESTORECON_ADD_ASSOC;
@@ -204,7 +205,7 @@ int main(int argc, char **argv)
                                "Executed with unrecognized name (%s), defaulting to %s behavior.\n",
                                base, RESTORECON);
 
-               iamrestorecon = 1;
+               iamrestorecon = true;
                r_opts.recurse = 0;
                r_opts.userealpath = SELINUX_RESTORECON_REALPATH;
                r_opts.add_assoc = 0;
--

2.54.0