commit ce2565f

Michael Forney  ·  2016-04-30 08:13:02 +0000 UTC
parent cb50131
launch: Avoid offsetof and typeof enabling -std=c11
3 files changed,  +3, -4
+1, -1
1@@ -61,7 +61,7 @@ endef
2 
3 $(foreach pkg,$(PACKAGES),$(eval $(call check,$(pkg))))
4 
5-FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=gnu11
6+FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c11
7 FINAL_CPPFLAGS = $(CPPFLAGS) -D_GNU_SOURCE # Required for mkostemp
8 
9 # Warning/error flags
+1, -1
1@@ -222,7 +222,7 @@ handle_socket_data(int socket)
2 
3 	switch (request->type) {
4 	case SWC_LAUNCH_REQUEST_OPEN_DEVICE:
5-		if (request->path[size - __builtin_offsetof(typeof(*request), path) - 1] != '\0') {
6+		if (buffer[size] != '\0') {
7 			fprintf(stderr, "path is not NULL terminated\n");
8 			goto fail;
9 		}
+1, -2
 1@@ -59,7 +59,6 @@ static int
 2 open_socket(struct sockaddr_un *addr, size_t path_size)
 3 {
 4 	int fd;
 5-	socklen_t size = offsetof(typeof(*addr), sun_path) + path_size + 1;
 6 
 7 	if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0)
 8 		goto error0;
 9@@ -68,7 +67,7 @@ open_socket(struct sockaddr_un *addr, size_t path_size)
10 	 * left around a stale lockfile. */
11 	unlink(addr->sun_path);
12 
13-	if (bind(fd, (struct sockaddr *)addr, size) < 0)
14+	if (bind(fd, (struct sockaddr *)addr, sizeof(*addr)) < 0)
15 		goto error1;
16 
17 	if (listen(fd, 1) < 0)