diff options
author | NIIBE Yutaka <[email protected]> | 2016-10-27 06:37:47 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2016-10-27 06:43:18 +0000 |
commit | 8b3d0d1a36cab83dafb98ccb7895144edb95e298 (patch) | |
tree | d54c7cd598f3bc1b2de9b5cadf8826f1f00d728e /common/sysutils.c | |
parent | dirmngr: More ADNS error fix. (diff) | |
download | gnupg-8b3d0d1a36cab83dafb98ccb7895144edb95e298.tar.gz gnupg-8b3d0d1a36cab83dafb98ccb7895144edb95e298.zip |
common: Fix gnupg_inotify_has_name, differently.
* common/sysutils.c (gnupg_inotify_has_name): Use void * to stop the
warning.
--
According to the man page of inotify(7), it is aligned by null bytes.
So, bc28f320fa6f5b9fcdb73dba5e6c582daf7992c5 is reverted.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/sysutils.c')
-rw-r--r-- | common/sysutils.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/common/sysutils.c b/common/sysutils.c index 71200a604..0f87a422f 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -1041,47 +1041,41 @@ gnupg_inotify_has_name (int fd, const char *name) { #if USE_NPTH && HAVE_INOTIFY_INIT #define BUFSIZE_FOR_INOTIFY (sizeof (struct inotify_event) + 255 + 1) - char buf[BUFSIZE_FOR_INOTIFY]; - char *p; + union { + struct inotify_event ev; + char _buf[sizeof (struct inotify_event) + 255 + 1]; + } buf; + struct inotify_event *evp; int n; - n = npth_read (fd, buf, sizeof buf); - p = buf; + n = npth_read (fd, &buf, sizeof buf); /* log_debug ("notify read: n=%d\n", n); */ + evp = &buf.ev; while (n >= sizeof (struct inotify_event)) { - struct inotify_event ev; - const char *ev_name; - - memcpy (&ev, p, sizeof (struct inotify_event)); - - if (ev.len > 255 + 1) /* Something goes wrong, skip this data. */ - break; - - ev_name = p + sizeof (struct inotify_event); - p += sizeof (struct inotify_event) + ev.len; - n -= sizeof (struct inotify_event) + ev.len; - /* log_debug (" mask=%x len=%u name=(%s)\n", */ - /* ev.mask, (unsigned int)ev.len, ev.len? ev.name:""); */ - if ((ev.mask & IN_UNMOUNT)) + /* evp->mask, (unsigned int)evp->len, evp->len? evp->name:""); */ + if ((evp->mask & IN_UNMOUNT)) { /* log_debug (" found (dir unmounted)\n"); */ return 3; /* Directory was unmounted. */ } - if ((ev.mask & IN_DELETE_SELF)) + if ((evp->mask & IN_DELETE_SELF)) { /* log_debug (" found (dir removed)\n"); */ return 2; /* Directory was removed. */ } - if ((ev.mask & IN_DELETE)) + if ((evp->mask & IN_DELETE)) { - if (ev.len >= strlen (name) && !strcmp (ev_name, name)) + if (evp->len >= strlen (name) && !strcmp (evp->name, name)) { /* log_debug (" found (file removed)\n"); */ return 1; /* File was removed. */ } } + n -= sizeof (*evp) + evp->len; + evp = (struct inotify_event *)(void *) + ((char *)evp + sizeof (*evp) + evp->len); } #else /*!(USE_NPTH && HAVE_INOTIFY_INIT)*/ |