(wrong string) ünnich

From: <git_AT_suckless.org>
Date: Wed, 17 May 2017 20:26:18 +0200 (CEST)

commit de3d7827ce13a52b1bcf3b72e9dc2ee89152dea6
Author: Bert Münnich <ber.t_AT_posteo.de>
AuthorDate: Wed May 17 20:15:35 2017 +0200
Commit: Bert Münnich <ber.t_AT_posteo.de>
CommitDate: Wed May 17 20:15:35 2017 +0200

    Compiler independent buffer alignment

diff --git a/autoreload_inotify.c b/autoreload_inotify.c
index a7378f6..473b8cb 100644
--- a/autoreload_inotify.c
+++ b/autoreload_inotify.c
_AT_@ -56,22 +56,26 @@ static void arl_setup_dir(arl_t *arl, const char *filepath)
         free(dntmp);
 }
 
+union {
+ char d[4096]; /* aligned buffer */
+ struct inotify_event e;
+} buf;
+
 bool arl_handle(arl_t *arl, const char *filepath)
 {
         bool reload = false;
- char buf[4096] __attribute__ ((aligned(__alignof__(struct inotify_event))));
         char *ptr;
         const struct inotify_event *event;
 
         for (;;) {
- ssize_t len = read(arl->fd, buf, sizeof(buf));
+ ssize_t len = read(arl->fd, buf.d, sizeof(buf.d));
 
                 if (len == -1) {
                         if (errno == EINTR)
                                 continue;
                         break;
                 }
- for (ptr = buf; ptr < buf + len; ptr += sizeof(*event) + event->len) {
+ for (ptr = buf.d; ptr < buf.d + len; ptr += sizeof(*event) + event->len) {
                         event = (const struct inotify_event*) ptr;
 
                         /* events from watching the file itself */
Received on Wed May 17 2017 - 20:26:18 CEST

This archive was generated by hypermail 2.3.0 : Wed May 17 2017 - 20:36:57 CEST