libselinux: include errno.h instead of sys/errno.h
PATCH 1/3 libselinux: include errno.h instead of sys/errno.h
Building with musl libc leads to some build errors:
setrans_client.c: In function ‘receive_response’:
setrans_client.c:147:19: error: implicit declaration of function ‘readv’ [-Werror=implicit-function-declaration]
while (((count = readv(fd, resp_hdr, 3)) < 0) && (errno == EINTR)) ;
^~~~~
and:
In file included from matchpathcon.c:10:0:
/usr/include/sys/errno.h:1:2: error: #warning redirecting incorrect #include <sys/errno.h> to <errno.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
^
Fix the first one by including <sys/uio.h> and the second one by using <errno.h> instead of <sys/errno.h>.
--- libselinux/src/setrans_client.c | 1 + libselinux/utils/matchpathcon.c | 1 - libselinux/utils/selinux_check_securetty_context.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-)
libselinux/src/setrans_client.c +1 -0
@@ -18,6 +18,7 @@#include <string.h> #include <ctype.h> #include <unistd.h> +#include <sys/uio.h> #include "dso.h" #include "selinux_internal.h" #include "setrans_internal.h"
libselinux/utils/matchpathcon.c +0 -1
@@ -7,7 +7,6 @@#include <limits.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/errno.h> #include <selinux/selinux.h> #include <limits.h> #include <stdlib.h>
libselinux/utils/selinux_check_securetty_context.c +1 -1
@@ -1,3 +1,4 @@ +#include <errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h>
@@ -6,7 +7,6 @@#include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/errno.h> #include <selinux/selinux.h> static __attribute__ ((__noreturn__))void usage (const char *progname)
Signature · 1 line
2.11.0
PATCH 2/3 checkpolicy: always include ctypes.h
The prototype of isdigit() is provided by ctypes.h header. Without including this file, gcc fails to build checkpolicy using musl libc:
checkpolicy.c: In function ‘main’:
checkpolicy.c:705:8: error: implicit declaration of function ‘isdigit’ [-Werror=implicit-function-declaration]
if (isdigit(ans[0])) {
^~~~~~~
--- checkpolicy/checkpolicy.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
checkpolicy/checkpolicy.c +1 -4
@@ -57,6 +57,7 @@* booleans or conditional rules are thrown away a warning is printed. */ +#include <ctype.h> #include <getopt.h> #include <unistd.h> #include <stdlib.h>
@@ -73,10 +74,6 @@#include <errno.h> #include <sys/mman.h> -#ifdef __APPLE__ -#include <ctype.h> -#endif -#include <sepol/module_to_cil.h> #include <sepol/policydb/policydb.h> #include <sepol/policydb/services.h>
Signature · 1 line
2.11.0
Stephen Smalley
AppliedRe: [PATCH 2/3] checkpolicy: always include ctypes.h
Quoted 10 lines · Nicolas Iooss
The prototype of
isdigit()is provided byctypes.hheader. Without including this file, gcc fails to build checkpolicy using musl libc:checkpolicy.c: In function ‘main’:
checkpolicy.c:705:8: error: implicit declaration of function ‘isdigit’ [-Werror=implicit-function-declaration] if (isdigit(ans[0])) {
^~~~~~~Signed-off-by Nicolas Iooss <[email protected]>
Thanks, applied all three.
Quoted 28 lines
---
checkpolicy/checkpolicy.c | 5 +----1 file changed, 1 insertion(+), 4 deletions(-)checkpolicy/checkpolicy.c +0
-0@@ -57,6 +57,7 @@ * booleans or conditional rules are thrown away a warning isprinted.
*/
+#include <ctype.h>
#include <getopt.h>
#include <unistd.h>
#include <stdlib.h>checkpolicy/checkpolicy.c +0
-0@@ -73,10 +74,6 @@ #include <errno.h> #include <sys/mman.h>checkpolicy/checkpolicy.c +0
-4-#ifdef __APPLE__ -#include <ctype.h> -#endif -#include <
sepol/module_to_cil.h>
#include <sepol/policydb/policydb.h>
#include <sepol/policydb/services.h>
PATCH 3/3 mcstransd: fix and reorder includes
In reply to Nicolas Iooss- Sort included header files by their number of path components then alphabetically.
- Include unistd.h and sys/types.h only once.
- Include sys/uio.h to get readv() and writev() declarations when compiling with musl libc.
- Include poll.h instead of sys/poll.h as building with musl results in the following message:
/usr/lib/musl/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/poll.h> to <poll.h> ^~~~~~~
--- mcstrans/src/mcstransd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
mcstrans/src/mcstransd.c +7 -8
@@ -1,22 +1,21 @@/* Copyright (c) 2006 Trusted Computer Solutions, Inc. */ -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/poll.h> -#include <sys/stat.h> -#include <sys/un.h> #include <errno.h> +#include <poll.h> +#include <signal.h> #include <stdint.h> #include <stdio.h> -#include <unistd.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #include <syslog.h> #include <unistd.h> #include <selinux/selinux.h> -#include <sys/types.h> #include <sys/capability.h> #include <sys/resource.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <sys/un.h> #include "mcstrans.h" #ifdef UNUSED
Signature · 1 line
2.11.0