aboutsummaryrefslogtreecommitdiffstats
path: root/libcutils/uevent.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcutils/uevent.c')
-rw-r--r--libcutils/uevent.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libcutils/uevent.c b/libcutils/uevent.c
index 97a81e30..42d9d901 100644
--- a/libcutils/uevent.c
+++ b/libcutils/uevent.c
@@ -95,14 +95,17 @@ out:
int uevent_open_socket(int buf_sz, bool passcred)
{
- struct sockaddr_nl addr;
+ union {
+ struct sockaddr_nl nl;
+ struct sockaddr generic;
+ } addr;
int on = passcred;
int s;
- memset(&addr, 0, sizeof(addr));
- addr.nl_family = AF_NETLINK;
- addr.nl_pid = getpid();
- addr.nl_groups = 0xffffffff;
+ memset(&addr.nl, 0, sizeof(addr.nl));
+ addr.nl.nl_family = AF_NETLINK;
+ addr.nl.nl_pid = getpid();
+ addr.nl.nl_groups = 0xffffffff;
s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
if(s < 0)
@@ -111,7 +114,7 @@ int uevent_open_socket(int buf_sz, bool passcred)
setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &buf_sz, sizeof(buf_sz));
setsockopt(s, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
- if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ if(bind(s, &addr.generic, sizeof(addr.nl)) < 0) {
close(s);
return -1;
}