summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2017-03-25 22:24:48 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2017-03-25 22:24:48 +0100
commit0ea846deb63e157b75527112c78443a144fd9220 (patch)
treec36d2ba3dbf9f538f0f74ae1b67f885aa02bdcf5
parenta925a4cab1b722a2a24b0c1d2a1925f3b766de61 (diff)
downloadfastd-0ea846deb63e157b75527112c78443a144fd9220.tar
fastd-0ea846deb63e157b75527112c78443a144fd9220.zip
status: correctly align sockaddr_un buffer
While at it, also do some more cleanup.
-rw-r--r--src/status.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/status.c b/src/status.c
index 5d38598..75ae9ec 100644
--- a/src/status.c
+++ b/src/status.c
@@ -243,15 +243,15 @@ void fastd_status_init(void) {
size_t status_socket_len = strlen(conf.status_socket);
size_t len = offsetof(struct sockaddr_un, sun_path) + status_socket_len + 1;
- uint8_t buf[len];
- memset(buf, 0, len);
+ uint8_t buf[len] __attribute__((aligned(__alignof__(struct sockaddr_un))));
+ memset(buf, 0, offsetof(struct sockaddr_un, sun_path));
- struct sockaddr_un *sa = (void*)buf;
+ struct sockaddr_un *sa = (struct sockaddr_un *)buf;
sa->sun_family = AF_UNIX;
memcpy(sa->sun_path, conf.status_socket, status_socket_len+1);
- if (bind(ctx.status_fd.fd, (struct sockaddr*)sa, len)) {
+ if (bind(ctx.status_fd.fd, (struct sockaddr *)sa, len)) {
switch (errno) {
case EADDRINUSE:
exit_error("unable to create status socket: the path `%s' already exists", conf.status_socket);