[PATCH 3/3] libselinux: make context_*_set() return -1 when an error occurs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In libselinux, most functions set errno and return -1 when an error
occurs. But some functions return 1 instead, such as context_type_set(),
context_role_set(), etc. This increases the difficulty of writing Python
bindings of these functions without much benefit.

Return -1 instead (errno was already set).

Signed-off-by: Nicolas Iooss <nicolas.iooss@xxxxxxx>
---
 libselinux/src/context.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libselinux/src/context.c b/libselinux/src/context.c
index 090264a49eb1..ce4258806c53 100644
--- a/libselinux/src/context.c
+++ b/libselinux/src/context.c
@@ -151,14 +151,14 @@ static int set_comp(context_private_t * n, int idx, const char *str)
 	if (str) {
 		t = (char *)malloc(strlen(str) + 1);
 		if (!t) {
-			return 1;
+			return -1;
 		}
 		for (p = str; *p; p++) {
 			if (*p == '\t' || *p == '\n' || *p == '\r' ||
 			    ((*p == ':' || *p == ' ') && idx != COMP_RANGE)) {
 				free(t);
 				errno = EINVAL;
-				return 1;
+				return -1;
 			}
 		}
 		strcpy(t, str);
-- 
2.26.0




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux