Message ID | 20200412081001.23246-3-nicolas.iooss@m4x.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/3] libselinux: add missing glue code to grab errno in Python bindings | expand |
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);
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@m4x.org> --- libselinux/src/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)