... and fix bogus return code on malloc failure.
}
int path_spec_fd_event(PathSpec *s, uint32_t events) {
}
int path_spec_fd_event(PathSpec *s, uint32_t events) {
+ uint8_t _cleanup_free_ *buf = NULL;
struct inotify_event *e;
ssize_t k;
int l;
struct inotify_event *e;
ssize_t k;
int l;
if (events != EPOLLIN) {
log_error("Got invalid poll event on inotify.");
if (events != EPOLLIN) {
log_error("Got invalid poll event on inotify.");
- r = -EINVAL;
- goto out;
}
if (ioctl(s->inotify_fd, FIONREAD, &l) < 0) {
log_error("FIONREAD failed: %m");
}
if (ioctl(s->inotify_fd, FIONREAD, &l) < 0) {
log_error("FIONREAD failed: %m");
- r = -errno;
- goto out;
}
assert(l > 0);
buf = malloc(l);
}
assert(l > 0);
buf = malloc(l);
- if (!buf) {
- log_error("Failed to allocate buffer: %m");
- r = -errno;
- goto out;
- }
+ if (!buf)
+ return log_oom();
k = read(s->inotify_fd, buf, l);
if (k < 0) {
log_error("Failed to read inotify event: %m");
k = read(s->inotify_fd, buf, l);
if (k < 0) {
log_error("Failed to read inotify event: %m");
- r = -errno;
- goto out;
}
e = (struct inotify_event*) buf;
}
e = (struct inotify_event*) buf;
e = (struct inotify_event*) ((uint8_t*) e + step);
k -= step;
}
e = (struct inotify_event*) ((uint8_t*) e + step);
k -= step;
}