diff options
Diffstat (limited to 'libcutils/properties.c')
| -rw-r--r-- | libcutils/properties.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libcutils/properties.c b/libcutils/properties.c index 9c46b795..6c3aab88 100644 --- a/libcutils/properties.c +++ b/libcutils/properties.c @@ -100,7 +100,10 @@ static int connectToServer(const char* fileName) int sock = -1; int cc; - struct sockaddr_un addr; + union { + struct sockaddr_un un; + struct sockaddr generic; + } addr; sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { @@ -109,9 +112,9 @@ static int connectToServer(const char* fileName) } /* connect to socket; fails if file doesn't exist */ - strcpy(addr.sun_path, fileName); // max 108 bytes - addr.sun_family = AF_UNIX; - cc = connect(sock, (struct sockaddr*) &addr, SUN_LEN(&addr)); + strcpy(addr.un.sun_path, fileName); // max 108 bytes + addr.un.sun_family = AF_UNIX; + cc = connect(sock, &addr.generic, SUN_LEN(&addr.un)); if (cc < 0) { // ENOENT means socket file doesn't exist // ECONNREFUSED means socket exists but nobody is listening |
