diff options
64 files changed, 221 insertions, 198 deletions
diff --git a/configure.ac b/configure.ac index 972fc2f6bf..c3653e3f76 100644 --- a/configure.ac +++ b/configure.ac @@ -199,6 +199,11 @@ AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags") AC_CHECK_SIZEOF(pid_t) AC_CHECK_SIZEOF(uid_t) AC_CHECK_SIZEOF(gid_t) +AC_CHECK_SIZEOF(time_t) +AC_CHECK_SIZEOF(rlim_t,,[ + #include <sys/time.h> + #include <sys/resource.h> +]) # ------------------------------------------------------------------------------ # we use python to build the man page index, and for systemd-python diff --git a/src/core/condition.c b/src/core/condition.c index 1448fa19dc..24684580a8 100644 --- a/src/core/condition.c +++ b/src/core/condition.c @@ -59,7 +59,7 @@ static bool condition_test_capability(Condition *c) { cap_value_t value; FILE *f; char line[LINE_MAX]; - unsigned long long capabilities = (unsigned long long) -1; + unsigned long long capabilities = -1; assert(c); assert(c->parameter); diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c index b9e3be483b..fbb4ff5646 100644 --- a/src/core/dbus-scope.c +++ b/src/core/dbus-scope.c @@ -138,7 +138,7 @@ static int bus_scope_set_transient_property( if (r < 0) return r; - unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec=%lluus\n", (unsigned long long) s->timeout_stop_usec); + unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec="USEC_FMT"us\n", s->timeout_stop_usec); } else { r = sd_bus_message_skip(message, "t"); if (r < 0) diff --git a/src/core/execute.c b/src/core/execute.c index 4a3aeda3cd..af8e7c725b 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1173,7 +1173,7 @@ static int build_environment( return -ENOMEM; our_env[n_env++] = x; - if (asprintf(&x, "WATCHDOG_USEC=%llu", (unsigned long long) watchdog_usec) < 0) + if (asprintf(&x, "WATCHDOG_USEC="USEC_FMT, watchdog_usec) < 0) return -ENOMEM; our_env[n_env++] = x; } @@ -2139,7 +2139,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { for (i = 0; i < RLIM_NLIMITS; i++) if (c->rlimit[i]) - fprintf(f, "%s%s: %llu\n", prefix, rlimit_to_string(i), (unsigned long long) c->rlimit[i]->rlim_max); + fprintf(f, "%s%s: "RLIM_FMT"\n", + prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max); if (c->ioprio_set) { _cleanup_free_ char *class_str = NULL; diff --git a/src/core/socket.c b/src/core/socket.c index 536904f309..05af8fe9d2 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -470,8 +470,8 @@ static void socket_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->bind_to_device) fprintf(f, @@ -1710,7 +1710,7 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) { unit_serialize_item_format(u, f, "n-accepted", "%u", s->n_accepted); 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->control_command_id >= 0) unit_serialize_item(u, f, "control-command", socket_exec_command_to_string(s->control_command_id)); diff --git a/src/core/swap.c b/src/core/swap.c index 10eed6d25f..9f353af430 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -609,8 +609,8 @@ static void swap_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); exec_context_dump(&s->exec_context, f, prefix); kill_context_dump(&s->kill_context, f, prefix); @@ -878,7 +878,7 @@ static int swap_serialize(Unit *u, FILE *f, FDSet *fds) { unit_serialize_item(u, f, "result", swap_result_to_string(s->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->control_command_id >= 0) unit_serialize_item(u, f, "control-command", swap_exec_command_to_string(s->control_command_id)); diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index d16d856b51..5bd30f0bf7 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -208,7 +208,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char if (r < 0) return -ENODATA; - asprintf(&printed, "%lu", (unsigned long) uid); + asprintf(&printed, UID_FMT, uid); } } @@ -231,7 +231,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char if (specifier == 'u') printed = strdup(username); else - asprintf(&printed, "%lu", (unsigned long) uid); + asprintf(&printed, UID_FMT, uid); } if (!printed) diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c index b3dedb77c6..95962c73c1 100644 --- a/src/dbus1-generator/dbus1-generator.c +++ b/src/dbus1-generator/dbus1-generator.c @@ -96,7 +96,7 @@ static int create_dbus_files( } fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT "\n", - (unsigned long) getuid(), run); + getuid(), run); } } diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c index f9613ea3b1..f9a6ed44ed 100644 --- a/src/initctl/initctl.c +++ b/src/initctl/initctl.c @@ -396,7 +396,7 @@ int main(int argc, char *argv[]) { if (server_init(&server, (unsigned) n) < 0) return EXIT_FAILURE; - log_debug("systemd-initctl running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-initctl running as pid "PID_FMT, getpid()); sd_notify(false, "READY=1\n" @@ -426,7 +426,7 @@ int main(int argc, char *argv[]) { r = EXIT_SUCCESS; - log_debug("systemd-initctl stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-initctl stopped as pid "PID_FMT, getpid()); fail: sd_notify(false, diff --git a/src/journal/journal-remote.c b/src/journal/journal-remote.c index ec4054f2f5..9adad7aabc 100644 --- a/src/journal/journal-remote.c +++ b/src/journal/journal-remote.c @@ -1210,8 +1210,8 @@ int main(int argc, char **argv) { if (remoteserver_init(&s) < 0) return EXIT_FAILURE; - log_debug("%s running as pid %lu", - program_invocation_short_name, (unsigned long) getpid()); + log_debug("%s running as pid "PID_FMT, + program_invocation_short_name, getpid()); sd_notify(false, "READY=1\n" "STATUS=Processing requests..."); diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 3db5fc50a1..6ec2528d74 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -67,9 +67,9 @@ void server_forward_console( /* First: timestamp */ if (prefix_timestamp()) { assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0); - snprintf(tbuf, sizeof(tbuf), "[%5llu.%06llu] ", - (unsigned long long) ts.tv_sec, - (unsigned long long) ts.tv_nsec / 1000); + snprintf(tbuf, sizeof(tbuf), "[%5"PRI_TIME".%06ld] ", + ts.tv_sec, + ts.tv_nsec / 1000); IOVEC_SET_STRING(iovec[n++], tbuf); } @@ -80,7 +80,7 @@ void server_forward_console( identifier = ident_buf; } - snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) ucred->pid); + snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", ucred->pid); char_array_0(header_pid); if (identifier) diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 35948ea754..12992e7d78 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -71,7 +71,7 @@ void server_forward_kmsg( identifier = ident_buf; } - snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) ucred->pid); + snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", ucred->pid); char_array_0(header_pid); if (identifier) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 6da81e7cde..0439caf909 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -269,8 +269,8 @@ static JournalFile* find_journal(Server *s, uid_t uid) { if (f) return f; - if (asprintf(&p, "/var/log/journal/" SD_ID128_FORMAT_STR "/user-%lu.journal", - SD_ID128_FORMAT_VAL(machine), (unsigned long) uid) < 0) + if (asprintf(&p, "/var/log/journal/" SD_ID128_FORMAT_STR "/user-"UID_FMT".journal", + SD_ID128_FORMAT_VAL(machine), uid) < 0) return s->system_journal; while (hashmap_size(s->user_journals) >= USER_JOURNALS_MAX) { @@ -576,13 +576,13 @@ static void dispatch_message_real( if (ucred) { realuid = ucred->uid; - sprintf(pid, "_PID=%lu", (unsigned long) ucred->pid); + sprintf(pid, "_PID="PID_FMT, ucred->pid); IOVEC_SET_STRING(iovec[n++], pid); - sprintf(uid, "_UID=%lu", (unsigned long) ucred->uid); + sprintf(uid, "_UID="UID_FMT, ucred->uid); IOVEC_SET_STRING(iovec[n++], uid); - sprintf(gid, "_GID=%lu", (unsigned long) ucred->gid); + sprintf(gid, "_GID="GID_FMT, ucred->gid); IOVEC_SET_STRING(iovec[n++], gid); r = get_process_comm(ucred->pid, &t); @@ -616,13 +616,13 @@ static void dispatch_message_real( #ifdef HAVE_AUDIT r = audit_session_from_pid(ucred->pid, &audit); if (r >= 0) { - sprintf(audit_session, "_AUDIT_SESSION=%lu", (unsigned long) audit); + sprintf(audit_session, "_AUDIT_SESSION=%"PRIu32, audit); IOVEC_SET_STRING(iovec[n++], audit_session); } r = audit_loginuid_from_pid(ucred->pid, &loginuid); if (r >= 0) { - sprintf(audit_loginuid, "_AUDIT_LOGINUID=%lu", (unsigned long) loginuid); + sprintf(audit_loginuid, "_AUDIT_LOGINUID="UID_FMT, loginuid); IOVEC_SET_STRING(iovec[n++], audit_loginuid); } #endif @@ -644,7 +644,7 @@ static void dispatch_message_real( if (cg_path_get_owner_uid(c, &owner) >= 0) { owner_valid = true; - sprintf(owner_uid, "_SYSTEMD_OWNER_UID=%lu", (unsigned long) owner); + sprintf(owner_uid, "_SYSTEMD_OWNER_UID="UID_FMT, owner); IOVEC_SET_STRING(iovec[n++], owner_uid); } @@ -703,13 +703,13 @@ static void dispatch_message_real( if (object_pid) { r = get_process_uid(object_pid, &object_uid); if (r >= 0) { - sprintf(o_uid, "OBJECT_UID=%lu", (unsigned long) object_uid); + sprintf(o_uid, "OBJECT_UID="UID_FMT, object_uid); IOVEC_SET_STRING(iovec[n++], o_uid); } r = get_process_gid(object_pid, &object_gid); if (r >= 0) { - sprintf(o_gid, "OBJECT_GID=%lu", (unsigned long) object_gid); + sprintf(o_gid, "OBJECT_GID="GID_FMT, object_gid); IOVEC_SET_STRING(iovec[n++], o_gid); } @@ -737,13 +737,13 @@ static void dispatch_message_real( #ifdef HAVE_AUDIT r = audit_session_from_pid(object_pid, &audit); if (r >= 0) { - sprintf(o_audit_session, "OBJECT_AUDIT_SESSION=%lu", (unsigned long) audit); + sprintf(o_audit_session, "OBJECT_AUDIT_SESSION=%"PRIu32, audit); IOVEC_SET_STRING(iovec[n++], o_audit_session); } r = audit_loginuid_from_pid(object_pid, &loginuid); if (r >= 0) { - sprintf(o_audit_loginuid, "OBJECT_AUDIT_LOGINUID=%lu", (unsigned long) loginuid); + sprintf(o_audit_loginuid, "OBJECT_AUDIT_LOGINUID="UID_FMT, loginuid); IOVEC_SET_STRING(iovec[n++], o_audit_loginuid); } #endif @@ -761,7 +761,7 @@ static void dispatch_message_real( } if (cg_path_get_owner_uid(c, &owner) >= 0) { - sprintf(o_owner_uid, "OBJECT_SYSTEMD_OWNER_UID=%lu", (unsigned long) owner); + sprintf(o_owner_uid, "OBJECT_SYSTEMD_OWNER_UID="UID_FMT, owner); IOVEC_SET_STRING(iovec[n++], o_owner_uid); } diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index fee7d91572..434eac428f 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -159,7 +159,7 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons identifier = ident_buf; } - snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) ucred->pid); + snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", ucred->pid); char_array_0(header_pid); if (identifier) diff --git a/src/journal/journald.c b/src/journal/journald.c index 766500917b..886ac92a79 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) { server_flush_to_var(&server); server_flush_dev_kmsg(&server); - log_debug("systemd-journald running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-journald running as pid "PID_FMT, getpid()); server_driver_message(&server, SD_MESSAGE_JOURNAL_START, "Journal started"); sd_notify(false, @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) { server_maybe_warn_forward_syslog_missed(&server); } - log_debug("systemd-journald stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-journald stopped as pid "PID_FMT, getpid()); server_driver_message(&server, SD_MESSAGE_JOURNAL_STOP, "Journal stopped"); finish: diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 7587211506..11de8ef45e 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1273,7 +1273,7 @@ static bool file_type_wanted(int flags, const char *filename) { if (flags & SD_JOURNAL_CURRENT_USER) { char prefix[5 + DECIMAL_STR_MAX(uid_t) + 1]; - assert_se(snprintf(prefix, sizeof(prefix), "user-%lu", (unsigned long) getuid()) + assert_se(snprintf(prefix, sizeof(prefix), "user-"UID_FMT, getuid()) < (int) sizeof(prefix)); if (file_has_type_prefix(prefix, filename)) diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index 3da77cf1d7..26c25452bb 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -749,7 +749,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) { if (tid > 0 && (missing & SD_BUS_CREDS_TID_COMM)) { _cleanup_free_ char *p = NULL; - if (asprintf(&p, "/proc/%lu/task/%lu/comm", (unsigned long) pid, (unsigned long) tid) < 0) + if (asprintf(&p, "/proc/"PID_FMT"/task/"PID_FMT"/comm", pid, tid) < 0) return -ENOMEM; r = read_one_line_file(p, &c->tid_comm); diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index 6f4ce0c42f..8b70b20e80 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -98,11 +98,11 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) { ansi_highlight_red(), strna(m->error.message), ansi_highlight_off()); if (m->monotonic != 0) - fprintf(f, " Monotonic=%llu", (unsigned long long) m->monotonic); + fprintf(f, " Monotonic="USEC_FMT, m->monotonic); if (m->realtime != 0) - fprintf(f, " Realtime=%llu", (unsigned long long) m->realtime); + fprintf(f, " Realtime="USEC_FMT, m->realtime); if (m->seqnum != 0) - fprintf(f, " SequenceNumber=%llu", (unsigned long long) m->seqnum); + fprintf(f, " SequenceNumber=%"PRIu64, m->seqnum); if (m->monotonic != 0 || m->realtime != 0 || m->seqnum != 0) fputs("\n", f); @@ -221,11 +221,11 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) { break; case SD_BUS_TYPE_INT64: - fprintf(f, "%sINT64 %s%lli%s;\n", prefix, ansi_highlight(), (long long) basic.s64, ansi_highlight_off()); + fprintf(f, "%sINT64 %s%"PRIi64"%s;\n", prefix, ansi_highlight(), basic.s64, ansi_highlight_off()); break; case SD_BUS_TYPE_UINT64: - fprintf(f, "%sUINT64 %s%llu%s;\n", prefix, ansi_highlight(), (unsigned long long) basic.u64, ansi_highlight_off()); + fprintf(f, "%sUINT64 %s%"PRIu64"%s;\n", prefix, ansi_highlight(), basic.u64, ansi_highlight_off()); break; case SD_BUS_TYPE_DOUBLE: @@ -319,18 +319,18 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f) { f = stdout; if (c->mask & SD_BUS_CREDS_PID) - fprintf(f, " PID=%lu", (unsigned long) c->pid); + fprintf(f, " PID="PID_FMT, c->pid); if (c->mask & SD_BUS_CREDS_PID_STARTTIME) - fprintf(f, " PIDStartTime=%llu", (unsigned long long) c->pid_starttime); + fprintf(f, " PIDStartTime="USEC_FMT, c->pid_starttime); if (c->mask & SD_BUS_CREDS_TID) - fprintf(f, " TID=%lu", (unsigned long) c->tid); + fprintf(f, " TID="PID_FMT, c->tid); if (c->mask & SD_BUS_CREDS_UID) - fprintf(f, " UID=%lu", (unsigned long) c->uid); + fprintf(f, " UID="UID_FMT, c->uid); r = sd_bus_creds_get_owner_uid(c, &owner); if (r >= 0) - fprintf(f, " OwnerUID=%lu", (unsigned long) owner); + fprintf(f, " OwnerUID="UID_FMT, owner); if (c->mask & SD_BUS_CREDS_GID) - fprintf(f, " GID=%lu", (unsigned long) c->gid); + fprintf(f, " GID="GID_FMT, c->gid); if ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID|SD_BUS_CREDS_UID|SD_BUS_CREDS_GID)) || r >= 0) fputs("\n", f); @@ -387,11 +387,11 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f) { if (sd_bus_creds_get_audit_login_uid(c, &audit_loginuid) >= 0) { audit_loginuid_is_set = true; - fprintf(f, " AuditLoginUID=%lu", (unsigned long) audit_loginuid); + fprintf(f, " AuditLoginUID="UID_FMT, audit_loginuid); } if (sd_bus_creds_get_audit_session_id(c, &audit_sessionid) >= 0) { audit_sessionid_is_set = true; - fprintf(f, " AuditSessionID=%lu", (unsigned long) audit_sessionid); + fprintf(f, " AuditSessionID=%"PRIu32, audit_sessionid); } if (audit_loginuid_is_set || audit_sessionid_is_set) diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index af42b9f5e1..8bab6ad1be 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -1305,7 +1305,7 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) { make->size += ALIGN8(n->size); n = KDBUS_ITEM_NEXT(n); - sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name); + sprintf(n->str, UID_FMT"-%s", getuid(), name); n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1; n->type = KDBUS_ITEM_MAKE_NAME; make->size += ALIGN8(n->size); @@ -1396,7 +1396,7 @@ int bus_kernel_create_starter(const char *bus, const char *name, bool activating assert(name); p = alloca(strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1); - sprintf(p, "/dev/kdbus/%lu-%s/bus", (unsigned long) getuid(), bus); + sprintf(p, "/dev/kdbus/"UID_FMT"-%s/bus", getuid(), bus); fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC); if (fd < 0) @@ -1511,7 +1511,7 @@ int bus_kernel_create_monitor(const char *bus) { assert(bus); p = alloca(strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1); - sprintf(p, "/dev/kdbus/%lu-%s/bus", (unsigned long) getuid(), bus); + sprintf(p, "/dev/kdbus/"UID_FMT"-%s/bus", getuid(), bus); fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC); if (fd < 0) diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index 2e8f008be4..d124d9aa13 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -648,7 +648,7 @@ static int bus_socket_start_auth_client(sd_bus *b) { auth_prefix = "\0AUTH EXTERNAL "; - snprintf(text, sizeof(text), "%lu", (unsigned long) geteuid()); + snprintf(text, sizeof(text), UID_FMT, geteuid()); char_array_0(text); l = strlen(text); diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index b5b3c857b8..6220934bd8 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -537,7 +537,7 @@ int bus_open_user_systemd(sd_bus **_bus) { if (r < 0) return r; - if (asprintf(&bus->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()) < 0) + if (asprintf(&bus->address, KERNEL_USER_BUS_FMT, getuid()) < 0) return -ENOMEM; bus->bus_client = true; diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index ea80e9d19b..de947bf5c6 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -1162,13 +1162,13 @@ int bus_set_address_user(sd_bus *b) { return -ENOMEM; #ifdef ENABLE_KDBUS - asprintf(&b->address, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT, (unsigned long) getuid(), ee); + asprintf(&b->address, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT, getuid(), ee); #else asprintf(&b->address, UNIX_USER_BUS_FMT, ee); #endif } else { #ifdef ENABLE_KDBUS - asprintf(&b->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()); + asprintf(&b->address, KERNEL_USER_BUS_FMT, getuid()); #else return -ECONNREFUSED; #endif diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index c9eb69843d..d5903f41d5 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -160,9 +160,9 @@ static int server(sd_bus *bus) { sd_bus_creds_get_pid(sd_bus_message_get_creds(m), &pid); sd_bus_creds_get_selinux_context(sd_bus_message_get_creds(m), &label); - log_info("Got message! member=%s pid=%lu label=%s", + log_info("Got message! member=%s pid="PID_FMT" label=%s", strna(sd_bus_message_get_member(m)), - (unsigned long) pid, + pid, strna(label)); /* bus_message_dump(m); */ /* sd_bus_message_rewind(m, true); */ diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index 2321873da5..2be4de571e 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) { h = hexmem(buffer, sz); assert_se(h); - log_info("message size = %lu, contents =\n%s", (unsigned long) sz, h); + log_info("message size = %zu, contents =\n%s", sz, h); free(h); #ifdef HAVE_GLIB diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 39445a191b..e7eea19580 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -172,7 +172,7 @@ _public_ int sd_uid_get_state(uid_t uid, char**state) { assert_return(state, -EINVAL); - if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) uid) < 0) + if (asprintf(&p, "/run/systemd/users/"UID_FMT, uid) < 0) return -ENOMEM; r = parse_env_file(p, NEWLINE, "STATE", &s, NULL); @@ -215,7 +215,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) if (!s) return -EIO; - if (asprintf(&t, "%lu", (unsigned long) uid) < 0) + if (asprintf(&t, UID_FMT, uid) < 0) return -ENOMEM; FOREACH_WORD(w, l, s, state) { @@ -231,7 +231,7 @@ static int uid_get_array(uid_t uid, const char *variable, char ***array) { char **a; int r; - if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) uid) < 0) + if (asprintf(&p, "/run/systemd/users/"UID_FMT, uid) < 0) return -ENOMEM; r = parse_env_file(p, NEWLINE, diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c index 9e326de5b4..ccf2c95816 100644 --- a/src/libsystemd/sd-login/test-login.c +++ b/src/libsystemd/sd-login/test-login.c @@ -47,7 +47,7 @@ static void test_login(void) { printf("session = %s\n", session); assert_se(sd_pid_get_owner_uid(0, &u2) == 0); - printf("user = %lu\n", (unsigned long) u2); + printf("user = "UID_FMT"\n", u2); assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0); sd_peer_get_session(pair[0], &pp); @@ -88,7 +88,7 @@ static void test_login(void) { free(state); assert_se(sd_session_get_uid(session, &u) >= 0); - printf("uid = %lu\n", (unsigned long) u); + printf("uid = "UID_FMT"\n", u); assert_se(u == u2); assert_se(sd_session_get_type(session, &type) >= 0); @@ -137,7 +137,7 @@ static void test_login(void) { assert_se(sd_seat_get_active(seat, &session2, &u2) >= 0); printf("session2 = %s\n", session2); - printf("uid2 = %lu\n", (unsigned long) u2); + printf("uid2 = "UID_FMT"\n", u2); r = sd_seat_get_sessions(seat, &sessions, &uids, &n); assert_se(r >= 0); @@ -149,7 +149,7 @@ static void test_login(void) { free(t); printf("uids ="); for (k = 0; k < (int) n; k++) - printf(" %lu", (unsigned long) uids[k]); + printf(" "UID_FMT, uids[k]); printf("\n"); free(uids); @@ -192,7 +192,7 @@ static void test_login(void) { printf("uids ="); for (k = 0; k < r; k++) - printf(" %lu", (unsigned long) uids[k]); + printf(" "UID_FMT, uids[k]); printf("\n"); free(uids); diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c index cb4947ff3b..637d064819 100644 --- a/src/libudev/libudev-device-private.c +++ b/src/libudev/libudev-device-private.c @@ -154,7 +154,7 @@ int udev_device_update_db(struct udev_device *udev_device) } if (udev_device_get_usec_initialized(udev_device) > 0) - fprintf(f, "I:%llu\n", (unsigned long long)udev_device_get_usec_initialized(udev_device)); + fprintf(f, "I:"USEC_FMT"\n", udev_device_get_usec_initialized(udev_device)); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) { if (!udev_list_entry_get_num(list_entry)) diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 9f80f56d42..3a64f24fb8 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -1341,7 +1341,7 @@ void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t us char num[32]; udev_device->usec_initialized = usec_initialized; - snprintf(num, sizeof(num), "%llu", (unsigned long long)usec_initialized); + snprintf(num, sizeof(num), USEC_FMT, usec_initialized); udev_device_add_property(udev_device, "USEC_INITIALIZED", num); } diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index ff34e5a2cd..e0d4d7ca8f 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -305,7 +305,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) { udev_dbg(udev, "=== trie on-disk ===\n"); udev_dbg(udev, "tool version: %"PRIu64, le64toh(hwdb->head->tool_version)); - udev_dbg(udev, "file size: %8llu bytes\n", (unsigned long long) hwdb->st.st_size); + udev_dbg(udev, "file size: %8zu bytes\n", hwdb->st.st_size); udev_dbg(udev, "header size %8"PRIu64" bytes\n", le64toh(hwdb->head->header_size)); udev_dbg(udev, "strings %8"PRIu64" bytes\n", le64toh(hwdb->head->strings_len)); udev_dbg(udev, "nodes %8"PRIu64" bytes\n", le64toh(hwdb->head->nodes_len)); diff --git a/src/login/inhibit.c b/src/login/inhibit.c index ae3afdf9b7..24e8fb04bd 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -100,11 +100,11 @@ static int print_inhibitors(sd_bus *bus, sd_bus_error *error) { get_process_comm(pid, &comm); u = uid_to_name(uid); - printf(" Who: %s (UID %lu/%s, PID %lu/%s)\n" + printf(" Who: %s (UID "UID_FMT"/%s, PID "PID_FMT"/%s)\n" " What: %s\n" " Why: %s\n" " Mode: %s\n\n", - who, (unsigned long) uid, strna(u), (unsigned long) pid, strna(comm), + who, uid, strna(u), pid, strna(comm), what, why, mode); diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 1928f43cd1..ae9cd4894a 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -153,17 +153,17 @@ int manager_handle_action( /* If this is just a recheck of the lid switch then don't warn about anything */ if (!is_edge) { - log_debug("Refusing operation, %s is inhibited by UID %lu/%s, PID %lu/%s.", + log_debug("Refusing operation, %s is inhibited by UID "UID_FMT"/%s, PID "PID_FMT"/%s.", inhibit_what_to_string(inhibit_operation), - (unsigned long) offending->uid, strna(u), - (unsigned long) offending->pid, strna(comm)); + offending->uid, strna(u), + offending->pid, strna(comm)); return 0; } - log_error("Refusing operation, %s is inhibited by UID %lu/%s, PID %lu/%s.", + log_error("Refusing operation, %s is inhibited by UID "UID_FMT"/%s, PID "PID_FMT"/%s.", inhibit_what_to_string(inhibit_operation), - (unsigned long) offending->uid, strna(u), - (unsigned long) offending->pid, strna(comm)); + offending->uid, strna(u), + offending->pid, strna(comm)); warn_melody(); return -EPERM; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 0af67148af..1a363c2c59 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -189,7 +189,7 @@ static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; if (!session) - return sd_bus_error_setf(error, BUS_ERROR_NO_SESSION_FOR_PID, "PID %lu does not belong to any known session", (unsigned long) pid); + return sd_bus_error_setf(error, BUS_ERROR_NO_SESSION_FOR_PID, "PID "PID_FMT" does not belong to any known session", pid); p = session_bus_path(session); if (!p) @@ -215,7 +215,7 @@ static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata, user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user "UID_FMT" known or logged in", uid); p = user_bus_path(user); if (!p) @@ -257,7 +257,7 @@ static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *us if (r < 0) return r; if (!user) - return sd_bus_error_setf(error, BUS_ERROR_NO_USER_FOR_PID, "PID %lu does not belong to any known or logged in user", (unsigned long) pid); + return sd_bus_error_setf(error, BUS_ERROR_NO_USER_FOR_PID, "PID "PID_FMT" does not belong to any known or logged in user", pid); p = user_bus_path(user); if (!p) @@ -621,7 +621,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (audit_id > 0) { /* Keep our session IDs and the audit session IDs in sync */ - if (asprintf(&id, "%lu", (unsigned long) audit_id) < 0) + if (asprintf(&id, "%"PRIu32, audit_id) < 0) return -ENOMEM; /* Wut? There's already a session by this name and we @@ -923,7 +923,7 @@ static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user "UID_FMT" known or logged in", uid); r = user_kill(user, signo); if (r < 0) @@ -973,7 +973,7 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER, "No user "UID_FMT" known or logged in", uid); r = user_stop(user, true); if (r < 0) @@ -2220,9 +2220,9 @@ int manager_dispatch_delayed(Manager *manager) { if (manager->action_timestamp + manager->inhibit_delay_max > now(CLOCK_MONOTONIC)) return 0; - log_info("Delay lock is active (UID %lu/%s, PID %lu/%s) but inhibitor timeout is reached.", - (unsigned long) offending->uid, strna(u), - (unsigned long) offending->pid, strna(comm)); + log_info("Delay lock is active (UID "UID_FMT"/%s, PID "PID_FMT"/%s) but inhibitor timeout is reached.", + offending->uid, strna(u), + offending->pid, strna(comm)); } /* Actually do the operation */ diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 8b329abd79..64a62ffeae 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -151,9 +151,9 @@ int inhibitor_start(Inhibitor *i) { dual_timestamp_get(&i->since); - log_debug("Inhibitor %s (%s) pid=%lu uid=%lu mode=%s started.", + log_debug("Inhibitor %s (%s) pid="PID_FMT" uid="UID_FMT" mode=%s started.", strna(i->who), strna(i->why), - (unsigned long) i->pid, (unsigned long) i->uid, + i->pid, i->uid, inhibit_mode_to_string(i->mode)); inhibitor_save(i); @@ -169,9 +169,9 @@ int inhibitor_stop(Inhibitor *i) { assert(i); if (i->started) - log_debug("Inhibitor %s (%s) pid=%lu uid=%lu mode=%s stopped.", + log_debug("Inhibitor %s (%s) pid="PID_FMT" uid="UID_FMT" mode=%s stopped.", strna(i->who), strna(i->why), - (unsigned long) i->pid, (unsigned long) i->uid, + i->pid, i->uid, inhibit_mode_to_string(i->mode)); if (i->state_file) diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 8e6f95e6cd..4fb229e354 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -533,7 +533,7 @@ int session_start(Session *s) { MESSAGE_ID(SD_MESSAGE_SESSION_START), "SESSION_ID=%s", s->id, "USER_ID=%s", s->user->name, - "LEADER=%lu", (unsigned long) s->leader, + "LEADER="PID_FMT, s->leader, "MESSAGE=New session %s of user %s.", s->id, s->user->name, NULL); @@ -632,7 +632,7 @@ int session_finalize(Session *s) { MESSAGE_ID(SD_MESSAGE_SESSION_STOP), "SESSION_ID=%s", s->id, "USER_ID=%s", s->user->name, - "LEADER=%lu", (unsigned long) s->leader, + "LEADER="PID_FMT, s->leader, "MESSAGE=Removed session %s.", s->id, NULL); diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 4f1a079ecd..6266ccb0f0 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -291,7 +291,7 @@ char *user_bus_path(User *u) { assert(u); - if (asprintf(&s, "/org/freedesktop/login1/user/_%llu", (unsigned long long) u->uid) < 0) + if (asprintf(&s, "/org/freedesktop/login1/user/_"UID_FMT, u->uid) < 0) return NULL; return s; diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 961cbcb27b..5fffa651a3 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -52,7 +52,7 @@ User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) { if (!u->name) goto fail; - if (asprintf(&u->state_file, "/run/systemd/users/%lu", (unsigned long) uid) < 0) + if (asprintf(&u->state_file, "/run/systemd/users/"UID_FMT, uid) < 0) goto fail; if (hashmap_put(m->users, ULONG_TO_PTR((unsigned long) uid), u) < 0) @@ -354,8 +354,8 @@ static int user_start_slice(User *u) { if (!u->slice) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - char lu[DECIMAL_STR_MAX(unsigned long) + 1], *slice; - sprintf(lu, "%lu", (unsigned long) u->uid); + char lu[DECIMAL_STR_MAX(uid_t) + 1], *slice; + sprintf(lu, UID_FMT, u->uid); r = build_subslice(SPECIAL_USER_SLICE, lu, &slice); if (r < 0) @@ -387,8 +387,8 @@ static int user_start_service(User *u) { assert(u); if (!u->service) { - char lu[DECIMAL_STR_MAX(unsigned long) + 1], *service; - sprintf(lu, "%lu", (unsigned long) u->uid); + char lu[DECIMAL_STR_MAX(uid_t) + 1], *service; + sprintf(lu, UID_FMT, u->uid); service = unit_name_build("user", lu, ".service"); if (!service) diff --git a/src/login/logind.c b/src/login/logind.c index 686506cc65..7a7bd97150 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1160,7 +1160,7 @@ int main(int argc, char *argv[]) { goto finish; } - log_debug("systemd-logind running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-logind running as pid "PID_FMT, getpid()); sd_notify(false, "READY=1\n" @@ -1168,7 +1168,7 @@ int main(int argc, char *argv[]) { r = manager_run(m); - log_debug("systemd-logind stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-logind stopped as pid "PID_FMT, getpid()); finish: sd_notify(false, diff --git a/src/login/pam-module.c b/src/login/pam-module.c index 1259457efc..262621d43f 100644 --- a/src/login/pam-module.c +++ b/src/login/pam-module.c @@ -184,7 +184,7 @@ static int export_legacy_dbus_address( return PAM_SUCCESS; if (asprintf(&s, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT, - (unsigned long) uid, runtime) < 0) { + uid, runtime) < 0) { pam_syslog(handle, LOG_ERR, "Failed to set bus variable."); return PAM_BUF_ERR; } @@ -252,7 +252,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( if (streq_ptr(service, "systemd-user")) { _cleanup_free_ char *p = NULL, *rt = NULL; - if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) + if (asprintf(&p, "/run/systemd/users/"UID_FMT, pw->pw_uid) < 0) return PAM_BUF_ERR; r = parse_env_file(p, NEWLINE, diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c index 70780c30af..21d2339616 100644 --- a/src/login/test-inhibit.c +++ b/src/login/test-inhibit.c @@ -73,8 +73,8 @@ static void print_inhibitors(sd_bus *bus) { assert(r >= 0); while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) { - printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<%lu> pid=<%lu>\n", - what, who, why, mode, (unsigned long) uid, (unsigned long) pid); + printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<"UID_FMT"> pid=<"PID_FMT">\n", + what, who, why, mode, uid, pid); n++; } diff --git a/src/machine/machine.c b/src/machine/machine.c index 9a5cc9a63c..1164ce8f3d 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -303,7 +303,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_MACHINE_START), "NAME=%s", m->name, - "LEADER=%lu", (unsigned long) m->leader, + "LEADER="PID_FMT, m->leader, "MESSAGE=New machine %s.", m->name, NULL); @@ -350,7 +350,7 @@ int machine_stop(Machine *m) { log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_MACHINE_STOP), "NAME=%s", m->name, - "LEADER=%lu", (unsigned long) m->leader, + "LEADER="PID_FMT, m->leader, "MESSAGE=Machine %s terminated.", m->name, NULL); diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 947310542c..a32d7f5d75 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -118,7 +118,7 @@ static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; if (!machine) - return sd_bus_error_setf(error, BUS_ERROR_NO_MACHINE_FOR_PID, "PID %lu does not belong to any known machine", (unsigned long) pid); + return sd_bus_error_setf(error, BUS_ERROR_NO_MACHINE_FOR_PID, "PID "PID_FMT" does not belong to any known machine", pid); p = machine_bus_path(machine); if (!p) diff --git a/src/machine/machined.c b/src/machine/machined.c index 45768d2e97..6160320127 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) { goto finish; } - log_debug("systemd-machined running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-machined running as pid "PID_FMT, getpid()); sd_notify(false, "READY=1\n" @@ -346,7 +346,7 @@ int main(int argc, char *argv[]) { r = manager_run(m); - log_debug("systemd-machined stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-machined stopped as pid "PID_FMT, getpid()); finish: sd_notify(false, diff --git a/src/notify/notify.c b/src/notify/notify.c index a145b8fd1b..68133c408b 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -184,7 +184,7 @@ int main(int argc, char* argv[]) { } if (arg_pid > 0) { - if (asprintf(&cpid, "MAINPID=%lu", (unsigned long) arg_pid) < 0) { + if (asprintf(&cpid, "MAINPID="PID_FMT, arg_pid) < 0) { log_error("Failed to allocate MAINPID string."); goto finish; } diff --git a/src/readahead/readahead-common.c b/src/readahead/readahead-common.c index 49679fc834..890886eca1 100644 --- a/src/readahead/readahead-common.c +++ b/src/readahead/readahead-common.c @@ -52,7 +52,7 @@ int file_verify(int fd, const char *fn, off_t file_size_max, struct stat *st) { } if (st->st_size <= 0 || st->st_size > file_size_max) { - log_debug("Not preloading file %s with size out of bounds %llu", fn, (unsigned long long) st->st_size); + log_debug("Not preloading file %s with size out of bounds %zu", fn, st->st_size); return 0; } @@ -255,7 +255,7 @@ ReadaheadShared *shared_get(void) { Simply so that it is more unlikely that users end up picking this value too so that we can recognize better whether the user changed the value while we had it temporarily bumped. */ -#define BUMP_REQUEST_NR (20*1024) +#define BUMP_REQUEST_NR (20*1024u) int block_bump_request_nr(const char *p) { struct stat st; @@ -296,7 +296,7 @@ int block_bump_request_nr(const char *p) { free(line); line = NULL; - if (asprintf(&line, "%lu", (unsigned long) BUMP_REQUEST_NR) < 0) { + if (asprintf(&line, "%u", BUMP_REQUEST_NR) < 0) { r = -ENOMEM; goto finish; } @@ -305,7 +305,7 @@ int block_bump_request_nr(const char *p) { if (r < 0) goto finish; - log_info("Bumped block_nr parameter of %u:%u to %lu. This is a temporary hack and should be removed one day.", major(d), minor(d), (unsigned long) BUMP_REQUEST_NR); + log_info("Bumped block_nr parameter of %u:%u to %u. This is a temporary hack and should be removed one day.", major(d), minor(d), BUMP_REQUEST_NR); r = 1; finish: @@ -379,7 +379,7 @@ int block_set_readahead(const char *p, uint64_t bytes) { goto finish; } - if (asprintf(&line, "%llu", (unsigned long long) bytes / 1024ULL) < 0) { + if (asprintf(&line, "%llu", bytes / 1024ULL) < 0) { r = -ENOMEM; goto finish; } diff --git a/src/run/run.c b/src/run/run.c index e3b040d79a..e4c695c5b5 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -338,7 +338,7 @@ static int start_transient_service( if (arg_unit) name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".service"); else - asprintf(&name, "run-%lu.service", (unsigned long) getpid()); + asprintf(&name, "run-"PID_FMT".service", getpid()); if (!name) return log_oom(); @@ -474,7 +474,7 @@ static int start_transient_scope( if (arg_unit) name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".scope"); else - asprintf(&name, "run-%lu.scope", (unsigned long) getpid()); + asprintf(&name, "run-"PID_FMT".scope", getpid()); if (!name) return log_oom(); diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index c3c78b69fb..5997a03fb2 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -359,14 +359,14 @@ int ask_password_agent( fprintf(f, "[Ask]\n" - "PID=%lu\n" + "PID="PID_FMT"\n" "Socket=%s\n" "AcceptCached=%i\n" - "NotAfter=%llu\n", - (unsigned long) getpid(), + "NotAfter="USEC_FMT"\n", + getpid(), socket_name, accept_cached ? 1 : 0, - (unsigned long long) until); + until); if (message) fprintf(f, "Message=%s\n", message); diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index 139888c4a1..c1c4d409ae 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -641,7 +641,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { if (pid == 0) pid = getpid(); - snprintf(c, sizeof(c), "%lu\n", (unsigned long) pid); + snprintf(c, sizeof(c), PID_FMT"\n", pid); return write_string_file(fs, c); } diff --git a/src/shared/def.h b/src/shared/def.h index aa489d80d0..a52853cfd1 100644 --- a/src/shared/def.h +++ b/src/shared/def.h @@ -71,7 +71,7 @@ #endif #define UNIX_USER_BUS_FMT "unix:path=%s/bus" -#define KERNEL_USER_BUS_FMT "kernel:path=/dev/kdbus/%lu-user/bus" +#define KERNEL_USER_BUS_FMT "kernel:path=/dev/kdbus/"UID_FMT"-user/bus" #ifndef TTY_GID #define TTY_GID 5 diff --git a/src/shared/log.c b/src/shared/log.c index a4b3b68ef1..9039db3496 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -378,7 +378,7 @@ static int write_to_syslog( if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0) return -EINVAL; - snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid()); + snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", getpid()); char_array_0(header_pid); IOVEC_SET_STRING(iovec[0], header_priority); @@ -426,7 +426,7 @@ static int write_to_kmsg( snprintf(header_priority, sizeof(header_priority), "<%i>", level); char_array_0(header_priority); - snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid()); + snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", getpid()); char_array_0(header_pid); IOVEC_SET_STRING(iovec[0], header_priority); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index b0b66f64fc..72c9ad2eba 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -301,8 +301,8 @@ static int output_short( } fprintf(f, "[%5llu.%06llu]", - (unsigned long long) (t / USEC_PER_SEC), - (unsigned long long) (t % USEC_PER_SEC)); + t / USEC_PER_SEC, + t % USEC_PER_SEC); n += 1 + 5 + 1 + 6 + 1; @@ -531,12 +531,12 @@ static int output_export( fprintf(f, "__CURSOR=%s\n" - "__REALTIME_TIMESTAMP=%llu\n" - "__MONOTONIC_TIMESTAMP=%llu\n" + "__REALTIME_TIMESTAMP="USEC_FMT"\n" + "__MONOTONIC_TIMESTAMP="USEC_FMT"\n" "_BOOT_ID=%s\n", cursor, - (unsigned long long) realtime, - (unsigned long long) monotonic, + realtime, + monotonic, sd_id128_to_string(boot_id, sid)); JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) { @@ -673,12 +673,12 @@ static int output_json( fprintf(f, "{\n" "\t\"__CURSOR\" : \"%s\",\n" - "\t\"__REALTIME_TIMESTAMP\" : \"%llu\",\n" - "\t\"__MONOTONIC_TIMESTAMP\" : \"%llu\",\n" + "\t\"__REALTIME_TIMESTAMP\" : \""USEC_FMT"\",\n" + "\t\"__MONOTONIC_TIMESTAMP\" : \""USEC_FMT"\",\n" "\t\"_BOOT_ID\" : \"%s\"", cursor, - (unsigned long long) realtime, - (unsigned long long) monotonic, + realtime, + monotonic, sd_id128_to_string(boot_id, sid)); else { if (mode == OUTPUT_JSON_SSE) @@ -686,12 +686,12 @@ static int output_json( fprintf(f, "{ \"__CURSOR\" : \"%s\", " - "\"__REALTIME_TIMESTAMP\" : \"%llu\", " - "\"__MONOTONIC_TIMESTAMP\" : \"%llu\", " + "\"__REALTIME_TIMESTAMP\" : \""USEC_FMT"\", " + "\"__MONOTONIC_TIMESTAMP\" : \""USEC_FMT"\", " "\"_BOOT_ID\" : \"%s\"", cursor, - (unsigned long long) realtime, - (unsigned long long) monotonic, + realtime, + monotonic, sd_id128_to_string(boot_id, sid)); } @@ -1100,7 +1100,7 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) { m2 = strappenda("USER_UNIT=", unit); m3 = strappenda("COREDUMP_USER_UNIT=", unit); m4 = strappenda("OBJECT_SYSTEMD_USER_UNIT=", unit); - sprintf(muid, "_UID=%lu", (unsigned long) uid); + sprintf(muid, "_UID="UID_FMT, uid); (void) ( /* Look for messages from the user service itself */ diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 5ef2e2244c..997a1ceba3 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -594,7 +594,7 @@ int getpeername_pretty(int fd, char **ret) { if (r < 0) return r; - if (asprintf(ret, "PID %lu/UID %lu", (unsigned long) ucred.pid, (unsigned long) ucred.uid) < 0) + if (asprintf(ret, "PID "PID_FMT"/UID "UID_FMT, ucred.pid, ucred.uid) < 0) return -ENOMEM; return 0; diff --git a/src/shared/time-util.c b/src/shared/time-util.c index eb5c1ae790..c66763872d 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -209,44 +209,44 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) { if (d >= USEC_PER_YEAR) snprintf(buf, l, "%llu years %llu months %s", - (unsigned long long) (d / USEC_PER_YEAR), - (unsigned long long) ((d % USEC_PER_YEAR) / USEC_PER_MONTH), s); + d / USEC_PER_YEAR, + (d % USEC_PER_YEAR) / USEC_PER_MONTH, s); else if (d >= USEC_PER_MONTH) snprintf(buf, l, "%llu months %llu days %s", - (unsigned long long) (d / USEC_PER_MONTH), - (unsigned long long) ((d % USEC_PER_MONTH) / USEC_PER_DAY), s); + d / USEC_PER_MONTH, + (d % USEC_PER_MONTH) / USEC_PER_DAY, s); else if (d >= USEC_PER_WEEK) snprintf(buf, l, "%llu weeks %llu days %s", - (unsigned long long) (d / USEC_PER_WEEK), - (unsigned long long) ((d % USEC_PER_WEEK) / USEC_PER_DAY), s); + d / USEC_PER_WEEK, + (d % USEC_PER_WEEK) / USEC_PER_DAY, s); else if (d >= 2*USEC_PER_DAY) - snprintf(buf, l, "%llu days %s", (unsigned long long) (d / USEC_PER_DAY), s); + snprintf(buf, l, "%llu days %s", d / USEC_PER_DAY, s); else if (d >= 25*USEC_PER_HOUR) snprintf(buf, l, "1 day %lluh %s", - (unsigned long long) ((d - USEC_PER_DAY) / USEC_PER_HOUR), s); + (d - USEC_PER_DAY) / USEC_PER_HOUR, s); else if (d >= 6*USEC_PER_HOUR) snprintf(buf, l, "%lluh %s", - (unsigned long long) (d / USEC_PER_HOUR), s); + d / USEC_PER_HOUR, s); else if (d >= USEC_PER_HOUR) snprintf(buf, l, "%lluh %llumin %s", - (unsigned long long) (d / USEC_PER_HOUR), - (unsigned long long) ((d % USEC_PER_HOUR) / USEC_PER_MINUTE), s); + d / USEC_PER_HOUR, + (d % USEC_PER_HOUR) / USEC_PER_MINUTE, s); else if (d >= 5*USEC_PER_MINUTE) snprintf(buf, l, "%llumin %s", - (unsigned long long) (d / USEC_PER_MINUTE), s); + d / USEC_PER_MINUTE, s); else if (d >= USEC_PER_MINUTE) snprintf(buf, l, "%llumin %llus %s", - (unsigned long long) (d / USEC_PER_MINUTE), - (unsigned long long) ((d % USEC_PER_MINUTE) / USEC_PER_SEC), s); + d / USEC_PER_MINUTE, + (d % USEC_PER_MINUTE) / USEC_PER_SEC, s); else if (d >= USEC_PER_SEC) snprintf(buf, l, "%llus %s", - (unsigned long long) (d / USEC_PER_SEC), s); + d / USEC_PER_SEC, s); else if (d >= USEC_PER_MSEC) snprintf(buf, l, "%llums %s", - (unsigned long long) (d / USEC_PER_MSEC), s); + d / USEC_PER_MSEC, s); else if (d > 0) - snprintf(buf, l, "%lluus %s", - (unsigned long long) d, s); + snprintf(buf, l, USEC_FMT"us %s", + d, s); else snprintf(buf, l, "now"); @@ -325,9 +325,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { if (j > 0) { k = snprintf(p, l, - "%s%llu.%0*llu%s", + "%s"USEC_FMT".%0*llu%s", p > buf ? " " : "", - (unsigned long long) a, + a, j, (unsigned long long) b, table[i].suffix); @@ -340,9 +340,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { /* No? Then let's show it normally */ if (!done) { k = snprintf(p, l, - "%s%llu%s", + "%s"USEC_FMT"%s", p > buf ? " " : "", - (unsigned long long) a, + a, table[i].suffix); t = b; @@ -370,10 +370,10 @@ void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t) { if (!dual_timestamp_is_set(t)) return; - fprintf(f, "%s=%llu %llu\n", + fprintf(f, "%s="USEC_FMT" "USEC_FMT"\n", name, - (unsigned long long) t->realtime, - (unsigned long long) t->monotonic); + t->realtime, + t->monotonic); } void dual_timestamp_deserialize(const char *value, dual_timestamp *t) { diff --git a/src/shared/util.c b/src/shared/util.c index d1dc476ab6..020c1da7a9 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -2499,7 +2499,7 @@ static char *lookup_uid(uid_t uid) { if (getpwuid_r(uid, &pwbuf, buf, bufsize, &pw) == 0 && pw) return strdup(pw->pw_name); - if (asprintf(&name, "%lu", (unsigned long) uid) < 0) + if (asprintf(&name, UID_FMT, uid) < 0) return NULL; return name; @@ -2624,7 +2624,7 @@ int get_ctty(pid_t pid, dev_t *_devnr, char **r) { /* This is an ugly hack */ if (major(devnr) == 136) { - asprintf(&b, "pts/%lu", (unsigned long) minor(devnr)); + asprintf(&b, "pts/%u", minor(devnr)); goto finish; } @@ -4299,7 +4299,7 @@ char* uid_to_name(uid_t uid) { if (p) return strdup(p->pw_name); - if (asprintf(&r, "%lu", (unsigned long) uid) < 0) + if (asprintf(&r, UID_FMT, uid) < 0) return NULL; return r; @@ -4316,7 +4316,7 @@ char* gid_to_name(gid_t gid) { if (p) return strdup(p->gr_name); - if (asprintf(&r, "%lu", (unsigned long) gid) < 0) + if (asprintf(&r, GID_FMT, gid) < 0) return NULL; return r; diff --git a/src/shared/util.h b/src/shared/util.h index 891fcee239..f2ce4f0d6e 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -67,6 +67,22 @@ # error Unknown gid_t size #endif +#if SIZEOF_TIME_T == 8 +# define PRI_TIME PRIu64 +#elif SIZEOF_GID_T == 4 +# define PRI_TIME PRIu32 +#else +# error Unknown time_t size +#endif + +#if SIZEOF_RLIM_T == 8 +# define RLIM_FMT "%" PRIu64 +#elif SIZEOF_RLIM_T == 4 +# define RLIM_FMT "%" PRIu32 +#else +# error Unknown rlim_t size +#endif + #include "macro.h" #include "time-util.h" diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c index 578920c96d..25427d6416 100644 --- a/src/shutdownd/shutdownd.c +++ b/src/shutdownd/shutdownd.c @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) { } } - log_debug("systemd-shutdownd running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-shutdownd running as pid "PID_FMT, getpid()); sd_notify(false, "READY=1\n" @@ -425,7 +425,7 @@ int main(int argc, char *argv[]) { r = EXIT_SUCCESS; - log_debug("systemd-shutdownd stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-shutdownd stopped as pid "PID_FMT, getpid()); finish: diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index a60a301988..b13b2731ce 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2884,8 +2884,8 @@ static int check_inhibitors(sd_bus *bus, enum action a) { get_process_comm(pid, &comm); user = uid_to_name(uid); - log_warning("Operation inhibited by \"%s\" (PID %lu \"%s\", user %s), reason is \"%s\".", - who, (unsigned long) pid, strna(comm), strna(user), why); + log_warning("Operation inhibited by \"%s\" (PID "PID_FMT" \"%s\", user %s), reason is \"%s\".", + who, pid, strna(comm), strna(user), why); c++; } @@ -4256,7 +4256,7 @@ static int get_unit_dbus_path_by_pid( &reply, "u", pid); if (r < 0) { - log_error("Failed to get unit for PID %lu: %s", (unsigned long) pid, bus_error_message(&error, r)); + log_error("Failed to get unit for PID "PID_FMT": %s", pid, bus_error_message(&error, r)); return r; } diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index b37468b70e..fda8bcc5c5 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -162,11 +162,11 @@ static void test_proc(void) { cg_pid_get_machine_name(pid, &machine); cg_pid_get_slice(pid, &slice); - printf("%lu\t%s\t%s\t%lu\t%s\t%s\t%s\t%s\t%s\n", - (unsigned long) pid, + printf(PID_FMT"\t%s\t%s\t"UID_FMT"\t%s\t%s\t%s\t%s\t%s\n", + pid, path, path_shifted, - (unsigned long) uid, + uid, session, unit, user_unit, diff --git a/src/test/test-log.c b/src/test/test-log.c index 8dc3d5383f..ca64004b4c 100644 --- a/src/test/test-log.c +++ b/src/test/test-log.c @@ -23,6 +23,7 @@ #include <unistd.h> #include "log.h" +#include "util.h" int main(int argc, char* argv[]) { @@ -30,7 +31,7 @@ int main(int argc, char* argv[]) { log_open(); log_struct(LOG_INFO, - "MESSAGE=Waldo PID=%lu", (unsigned long) getpid(), + "MESSAGE=Waldo PID="PID_FMT, getpid(), "SERVICE=piepapo", NULL); @@ -38,12 +39,12 @@ int main(int argc, char* argv[]) { log_open(); log_struct(LOG_INFO, - "MESSAGE=Foobar PID=%lu", (unsigned long) getpid(), + "MESSAGE=Foobar PID="PID_FMT, getpid(), "SERVICE=foobar", NULL); log_struct(LOG_INFO, - "MESSAGE=Foobar PID=%lu", (unsigned long) getpid(), + "MESSAGE=Foobar PID="PID_FMT, getpid(), "FORMAT_STR_TEST=1=%i A=%c 2=%hi 3=%li 4=%lli 1=%p foo=%s 2.5=%g 3.5=%g 4.5=%Lg", (int) 1, 'A', (short) 2, (long int) 3, (long long int) 4, (void*) 1, "foo", (float) 2.5f, (double) 3.5, (long double) 4.5, "SUFFIX=GOT IT", diff --git a/src/test/test-time.c b/src/test/test-time.c index 36a33046a2..7c29f96a34 100644 --- a/src/test/test-time.c +++ b/src/test/test-time.c @@ -84,7 +84,7 @@ static void test_format_timespan_one(usec_t x, usec_t accuracy) { char l[FORMAT_TIMESPAN_MAX]; usec_t y; - log_info("%llu (at accuracy %llu)", (unsigned long long) x, (unsigned long long) accuracy); + log_info(USEC_FMT" (at accuracy "USEC_FMT")", x, accuracy); r = format_timespan(l, sizeof(l), x, accuracy); assert_se(r); @@ -93,7 +93,7 @@ static void test_format_timespan_one(usec_t x, usec_t accuracy) { assert_se(parse_sec(l, &y) >= 0); - log_info(" = %llu", (unsigned long long) y); + log_info(" = "USEC_FMT, y); if (accuracy <= 0) accuracy = 1; diff --git a/src/test/test-util.c b/src/test/test-util.c index caf8d2b12b..2b46699125 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -434,7 +434,7 @@ static void test_get_process_comm(void) { log_info("pid1 cmdline truncated: '%s'", d); assert_se(get_parent_of_pid(1, &e) >= 0); - log_info("pid1 ppid: '%llu'", (unsigned long long) e); + log_info("pid1 ppid: "PID_FMT, e); assert_se(e == 0); assert_se(is_kernel_thread(1) == 0); @@ -444,11 +444,11 @@ static void test_get_process_comm(void) { log_info("pid1 exe: '%s'", strna(f)); assert_se(get_process_uid(1, &u) == 0); - log_info("pid1 uid: '%llu'", (unsigned long long) u); + log_info("pid1 uid: "UID_FMT, u); assert_se(u == 0); assert_se(get_process_gid(1, &g) == 0); - log_info("pid1 gid: '%llu'", (unsigned long long) g); + log_info("pid1 gid: "GID_FMT, g); assert_se(g == 0); assert(get_ctty_devnr(1, &h) == -ENOENT); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 1b09380094..3e0f70cfdc 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -710,7 +710,7 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu log_struct(LOG_INFO, MESSAGE_ID(SD_MESSAGE_TIME_CHANGE), - "REALTIME=%llu", (unsigned long long) timespec_load(&ts), + "REALTIME="USEC_FMT, timespec_load(&ts), "MESSAGE=Changed local time to %s", ctime(&ts.tv_sec), NULL); diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index db652f7a6e..cf194c00c6 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -274,9 +274,9 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t if (err < 0) goto out; - log_debug("probe %s %sraid offset=%llu", + log_debug("probe %s %sraid offset=%"PRIu64, udev_device_get_devnode(dev), - noraid ? "no" : "", (unsigned long long) offset); + noraid ? "no" : "", offset); err = probe_superblocks(pr); if (err < 0) diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index b2f7f6ba4c..a54aa82c73 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -48,9 +48,9 @@ static void print_device(struct udev_device *device, const char *source, int pro struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - printf("%-6s[%llu.%06u] %-8s %s (%s)\n", + printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n", source, - (unsigned long long) ts.tv_sec, (unsigned int) ts.tv_nsec/1000, + ts.tv_sec, ts.tv_nsec/1000, udev_device_get_action(device), udev_device_get_devpath(device), udev_device_get_subsystem(device)); diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index e5fb5f8bf6..31cae70950 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -270,7 +270,7 @@ int main(int argc, char *argv[]) { goto finish; } - log_debug("systemd-update-utmp running as pid %lu", (unsigned long) getpid()); + log_debug("systemd-update-utmp running as pid "PID_FMT, getpid()); if (streq(argv[1], "reboot")) r = on_reboot(&c); @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) { r = -EINVAL; } - log_debug("systemd-update-utmp stopped as pid %lu", (unsigned long) getpid()); + log_debug("systemd-update-utmp stopped as pid "PID_FMT, getpid()); finish: #ifdef HAVE_AUDIT |