Remove unnecessary casts in printfs

No functional change expected :)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2014-04-25 07:45:15 -04:00
parent 12ed81d9c8
commit de0671ee7f
64 changed files with 221 additions and 198 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;

View File

@@ -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));

View File

@@ -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));

View File

@@ -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)

View File

@@ -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);
}
}

View File

@@ -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,

View File

@@ -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...");

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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:

View File

@@ -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))

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);

Some files were not shown because too many files have changed in this diff Show More