Skip to content

Commit de0671e

Browse files
committed
Remove unnecessary casts in printfs
No functional change expected :)
1 parent 12ed81d commit de0671e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+221
-198
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
199199
AC_CHECK_SIZEOF(pid_t)
200200
AC_CHECK_SIZEOF(uid_t)
201201
AC_CHECK_SIZEOF(gid_t)
202+
AC_CHECK_SIZEOF(time_t)
203+
AC_CHECK_SIZEOF(rlim_t,,[
204+
#include <sys/time.h>
205+
#include <sys/resource.h>
206+
])
202207

203208
# ------------------------------------------------------------------------------
204209
# we use python to build the man page index, and for systemd-python

src/core/condition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static bool condition_test_capability(Condition *c) {
5959
cap_value_t value;
6060
FILE *f;
6161
char line[LINE_MAX];
62-
unsigned long long capabilities = (unsigned long long) -1;
62+
unsigned long long capabilities = -1;
6363

6464
assert(c);
6565
assert(c->parameter);

src/core/dbus-scope.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int bus_scope_set_transient_property(
138138
if (r < 0)
139139
return r;
140140

141-
unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec=%lluus\n", (unsigned long long) s->timeout_stop_usec);
141+
unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec="USEC_FMT"us\n", s->timeout_stop_usec);
142142
} else {
143143
r = sd_bus_message_skip(message, "t");
144144
if (r < 0)

src/core/execute.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ static int build_environment(
11731173
return -ENOMEM;
11741174
our_env[n_env++] = x;
11751175

1176-
if (asprintf(&x, "WATCHDOG_USEC=%llu", (unsigned long long) watchdog_usec) < 0)
1176+
if (asprintf(&x, "WATCHDOG_USEC="USEC_FMT, watchdog_usec) < 0)
11771177
return -ENOMEM;
11781178
our_env[n_env++] = x;
11791179
}
@@ -2139,7 +2139,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
21392139

21402140
for (i = 0; i < RLIM_NLIMITS; i++)
21412141
if (c->rlimit[i])
2142-
fprintf(f, "%s%s: %llu\n", prefix, rlimit_to_string(i), (unsigned long long) c->rlimit[i]->rlim_max);
2142+
fprintf(f, "%s%s: "RLIM_FMT"\n",
2143+
prefix, rlimit_to_string(i), c->rlimit[i]->rlim_max);
21432144

21442145
if (c->ioprio_set) {
21452146
_cleanup_free_ char *class_str = NULL;

src/core/socket.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
470470

471471
if (s->control_pid > 0)
472472
fprintf(f,
473-
"%sControl PID: %lu\n",
474-
prefix, (unsigned long) s->control_pid);
473+
"%sControl PID: "PID_FMT"\n",
474+
prefix, s->control_pid);
475475

476476
if (s->bind_to_device)
477477
fprintf(f,
@@ -1710,7 +1710,7 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
17101710
unit_serialize_item_format(u, f, "n-accepted", "%u", s->n_accepted);
17111711

17121712
if (s->control_pid > 0)
1713-
unit_serialize_item_format(u, f, "control-pid", "%lu", (unsigned long) s->control_pid);
1713+
unit_serialize_item_format(u, f, "control-pid", PID_FMT, s->control_pid);
17141714

17151715
if (s->control_command_id >= 0)
17161716
unit_serialize_item(u, f, "control-command", socket_exec_command_to_string(s->control_command_id));

src/core/swap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
609609

610610
if (s->control_pid > 0)
611611
fprintf(f,
612-
"%sControl PID: %lu\n",
613-
prefix, (unsigned long) s->control_pid);
612+
"%sControl PID: "PID_FMT"\n",
613+
prefix, s->control_pid);
614614

615615
exec_context_dump(&s->exec_context, f, prefix);
616616
kill_context_dump(&s->kill_context, f, prefix);
@@ -878,7 +878,7 @@ static int swap_serialize(Unit *u, FILE *f, FDSet *fds) {
878878
unit_serialize_item(u, f, "result", swap_result_to_string(s->result));
879879

880880
if (s->control_pid > 0)
881-
unit_serialize_item_format(u, f, "control-pid", "%lu", (unsigned long) s->control_pid);
881+
unit_serialize_item_format(u, f, "control-pid", PID_FMT, s->control_pid);
882882

883883
if (s->control_command_id >= 0)
884884
unit_serialize_item(u, f, "control-command", swap_exec_command_to_string(s->control_command_id));

src/core/unit-printf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
208208
if (r < 0)
209209
return -ENODATA;
210210

211-
asprintf(&printed, "%lu", (unsigned long) uid);
211+
asprintf(&printed, UID_FMT, uid);
212212
}
213213
}
214214

@@ -231,7 +231,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
231231
if (specifier == 'u')
232232
printed = strdup(username);
233233
else
234-
asprintf(&printed, "%lu", (unsigned long) uid);
234+
asprintf(&printed, UID_FMT, uid);
235235
}
236236

237237
if (!printed)

src/dbus1-generator/dbus1-generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int create_dbus_files(
9696
}
9797

9898
fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT "\n",
99-
(unsigned long) getuid(), run);
99+
getuid(), run);
100100
}
101101
}
102102

src/initctl/initctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ int main(int argc, char *argv[]) {
396396
if (server_init(&server, (unsigned) n) < 0)
397397
return EXIT_FAILURE;
398398

399-
log_debug("systemd-initctl running as pid %lu", (unsigned long) getpid());
399+
log_debug("systemd-initctl running as pid "PID_FMT, getpid());
400400

401401
sd_notify(false,
402402
"READY=1\n"
@@ -426,7 +426,7 @@ int main(int argc, char *argv[]) {
426426

427427
r = EXIT_SUCCESS;
428428

429-
log_debug("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
429+
log_debug("systemd-initctl stopped as pid "PID_FMT, getpid());
430430

431431
fail:
432432
sd_notify(false,

src/journal/journal-remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,8 @@ int main(int argc, char **argv) {
12101210
if (remoteserver_init(&s) < 0)
12111211
return EXIT_FAILURE;
12121212

1213-
log_debug("%s running as pid %lu",
1214-
program_invocation_short_name, (unsigned long) getpid());
1213+
log_debug("%s running as pid "PID_FMT,
1214+
program_invocation_short_name, getpid());
12151215
sd_notify(false,
12161216
"READY=1\n"
12171217
"STATUS=Processing requests...");

0 commit comments

Comments
 (0)