commit ce2565fdca2f7bda7ecdb166726c138a88313d69
parent cb50131f9b27581aa91f15bce944ba68969ff6d7
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 30 Apr 2016 01:13:02 -0700
launch: Avoid offsetof and typeof enabling -std=c11
Diffstat:
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -61,7 +61,7 @@ endef
$(foreach pkg,$(PACKAGES),$(eval $(call check,$(pkg))))
-FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=gnu11
+FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c11
FINAL_CPPFLAGS = $(CPPFLAGS) -D_GNU_SOURCE # Required for mkostemp
# Warning/error flags
diff --git a/launch/launch.c b/launch/launch.c
@@ -222,7 +222,7 @@ handle_socket_data(int socket)
switch (request->type) {
case SWC_LAUNCH_REQUEST_OPEN_DEVICE:
- if (request->path[size - __builtin_offsetof(typeof(*request), path) - 1] != '\0') {
+ if (buffer[size] != '\0') {
fprintf(stderr, "path is not NULL terminated\n");
goto fail;
}
diff --git a/libswc/xserver.c b/libswc/xserver.c
@@ -59,7 +59,6 @@ static int
open_socket(struct sockaddr_un *addr, size_t path_size)
{
int fd;
- socklen_t size = offsetof(typeof(*addr), sun_path) + path_size + 1;
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0)
goto error0;
@@ -68,7 +67,7 @@ open_socket(struct sockaddr_un *addr, size_t path_size)
* left around a stale lockfile. */
unlink(addr->sun_path);
- if (bind(fd, (struct sockaddr *)addr, size) < 0)
+ if (bind(fd, (struct sockaddr *)addr, sizeof(*addr)) < 0)
goto error1;
if (listen(fd, 1) < 0)