diff mbox series

[2/3] libselinux: copy the reason why selinux_status_open() returns 1

Message ID 20200412081001.23246-2-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

Commit Message

Nicolas Iooss April 12, 2020, 8:10 a.m. UTC
The function comment of selinux_status_open() states:

    It returns 0 on success, or -1 on error.

However the implementation of this function can also return 1. This is
documented in its manpage (libselinux/man/man3/selinux_status_open.3) as
intended. Copy the reason near the function definition in order to make
the code more auditable.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/sestatus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libselinux/src/sestatus.c b/libselinux/src/sestatus.c
index ede5a28980bf..86267ff89646 100644
--- a/libselinux/src/sestatus.c
+++ b/libselinux/src/sestatus.c
@@ -250,7 +250,9 @@  static int fallback_cb_policyload(int policyload)
  * Since Linux 2.6.37 or later supports this feature, we may run
  * fallback routine using a netlink socket on older kernels, if
  * the supplied `fallback' is not zero.
- * It returns 0 on success, or -1 on error.
+ * It returns 0 on success, -1 on error or 1 when we are ready to
+ * use these interfaces, but netlink socket was opened as fallback
+ * instead of the kernel status page.
  */
 int selinux_status_open(int fallback)
 {