summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c4
-rw-r--r--src/core/dbus-cgroup.c5
-rw-r--r--src/core/execute.c14
-rw-r--r--src/core/job.c4
-rw-r--r--src/core/killall.c4
-rw-r--r--src/core/main.c6
-rw-r--r--src/core/manager.c24
-rw-r--r--src/core/mount.c6
-rw-r--r--src/core/service.c58
9 files changed, 62 insertions, 63 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index c44521c22e..f500850f83 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -774,8 +774,8 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
get_process_comm(packet.v5_packet.pid, &p);
log_info_unit(UNIT(a)->id,
- "Got automount request for %s, triggered by %lu (%s)",
- a->where, (unsigned long) packet.v5_packet.pid, strna(p));
+ "Got automount request for %s, triggered by "PID_FMT" (%s)",
+ a->where, packet.v5_packet.pid, strna(p));
} else
log_debug_unit(UNIT(a)->id, "Got direct mount request on %s", a->where);
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 861bb16445..792f37eef5 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -321,10 +321,9 @@ int bus_cgroup_set_property(
if (r < 0)
return r;
- while (( r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
- unsigned long ul;
+ while ((r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
+ unsigned long ul = u64;
- ul = (unsigned long) u64;
if (ul < 10 || ul > 1000)
return sd_bus_error_set_errnof(error, EINVAL, "BlockIODeviceWeight out of range");
diff --git a/src/core/execute.c b/src/core/execute.c
index 7f93c0c3b1..39c0fed7ac 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1038,7 +1038,7 @@ static int build_environment(
return -ENOMEM;
if (n_fds > 0) {
- if (asprintf(&x, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0)
+ if (asprintf(&x, "LISTEN_PID="PID_FMT, getpid()) < 0)
return -ENOMEM;
our_env[n_env++] = x;
@@ -1048,7 +1048,7 @@ static int build_environment(
}
if (watchdog_usec > 0) {
- if (asprintf(&x, "WATCHDOG_PID=%lu", (unsigned long) getpid()) < 0)
+ if (asprintf(&x, "WATCHDOG_PID="PID_FMT, getpid()) < 0)
return -ENOMEM;
our_env[n_env++] = x;
@@ -1636,8 +1636,8 @@ int exec_spawn(ExecCommand *command,
log_struct_unit(LOG_DEBUG,
unit_id,
- "MESSAGE=Forked %s as %lu",
- command->path, (unsigned long) pid,
+ "MESSAGE=Forked %s as "PID_FMT,
+ command->path, pid,
NULL);
/* We add the new process to the cgroup both in the child (so
@@ -1979,7 +1979,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
}
if (c->timer_slack_nsec != (nsec_t) -1)
- fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, (unsigned long)c->timer_slack_nsec);
+ fprintf(f, "%sTimerSlackNSec: "NSEC_FMT "\n", prefix, c->timer_slack_nsec);
fprintf(f,
"%sStandardInput: %s\n"
@@ -2139,8 +2139,8 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
return;
fprintf(f,
- "%sPID: %lu\n",
- prefix, (unsigned long) s->pid);
+ "%sPID: "PID_FMT"\n",
+ prefix, s->pid);
if (s->start_timestamp.realtime > 0)
fprintf(f,
diff --git a/src/core/job.c b/src/core/job.c
index 491c73d47b..7faa8da0ed 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -906,7 +906,7 @@ char *job_dbus_path(Job *j) {
assert(j);
- if (asprintf(&p, "/org/freedesktop/systemd1/job/%lu", (unsigned long) j->id) < 0)
+ if (asprintf(&p, "/org/freedesktop/systemd1/job/%"PRIu32, j->id) < 0)
return NULL;
return p;
@@ -922,7 +922,7 @@ int job_serialize(Job *j, FILE *f, FDSet *fds) {
fprintf(f, "job-ignore-order=%s\n", yes_no(j->ignore_order));
if (j->begin_usec > 0)
- fprintf(f, "job-begin=%llu\n", (unsigned long long) j->begin_usec);
+ fprintf(f, "job-begin="USEC_FMT"\n", j->begin_usec);
bus_client_track_serialize(j->manager, f, j->subscribed);
diff --git a/src/core/killall.c b/src/core/killall.c
index ea9bfa105e..7664775142 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -170,12 +170,12 @@ static int killall(int sig, Set *pids, bool send_sighup) {
_cleanup_free_ char *s;
get_process_comm(pid, &s);
- log_notice("Sending SIGKILL to PID %lu (%s).", (unsigned long) pid, strna(s));
+ log_notice("Sending SIGKILL to PID "PID_FMT" (%s).", pid, strna(s));
}
if (kill(pid, sig) >= 0) {
if (pids)
- set_put(pids, ULONG_TO_PTR((unsigned long) pid));
+ set_put(pids, ULONG_TO_PTR(pid));
} else if (errno != ENOENT)
log_warning("Could not kill %d: %m", pid);
diff --git a/src/core/main.c b/src/core/main.c
index 064445d17e..d052c8debc 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -166,7 +166,7 @@ noreturn static void crash(int sig) {
else if (status.si_code != CLD_DUMPED)
log_error("Caught <%s>, core dump failed.", signal_to_string(sig));
else
- log_error("Caught <%s>, dumped core as pid %lu.", signal_to_string(sig), (unsigned long) pid);
+ log_error("Caught <%s>, dumped core as pid "PID_FMT".", signal_to_string(sig), pid);
}
}
@@ -197,7 +197,7 @@ noreturn static void crash(int sig) {
_exit(1);
}
- log_info("Successfully spawned crash shell as pid %lu.", (unsigned long) pid);
+ log_info("Successfully spawned crash shell as pid "PID_FMT".", pid);
}
log_info("Freezing execution.");
@@ -1865,7 +1865,7 @@ finish:
watchdog_close(false);
/* Tell the binary how often to ping */
- snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog);
+ snprintf(e, sizeof(e), "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog);
char_array_0(e);
env_block = strv_append(environ, e);
diff --git a/src/core/manager.c b/src/core/manager.c
index ea8887a92e..22a3e3ef5d 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1334,7 +1334,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
if (!u) {
u = manager_get_unit_by_pid(m, ucred->pid);
if (!u) {
- log_warning("Cannot find unit for notify message of PID %lu.", (unsigned long) ucred->pid);
+ log_warning("Cannot find unit for notify message of PID "PID_FMT".", ucred->pid);
continue;
}
}
@@ -1382,7 +1382,7 @@ static int manager_dispatch_sigchld(Manager *m) {
_cleanup_free_ char *name = NULL;
get_process_comm(si.si_pid, &name);
- log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name));
+ log_debug("Got SIGCHLD for process "PID_FMT" (%s)", si.si_pid, strna(name));
}
/* And now figure out the unit this belongs to */
@@ -1470,9 +1470,9 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
log_full(sfsi.ssi_signo == SIGCHLD ||
(sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
? LOG_DEBUG : LOG_INFO,
- "Received SIG%s from PID %lu (%s).",
+ "Received SIG%s from PID "PID_FMT" (%s).",
signal_to_string(sfsi.ssi_signo),
- (unsigned long) sfsi.ssi_pid, strna(p));
+ sfsi.ssi_pid, strna(p));
} else
log_full(sfsi.ssi_signo == SIGCHLD ||
(sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
@@ -1974,9 +1974,9 @@ int manager_open_serialization(Manager *m, FILE **_f) {
assert(_f);
if (m->running_as == SYSTEMD_SYSTEM)
- asprintf(&path, "/run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
+ asprintf(&path, "/run/systemd/dump-"PID_FMT"-XXXXXX", getpid());
else
- asprintf(&path, "/tmp/systemd-dump-%lu-XXXXXX", (unsigned long) getpid());
+ asprintf(&path, "/tmp/systemd-dump-"PID_FMT"-XXXXXX", getpid());
if (!path)
return -ENOMEM;
@@ -2454,9 +2454,9 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
- "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
- "INITRD_USEC=%llu", (unsigned long long) initrd_usec,
- "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+ "KERNEL_USEC="USEC_FMT, kernel_usec,
+ "INITRD_USEC="USEC_FMT, initrd_usec,
+ "USERSPACE_USEC="USEC_FMT, userspace_usec,
"MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
@@ -2470,8 +2470,8 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
- "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
- "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+ "KERNEL_USEC="USEC_FMT, kernel_usec,
+ "USERSPACE_USEC="USEC_FMT, userspace_usec,
"MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
@@ -2485,7 +2485,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
- "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+ "USERSPACE_USEC="USEC_FMT, userspace_usec,
"MESSAGE=Startup finished in %s.",
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
NULL);
diff --git a/src/core/mount.c b/src/core/mount.c
index 09efa1b6e0..41185c0c1d 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -750,8 +750,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
if (m->control_pid > 0)
fprintf(f,
- "%sControl PID: %lu\n",
- prefix, (unsigned long) m->control_pid);
+ "%sControl PID: "PID_FMT"\n",
+ prefix, m->control_pid);
exec_context_dump(&m->exec_context, f, prefix);
kill_context_dump(&m->kill_context, f, prefix);
@@ -1093,7 +1093,7 @@ static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
if (m->control_pid > 0)
- unit_serialize_item_format(u, f, "control-pid", "%lu", (unsigned long) m->control_pid);
+ unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
if (m->control_command_id >= 0)
unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
diff --git a/src/core/service.c b/src/core/service.c
index ea47a5e327..6fbde2b8f2 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -210,8 +210,8 @@ static int service_set_main_pid(Service *s, pid_t pid) {
if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
log_warning_unit(UNIT(s)->id,
- "%s: Supervising process %lu which is not our child. We'll most likely not notice when it exits.",
- UNIT(s)->id, (unsigned long) pid);
+ "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.",
+ UNIT(s)->id, pid);
s->main_pid_alien = true;
} else
@@ -1309,15 +1309,15 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
if (s->control_pid > 0)
fprintf(f,
- "%sControl PID: %lu\n",
- prefix, (unsigned long) s->control_pid);
+ "%sControl PID: "PID_FMT"\n",
+ prefix, s->control_pid);
if (s->main_pid > 0)
fprintf(f,
- "%sMain PID: %lu\n"
+ "%sMain PID: "PID_FMT"\n"
"%sMain PID Known: %s\n"
"%sMain PID Alien: %s\n",
- prefix, (unsigned long) s->main_pid,
+ prefix, s->main_pid,
prefix, yes_no(s->main_pid_known),
prefix, yes_no(s->main_pid_alien));
@@ -1401,8 +1401,8 @@ static int service_load_pid_file(Service *s, bool may_warn) {
if (kill(pid, 0) < 0 && errno != EPERM) {
if (may_warn)
log_info_unit(UNIT(s)->id,
- "PID %lu read from file %s does not exist.",
- (unsigned long) pid, s->pid_file);
+ "PID "PID_FMT" read from file %s does not exist.",
+ pid, s->pid_file);
return -ESRCH;
}
@@ -1411,13 +1411,13 @@ static int service_load_pid_file(Service *s, bool may_warn) {
return 0;
log_debug_unit(UNIT(s)->id,
- "Main PID changing: %lu -> %lu",
- (unsigned long) s->main_pid, (unsigned long) pid);
+ "Main PID changing: "PID_FMT" -> "PID_FMT,
+ s->main_pid, pid);
service_unwatch_main_pid(s);
s->main_pid_known = false;
} else
log_debug_unit(UNIT(s)->id,
- "Main PID loaded: %lu", (unsigned long) pid);
+ "Main PID loaded: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
@@ -1427,8 +1427,8 @@ static int service_load_pid_file(Service *s, bool may_warn) {
if (r < 0) {
/* FIXME: we need to do something here */
log_warning_unit(UNIT(s)->id,
- "Failed to watch PID %lu from service %s",
- (unsigned long) pid, UNIT(s)->id);
+ "Failed to watch PID "PID_FMT" from service %s",
+ pid, UNIT(s)->id);
return r;
}
@@ -1456,7 +1456,7 @@ static int service_search_main_pid(Service *s) {
return -ENOENT;
log_debug_unit(UNIT(s)->id,
- "Main PID guessed: %lu", (unsigned long) pid);
+ "Main PID guessed: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
return r;
@@ -1465,8 +1465,8 @@ static int service_search_main_pid(Service *s) {
if (r < 0)
/* FIXME: we need to do something here */
log_warning_unit(UNIT(s)->id,
- "Failed to watch PID %lu from service %s",
- (unsigned long) pid, UNIT(s)->id);
+ "Failed to watch PID "PID_FMT" from service %s",
+ pid, UNIT(s)->id);
return r;
return 0;
@@ -1763,13 +1763,13 @@ static int service_spawn(
}
if (s->main_pid > 0)
- if (asprintf(our_env + n_env++, "MAINPID=%lu", (unsigned long) s->main_pid) < 0) {
+ if (asprintf(our_env + n_env++, "MAINPID="PID_FMT, s->main_pid) < 0) {
r = -ENOMEM;
goto fail;
}
if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM)
- if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) {
+ if (asprintf(our_env + n_env++, "MANAGERPID="PID_FMT, getpid()) < 0) {
r = -ENOMEM;
goto fail;
}
@@ -2562,11 +2562,11 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
unit_serialize_item(u, f, "reload-result", service_result_to_string(s->reload_result));
if (s->control_pid > 0)
- unit_serialize_item_format(u, f, "control-pid", "%lu",
- (unsigned long) s->control_pid);
+ unit_serialize_item_format(u, f, "control-pid", PID_FMT,
+ s->control_pid);
if (s->main_pid_known && s->main_pid > 0)
- unit_serialize_item_format(u, f, "main-pid", "%lu", (unsigned long) s->main_pid);
+ unit_serialize_item_format(u, f, "main-pid", PID_FMT, s->main_pid);
unit_serialize_item(u, f, "main-pid-known", yes_no(s->main_pid_known));
@@ -2590,8 +2590,8 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
}
if (s->main_exec_status.pid > 0) {
- unit_serialize_item_format(u, f, "main-exec-status-pid", "%lu",
- (unsigned long) s->main_exec_status.pid);
+ unit_serialize_item_format(u, f, "main-exec-status-pid", PID_FMT,
+ s->main_exec_status.pid);
dual_timestamp_serialize(f, "main-exec-status-start",
&s->main_exec_status.start_timestamp);
dual_timestamp_serialize(f, "main-exec-status-exit",
@@ -3343,20 +3343,20 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
assert(u);
- log_debug_unit(u->id, "%s: Got notification message from PID %lu (%s...)",
- u->id, (unsigned long) pid, tags && *tags ? tags[0] : "(empty)");
+ log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s...)",
+ u->id, pid, tags && *tags ? tags[0] : "(empty)");
if (s->notify_access == NOTIFY_NONE) {
log_warning_unit(u->id,
- "%s: Got notification message from PID %lu, but reception is disabled.",
- u->id, (unsigned long) pid);
+ "%s: Got notification message from PID "PID_FMT", but reception is disabled.",
+ u->id, pid);
return;
}
if (s->notify_access == NOTIFY_MAIN && s->main_pid != 0 && pid != s->main_pid) {
log_warning_unit(u->id,
- "%s: Got notification message from PID %lu, but reception only permitted for PID %lu",
- u->id, (unsigned long) pid, (unsigned long) s->main_pid);
+ "%s: Got notification message from PID "PID_FMT", but reception only permitted for PID "PID_FMT,
+ u->id, pid, s->main_pid);
return;
}