else
log_debug("Sending success.");
+ r = 0;
+
/* Autofs thankfully does not hand out 0 as a token */
while ((token = PTR_TO_UINT(set_steal_first(a->tokens)))) {
int k;
r = k;
}
- r = 0;
-
fail:
if (ioctl_fd >= 0)
close_nointr_nofail(ioctl_fd);
printf("%s%s %*lu %s\n",
prefix,
(more || i < n-1) ? "\342\224\234" : "\342\224\224",
- ilog10(biggest),
+ (int) ilog10(biggest),
(unsigned long) pids[i],
strna(t));
free(fs);
fs = NULL;
- if ((r = cg_get_path(controller, NULL, "notify_on_release", &fs)) < 0) {
- r = -ENOMEM;
+ if ((r = cg_get_path(controller, NULL, "notify_on_release", &fs)) < 0)
goto finish;
- }
free(contents);
contents = NULL;
} else {
/* We need a new root cgroup */
m->cgroup_hierarchy = NULL;
- if ((r = asprintf(&m->cgroup_hierarchy, "%s%s", streq(current, "/") ? "" : current, suffix)) < 0) {
+ if (asprintf(&m->cgroup_hierarchy, "%s%s", streq(current, "/") ? "" : current, suffix) < 0) {
r = -ENOMEM;
goto finish;
}
Unit* cgroup_unit_by_pid(Manager *m, pid_t pid) {
CGroupBonding *l, *b;
char *group = NULL;
- int r;
assert(m);
if (pid <= 1)
return NULL;
- if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, pid, &group)))
+ if (cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, pid, &group) < 0)
return NULL;
l = hashmap_get(m->cgroup_bondings, group);
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_BOOLEAN, &c->ignore) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &c->exec_status.start_timestamp.realtime) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &c->exec_status.exit_timestamp.realtime) ||
- !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &c->exec_status.pid) ||
- !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &c->exec_status.code) ||
- !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &c->exec_status.status))
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &pid) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &code) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &status))
return -ENOMEM;
if (!dbus_message_iter_close_container(&sub, &sub2))
}
if (cgroup_bondings)
- if ((r = cgroup_bonding_install_list(cgroup_bondings, 0)) < 0) {
+ if (cgroup_bonding_install_list(cgroup_bondings, 0) < 0) {
r = EXIT_CGROUP;
goto fail;
}
if (k <= 0)
break;
- if ((k = process_event(&server, &event)) < 0)
+ if (process_event(&server, &event) < 0)
goto fail;
}
if (k <= 0)
break;
- if ((k = process_event(&server, &event)) < 0)
+ if (process_event(&server, &event) < 0)
goto fail;
}
_exit(1);
} else {
- int status, r;
+ int status;
/* Order things nicely. */
- if ((r = waitpid(pid, &status, 0)) < 0)
+ if (waitpid(pid, &status, 0) < 0)
log_error("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(errno));
else if (!WCOREDUMP(status))
log_error("Caught <%s>, core dump failed.", signal_to_string(sig));
char *state;
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(errno));
+ log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
return 0;
}
d = j;
else
d = k;
- }
+ } else
+ d = j;
} else if (!j->matters_to_anchor)
d = j;
t = j->type;
LIST_FOREACH(transaction, k, j->transaction_next) {
- if ((r = job_type_merge(&t, k->type)) >= 0)
+ if (job_type_merge(&t, k->type) >= 0)
continue;
/* OK, we could not merge all jobs for this
static Job* transaction_add_one_job(Manager *m, JobType type, Unit *unit, bool override, bool *is_new) {
Job *j, *f;
- int r;
assert(m);
assert(unit);
LIST_PREPEND(Job, transaction, f, j);
- if ((r = hashmap_replace(m->transaction_jobs, unit, f)) < 0) {
+ if (hashmap_replace(m->transaction_jobs, unit, f) < 0) {
job_free(j);
return NULL;
}
return;
fail:
+ log_warning("%s failed to run 'remount' task: %s", m->meta.id, strerror(-r));
mount_enter_mounted(m, false);
}
static int mount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Mount *m = MOUNT(u);
- int r;
assert(u);
assert(key);
} else if (streq(key, "control-pid")) {
pid_t pid;
- if ((r = parse_pid(value, &pid)) < 0)
+ if (parse_pid(value, &pid) < 0)
log_debug("Failed to parse control-pid value %s", value);
else
m->control_pid = pid;
* table changes */
if ((r = mount_load_proc_self_mountinfo(m, true)) < 0) {
- log_error("Failed to reread /proc/self/mountinfo: %s", strerror(errno));
+ log_error("Failed to reread /proc/self/mountinfo: %s", strerror(-r));
/* Reset flags, just in case, for later calls */
LIST_FOREACH(units_per_type, meta, m->units_per_type[UNIT_MOUNT]) {
case PRIVATE:
what = private_dir;
break;
+
+ default:
+ assert_not_reached("Unknown mode");
}
if ((r = mount(what, where, NULL, MS_BIND|MS_REC, NULL)) >= 0) {
static void path_dump(Unit *u, FILE *f, const char *prefix) {
Path *p = PATH(u);
- const char *prefix2;
- char *p2;
PathSpec *s;
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
+ assert(p);
+ assert(f);
fprintf(f,
"%sPath State: %s\n"
prefix,
path_type_to_string(s->type),
s->path);
-
- free(p2);
}
static void path_unwatch_one(Path *p, PathSpec *s) {
if (t == s->meta.id)
continue;
- if ((r == service_load_sysv_name(s, t)) < 0)
+ if ((r = service_load_sysv_name(s, t)) < 0)
return r;
if (s->meta.load_state != UNIT_STUB)
static int service_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Service *s = SERVICE(u);
- int r;
assert(u);
assert(key);
} else if (streq(key, "control-pid")) {
pid_t pid;
- if ((r = parse_pid(value, &pid)) < 0)
+ if (parse_pid(value, &pid) < 0)
log_debug("Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
} else if (streq(key, "main-pid")) {
pid_t pid;
- if ((r = parse_pid(value, &pid)) < 0)
+ if (parse_pid(value, &pid) < 0)
log_debug("Failed to parse main-pid value %s", value);
else
service_set_main_pid(s, (pid_t) pid);
} else if (streq(key, "main-exec-status-pid")) {
pid_t pid;
- if ((r = parse_pid(value, &pid)) < 0)
+ if (parse_pid(value, &pid) < 0)
log_debug("Failed to parse main-exec-status-pid value %s", value);
else
s->main_exec_status.pid = pid;
} else if (streq(key, "main-exec-status-code")) {
int i;
- if ((r = safe_atoi(value, &i)) < 0)
+ if (safe_atoi(value, &i) < 0)
log_debug("Failed to parse main-exec-status-code value %s", value);
else
s->main_exec_status.code = i;
} else if (streq(key, "main-exec-status-status")) {
int i;
- if ((r = safe_atoi(value, &i)) < 0)
+ if (safe_atoi(value, &i) < 0)
log_debug("Failed to parse main-exec-status-status value %s", value);
else
s->main_exec_status.status = i;
} else if (streq(key, "main-exec-status-start-realtime")) {
uint64_t k;
- if ((r = safe_atou64(value, &k)) < 0)
+ if (safe_atou64(value, &k) < 0)
log_debug("Failed to parse main-exec-status-start-realtime value %s", value);
else
s->main_exec_status.start_timestamp.realtime = (usec_t) k;
} else if (streq(key, "main-exec-status-start-monotonic")) {
uint64_t k;
- if ((r = safe_atou64(value, &k)) < 0)
+ if (safe_atou64(value, &k) < 0)
log_debug("Failed to parse main-exec-status-start-monotonic value %s", value);
else
s->main_exec_status.start_timestamp.monotonic = (usec_t) k;
} else if (streq(key, "main-exec-status-exit-realtime")) {
uint64_t k;
- if ((r = safe_atou64(value, &k)) < 0)
+ if (safe_atou64(value, &k) < 0)
log_debug("Failed to parse main-exec-status-exit-realtime value %s", value);
else
s->main_exec_status.exit_timestamp.realtime = (usec_t) k;
} else if (streq(key, "main-exec-status-exit-monotonic")) {
uint64_t k;
- if ((r = safe_atou64(value, &k)) < 0)
+ if (safe_atou64(value, &k) < 0)
log_debug("Failed to parse main-exec-status-exit-monotonic value %s", value);
else
s->main_exec_status.exit_timestamp.monotonic = (usec_t) k;
if (p->type == SOCKET_SOCKET) {
const char *t;
int r;
- char *k;
+ char *k = NULL;
if ((r = socket_address_print(&p->address, &k)) < 0)
t = strerror(-r);
else
t = k;
- fprintf(f, "%s%s: %s\n", prefix, listen_lookup(p->address.type), k);
+ fprintf(f, "%s%s: %s\n", prefix, listen_lookup(p->address.type), t);
free(k);
} else
fprintf(f, "%sListenFIFO: %s\n", prefix, p->path);
static int socket_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Socket *s = SOCKET(u);
- int r;
assert(u);
assert(key);
} else if (streq(key, "n-accepted")) {
unsigned k;
- if ((r = safe_atou(value, &k)) < 0)
+ if (safe_atou(value, &k) < 0)
log_debug("Failed to parse n-accepted value %s", value);
else
s->n_accepted += k;
} else if (streq(key, "control-pid")) {
pid_t pid;
- if ((r = parse_pid(value, &pid)) < 0)
+ if (parse_pid(value, &pid) < 0)
log_debug("Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
if (p->fd >= 0)
rn_fds++;
- if (!(rfds = new(int, rn_fds)) < 0)
+ if (!(rfds = new(int, rn_fds)))
return -ENOMEM;
k = 0;
dbus_message_iter_next(&sub);
}
+ r = 0;
+
finish:
if (m)
dbus_message_unref(m);
}
static bool need_daemon_reload(DBusConnection *bus, const char *unit) {
- DBusMessage *m, *reply;
+ DBusMessage *m = NULL, *reply = NULL;
dbus_bool_t b = FALSE;
DBusMessageIter iter, sub;
const char
free(p);
if (r == 0)
- q = r;
+ r = q;
} else if (is_link) {
char *p, *dest, *c;
}
static int reload_with_fallback(DBusConnection *bus) {
- int r;
if (bus) {
/* First, try systemd via D-Bus. */
- if ((r = daemon_reload(bus, NULL, 0)) > 0)
+ if (daemon_reload(bus, NULL, 0) > 0)
return 0;
}
}
static int start_with_fallback(DBusConnection *bus) {
- int r;
if (bus) {
/* First, try systemd via D-Bus. */
- if ((r = start_unit(bus, NULL, 0)) > 0)
+ if (start_unit(bus, NULL, 0) > 0)
goto done;
}
/* Hmm, talking to systemd via D-Bus didn't work. Then
* let's try to talk to Upstart via D-Bus. */
- if ((r = talk_upstart()) > 0)
+ if (talk_upstart() > 0)
goto done;
/* Nothing else worked, so let's try
* /dev/initctl */
- if ((r = talk_initctl()) != 0)
+ if (talk_initctl() != 0)
goto done;
log_error("Failed to talk to init daemon.");
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
Timer *t = TIMER(u);
- const char *prefix2;
- char *p2;
TimerValue *v;
char
timespan1[FORMAT_TIMESPAN_MAX];
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
-
fprintf(f,
"%sTimer State: %s\n"
"%sUnit: %s\n",
prefix,
timer_base_to_string(v->base),
strna(format_timespan(timespan1, sizeof(timespan1), v->value)));
-
- free(p2);
}
static void timer_set_state(Timer *t, TimerState state) {
return -EBADR;
state = unit_active_state(u);
- if (unit_active_state(u) == UNIT_RELOADING)
+ if (state == UNIT_RELOADING)
return -EALREADY;
- if (unit_active_state(u) != UNIT_ACTIVE)
+ if (state != UNIT_ACTIVE)
return -ENOEXEC;
unit_add_to_dbus_queue(u);