Skip to contentSkip to conversation

libselinux: avc_internal.c: allow building with clang

PATCH In review Stephen Smalley 2 participants 3 messages Nov 1, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: avc_internal.c: allow building with clang

Resolves the following errors from clang:
avc_internal.c:105:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]

        struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
                               ^~~~~~~~~~~~~~~~~~~~~~
avc_internal.c:161:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
                               ^~~~~~~~~~~~~~~~~~~~~~
---
 libselinux/src/avc_internal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/src/avc_internal.c +2 -2
index be94857..26f3360 100644
@@ -96,7 +96,7 @@ void avc_netlink_close(void)
 	fd = -1;
 }
 
-static int avc_netlink_receive(char *buf, unsigned buflen, int blocking)
+static int avc_netlink_receive(void *buf, unsigned buflen, int blocking)
 {
 	int rc;
 	struct pollfd pfd = { fd, POLLIN | POLLPRI, 0 };
@@ -155,7 +155,7 @@ static int avc_netlink_receive(char *buf, unsigned buflen, int blocking)
 	return 0;
 }
 
-static int avc_netlink_process(char *buf)
+static int avc_netlink_process(void *buf)
 {
 	int rc;
 	struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
Signature · 1 line
2.7.4
#1 lore raw

We're gonna cross, I just sent this out as well, as well as noreturn fixes for utils.

Quoted 38 lines · Stephen Smalley

Resolves the following errors from clang:
avc_internal.c:105:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]

        struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
                               ^~~~~~~~~~~~~~~~~~~~~~
avc_internal.c:161:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
                               ^~~~~~~~~~~~~~~~~~~~~~
---
 libselinux/src/avc_internal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/src/avc_internal.c +2 -3
index be94857..26f3360 100644
@@ -96,7 +96,7 @@ void avc_netlink_close(void)
        fd = -1;
 }
 
-static int avc_netlink_receive(char *buf, unsigned buflen, int blocking)
+static int avc_netlink_receive(void *buf, unsigned buflen, int blocking)
 {
        int rc;
        struct pollfd pfd = { fd, POLLIN | POLLPRI, 0 };
@@ -155,7 +155,7 @@ static int avc_netlink_receive(char *buf, unsigned buflen, int blocking)
        return 0;
 }
 
-static int avc_netlink_process(char *buf)
+static int avc_netlink_process(void *buf)
 {
        int rc;
        struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
--

2.7.4

Signature · 3 lines
Respectfully,

William C Roberts
#2 lore raw
Quoted 3 lines · William Roberts

We're gonna cross, I just sent this out as well, as well as noreturn fixes for utils.

Never-mind, a gitfoo mistake ended up in my favor of ditching my version of this and rebasing on top of yours. You only need the noreturn patch, which is the only
one sent.

<snip>