... and use automatic cleanup.
#include "special.h"
#include "bus-errors.h"
#include "path-util.h"
#include "special.h"
#include "bus-errors.h"
#include "path-util.h"
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
+ char _cleanup_free_ *k = NULL;
+ char *slash;
- if (!(k = strdup(s->path)))
+ k = strdup(s->path);
+ if (!k)
- if ((s->inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC)) < 0) {
+ s->inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
+ if (s->inotify_fd < 0) {
- if (unit_watch_fd(u, s->inotify_fd, EPOLLIN, &s->watch) < 0) {
- r = -errno;
+ r = unit_watch_fd(u, s->inotify_fd, EPOLLIN, &s->watch);
+ if (r < 0)
s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type]);
if (s->primary_wd >= 0)
s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type]);
if (s->primary_wd >= 0)
path_spec_unwatch(s, u);
return r;
}
path_spec_unwatch(s, u);
return r;
}