1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

inotify-util: fix wrong warnings in FOREACH_INOTIFY_EVENT()

Follow-up for 00adc340bb15bc9d634db6caa48f1c964b99f79a.

This fixes the wrong "Received invalid inotify event, ignoring." warnings
caused by the missing curly brackets and the priorities of `&&` and `?:`.

This also replaces the ternary operators with `||`.
This commit is contained in:
Yu Watanabe 2022-03-25 15:34:29 +09:00
parent 6d39da79c8
commit 8166950763

View File

@ -12,15 +12,12 @@
#define _FOREACH_INOTIFY_EVENT(e, buffer, sz, log_level, start, end) \
for (struct inotify_event \
*start = &((buffer).ev), \
*start = &((buffer).ev), \
*end = (struct inotify_event*) ((uint8_t*) start + (sz)), \
*e = start; \
(uint8_t*) e + sizeof(struct inotify_event) <= (uint8_t*) end && \
(uint8_t*) e + sizeof(struct inotify_event) + e->len <= (uint8_t*) end ? true : \
({ \
log_full(log_level, "Received invalid inotify event, ignoring."); \
false; \
}); \
(size_t) ((uint8_t*) end - (uint8_t*) e) >= sizeof(struct inotify_event) && \
((size_t) ((uint8_t*) end - (uint8_t*) e) >= sizeof(struct inotify_event) + e->len || \
(log_full(log_level, "Received invalid inotify event, ignoring."), false)); \
e = (struct inotify_event*) ((uint8_t*) e + sizeof(struct inotify_event) + e->len))
#define _FOREACH_INOTIFY_EVENT_FULL(e, buffer, sz, log_level) \