From 091549b2d0d45899442c9725d219b7dd191036bb Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Sun, 12 Apr 2020 10:10:01 +0200 Subject: [PATCH] libselinux: make context_*_set() return -1 when an error occurs 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 --- 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 090264a4..ce425880 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);