tree-wide: Use correct format specifiers

gcc will complain about all these with -Wformat-signedness.
This commit is contained in:
Jan Janssen 2022-08-29 13:07:11 +02:00
parent 125d108665
commit c0f86d66f3
55 changed files with 102 additions and 102 deletions

View File

@ -450,7 +450,7 @@ static const char *get_efi_arch(void) {
if (r == -ENOENT)
return EFI_MACHINE_TYPE_NAME;
if (r < 0) {
log_warning_errno(r, "Error reading EFI firmware word size, assuming '%u': %m", __WORDSIZE);
log_warning_errno(r, "Error reading EFI firmware word size, assuming '%i': %m", __WORDSIZE);
return EFI_MACHINE_TYPE_NAME;
}
@ -460,7 +460,7 @@ static const char *get_efi_arch(void) {
return "ia32";
log_warning(
"Unknown EFI firmware word size '%s', using default word size '%u' instead.",
"Unknown EFI firmware word size '%s', using default word size '%i' instead.",
platform_size,
__WORDSIZE);
#endif

View File

@ -375,7 +375,7 @@ static int open_dev_autofs(Manager *m) {
return -errno;
}
log_debug("Autofs kernel version %i.%i", param.ver_major, param.ver_minor);
log_debug("Autofs kernel version %u.%u", param.ver_major, param.ver_minor);
return m->dev_autofs_fd;
}
@ -429,7 +429,7 @@ static int autofs_protocol(int dev_autofs_fd, int ioctl_fd) {
minor = param.protosubver.sub_version;
log_debug("Autofs protocol version %i.%i", major, minor);
log_debug("Autofs protocol version %u.%u", major, minor);
return 0;
}

View File

@ -69,11 +69,11 @@ static int prepare_socket_bind_bpf(
if (allow_count > SOCKET_BIND_MAX_RULES)
return log_unit_full_errno(u, u ? LOG_ERR : LOG_WARNING, SYNTHETIC_ERRNO(EINVAL),
"bpf-socket-bind: Maximum number of socket bind rules=%u is exceeded", SOCKET_BIND_MAX_RULES);
"bpf-socket-bind: Maximum number of socket bind rules=%i is exceeded", SOCKET_BIND_MAX_RULES);
if (deny_count > SOCKET_BIND_MAX_RULES)
return log_unit_full_errno(u, u ? LOG_ERR : LOG_WARNING, SYNTHETIC_ERRNO(EINVAL),
"bpf-socket-bind: Maximum number of socket bind rules=%u is exceeded", SOCKET_BIND_MAX_RULES);
"bpf-socket-bind: Maximum number of socket bind rules=%i is exceeded", SOCKET_BIND_MAX_RULES);
obj = socket_bind_bpf__open();
if (!obj)

View File

@ -1599,7 +1599,7 @@ static void cgroup_context_apply(
if (unit_has_unified_memory_config(u)) {
val = c->memory_max;
log_cgroup_compat(u, "Applying MemoryMax=%" PRIi64 " as MemoryLimit=", val);
log_cgroup_compat(u, "Applying MemoryMax=%" PRIu64 " as MemoryLimit=", val);
} else
val = c->memory_limit;

View File

@ -2763,7 +2763,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
return log_error_errno(errno, "Reading from signal fd failed: %m");
}
if (n != sizeof(sfsi)) {
log_warning("Truncated read from signal fd (%zu bytes), ignoring!", n);
log_warning("Truncated read from signal fd (%zi bytes), ignoring!", n);
return 0;
}

View File

@ -496,7 +496,7 @@ static int service_add_fd_store_set(Service *s, FDSet *fds, const char *name, bo
if (r < 0)
return log_unit_error_errno(UNIT(s), r, "Failed to add fd to store: %m");
if (r > 0)
log_unit_debug(UNIT(s), "Added fd %u (%s) to fd store.", fd, strna(name));
log_unit_debug(UNIT(s), "Added fd %i (%s) to fd store.", fd, strna(name));
fd = -1;
}

View File

@ -2263,7 +2263,7 @@ void unit_start_on_failure(
}
if (n_jobs >= 0)
log_unit_debug(u, "Triggering %s dependencies done (%u %s).",
log_unit_debug(u, "Triggering %s dependencies done (%i %s).",
dependency_name, n_jobs, n_jobs == 1 ? "job" : "jobs");
}

View File

@ -202,7 +202,7 @@ static int make_userns(uid_t stored_uid, uid_t exposed_uid) {
return log_oom();
/* Now map the UID we are doing this for to the target UID. */
r = strextendf(&text, UID_FMT " " UID_FMT " " UID_FMT "\n", stored_uid, exposed_uid, 1);
r = strextendf(&text, UID_FMT " " UID_FMT " " UID_FMT "\n", stored_uid, exposed_uid, 1u);
if (r < 0)
return log_oom();
@ -221,7 +221,7 @@ static int make_userns(uid_t stored_uid, uid_t exposed_uid) {
/* Map nspawn's mapped root UID as identity mapping so that people can run nspawn uidmap mounted
* containers off $HOME, if they want. */
r = strextendf(&text, UID_FMT " " UID_FMT " " UID_FMT "\n", UID_MAPPED_ROOT, UID_MAPPED_ROOT, 1);
r = strextendf(&text, UID_FMT " " UID_FMT " " UID_FMT "\n", UID_MAPPED_ROOT, UID_MAPPED_ROOT, 1u);
if (r < 0)
return log_oom();

View File

@ -13,7 +13,7 @@ void source_free(RemoteSource *source) {
journal_importer_cleanup(&source->importer);
log_debug("Writer ref count %i", source->writer->n_ref);
log_debug("Writer ref count %u", source->writer->n_ref);
writer_unref(source->writer);
sd_event_source_unref(source->event);

View File

@ -1430,11 +1430,11 @@ static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *
assert(s);
if (s->namespace) {
log_error("Received SIGUSR1 signal from PID " PID_FMT ", but flushing runtime journals not supported for namespaced instances.", si->ssi_pid);
log_error("Received SIGUSR1 signal from PID %u, but flushing runtime journals not supported for namespaced instances.", si->ssi_pid);
return 0;
}
log_info("Received SIGUSR1 signal from PID " PID_FMT ", as request to flush runtime journal.", si->ssi_pid);
log_info("Received SIGUSR1 signal from PID %u, as request to flush runtime journal.", si->ssi_pid);
server_full_flush(s);
return 0;
@ -1466,7 +1466,7 @@ static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo *
assert(s);
log_info("Received SIGUSR2 signal from PID " PID_FMT ", as request to rotate journal, rotating.", si->ssi_pid);
log_info("Received SIGUSR2 signal from PID %u, as request to rotate journal, rotating.", si->ssi_pid);
server_full_rotate(s);
return 0;
@ -1575,7 +1575,7 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
assert(s);
log_debug("Received SIGRTMIN1 signal from PID " PID_FMT ", as request to sync.", si->ssi_pid );
log_debug("Received SIGRTMIN1 signal from PID %u, as request to sync.", si->ssi_pid);
server_full_sync(s);
return 0;

View File

@ -20,7 +20,7 @@
static bool arg_keep = false;
_noreturn_ static void log_assert_errno(const char *text, int error, const char *file, int line, const char *func) {
_noreturn_ static void log_assert_errno(const char *text, int error, const char *file, unsigned line, const char *func) {
log_internal(LOG_CRIT, error, file, line, func,
"'%s' failed at %s:%u (%s): %m", text, file, line, func);
abort();

View File

@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
dual_timestamp_get(&ts);
assert_se(asprintf(&test, "RANDOM=%lu", random() % RANDOM_RANGE));
assert_se(asprintf(&test, "RANDOM=%li", random() % RANDOM_RANGE));
iovec = IOVEC_MAKE_STRING(test);

View File

@ -139,7 +139,7 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
if (packet->ip.ihl < 5)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"ignoring packet: IPv4 IHL (%u words) invalid",
"ignoring packet: IPv4 IHL (%i words) invalid",
packet->ip.ihl);
hdrlen = packet->ip.ihl * 4;

View File

@ -207,7 +207,7 @@ static int dhcp6_client_set_duid_internal(
if (r < 0)
return log_dhcp6_client_errno(client, r, "Failed to validate length of DUID: %m");
log_dhcp6_client(client, "Using DUID of type %u of incorrect length, proceeding.", duid_type);
log_dhcp6_client(client, "Using DUID of type %i of incorrect length, proceeding.", duid_type);
}
client->duid.type = htobe16(duid_type);

View File

@ -247,13 +247,13 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
advertisement[7] = 0x00;
}
printf ("Received Router Advertisement with lifetime %u\n",
printf ("Received Router Advertisement with lifetime %i\n",
(advertisement[6] << 8) + advertisement[7]);
/* test only up to buf size, rest is not yet implemented */
for (i = 0; i < sizeof(buf); i++) {
if (!(i % 8))
printf("%3zd: ", i);
printf("%3zu: ", i);
printf("0x%02x", buf[i]);

View File

@ -655,7 +655,7 @@ TEST(ratelimit) {
assert_se(sd_event_source_is_ratelimited(s) == 0);
assert_se(count == 10);
log_info("ratelimit_io_handler: called %d times, event source not ratelimited", count);
log_info("ratelimit_io_handler: called %u times, event source not ratelimited", count);
assert_se(sd_event_source_set_ratelimit(s, 0, 0) >= 0);
assert_se(sd_event_source_set_ratelimit(s, 1 * USEC_PER_SEC, 5) >= 0);
@ -666,7 +666,7 @@ TEST(ratelimit) {
assert_se(sd_event_run(e, UINT64_MAX) >= 0);
assert_se(usleep(10) >= 0);
}
log_info("ratelimit_io_handler: called %d times, event source got ratelimited", count);
log_info("ratelimit_io_handler: called %u times, event source got ratelimited", count);
assert_se(count < 10);
s = sd_event_source_unref(s);
@ -680,7 +680,7 @@ TEST(ratelimit) {
assert_se(sd_event_run(e, UINT64_MAX) >= 0);
} while (!sd_event_source_is_ratelimited(s));
log_info("ratelimit_time_handler: called %d times, event source got ratelimited", count);
log_info("ratelimit_time_handler: called %u times, event source got ratelimited", count);
assert_se(count == 10);
/* In order to get rid of active rate limit client needs to disable it explicitly */

View File

@ -499,7 +499,7 @@ static void test_get_addresses(sd_netlink *rtnl) {
assert_se(ifindex > 0);
assert_se(IN_SET(family, AF_INET, AF_INET6));
log_info("got IPv%u address on ifindex %i", family == AF_INET ? 4: 6, ifindex);
log_info("got IPv%i address on ifindex %i", family == AF_INET ? 4 : 6, ifindex);
}
}

View File

@ -128,7 +128,7 @@ static void test_device_devnum(struct udev *udev) {
dev_t devnum = makedev(1, 3);
_cleanup_(udev_device_unrefp) struct udev_device *device;
log_info("/* %s, device %d:%d */", __func__, major(devnum), minor(devnum));
log_info("/* %s, device %u:%u */", __func__, major(devnum), minor(devnum));
device = udev_device_new_from_devnum(udev, 'c', devnum);
if (device)

View File

@ -478,9 +478,9 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
printf("%s - ", strna(i.id));
if (i.name)
printf("%s (%"PRIu32")\n", i.name, i.uid);
printf("%s (" UID_FMT ")\n", i.name, i.uid);
else
printf("%"PRIu32"\n", i.uid);
printf(UID_FMT "\n", i.uid);
if (timestamp_is_set(i.timestamp.realtime))
printf("\t Since: %s; %s\n",
@ -490,7 +490,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
if (i.leader > 0) {
_cleanup_free_ char *t = NULL;
printf("\t Leader: %"PRIu32, i.leader);
printf("\t Leader: " PID_FMT, i.leader);
(void) get_process_comm(i.leader, &t);
if (t)

View File

@ -776,7 +776,7 @@ static int manager_connect_console(Manager *m) {
if (SIGRTMIN + 1 > SIGRTMAX)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Not enough real-time signals available: %u-%u",
"Not enough real-time signals available: %i-%i",
SIGRTMIN, SIGRTMAX);
assert_se(ignore_signals(SIGRTMIN + 1) >= 0);

View File

@ -278,7 +278,7 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
if (r < 0)
return r;
if (asprintf(&sys_path, "/sys/dev/char/%d:%d", major(display_ctty), minor(display_ctty)) < 0)
if (asprintf(&sys_path, "/sys/dev/char/%u:%u", major(display_ctty), minor(display_ctty)) < 0)
return -ENOMEM;
r = readlink_value(sys_path, &tty);
if (r < 0)

View File

@ -841,7 +841,7 @@ int config_parse_macsec_key_id(
}
if (l > MACSEC_KEYID_LEN) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified KeyId= is larger then the allowed maximum (%zu > %u), ignoring: %s",
"Specified KeyId= is larger then the allowed maximum (%zu > %i), ignoring: %s",
l, MACSEC_KEYID_LEN, rvalue);
return 0;
}

View File

@ -135,7 +135,7 @@ static int dump_link_description(sd_bus *bus, char **patterns) {
name = json_variant_string(json_variant_by_key(i, "Name"));
index = json_variant_integer(json_variant_by_key(i, "Index"));
xsprintf(ifindex_str, "%ji", index);
xsprintf(ifindex_str, "%" PRIi64, index);
if (!strv_fnmatch_full(patterns, ifindex_str, 0, &pos) &&
!strv_fnmatch_full(patterns, name, 0, &pos)) {

View File

@ -38,9 +38,9 @@ int can_set_netlink_message(Link *link, sd_netlink_message *m) {
.sjw = link->network->can_sync_jump_width,
};
log_link_debug(link, "Setting bitrate = %d bit/s", bt.bitrate);
log_link_debug(link, "Setting bitrate = %u bit/s", bt.bitrate);
if (link->network->can_sample_point > 0)
log_link_debug(link, "Setting sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
log_link_debug(link, "Setting sample point = %u.%u%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default sample point");
@ -69,9 +69,9 @@ int can_set_netlink_message(Link *link, sd_netlink_message *m) {
.sjw = link->network->can_data_sync_jump_width,
};
log_link_debug(link, "Setting data bitrate = %d bit/s", bt.bitrate);
log_link_debug(link, "Setting data bitrate = %u bit/s", bt.bitrate);
if (link->network->can_data_sample_point > 0)
log_link_debug(link, "Setting data sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
log_link_debug(link, "Setting data sample point = %u.%u%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default data sample point");

View File

@ -477,7 +477,7 @@ static int dhcp_pd_get_preferred_subnet_prefix(
r = dhcp_pd_calculate_subnet_prefix(pd_prefix, pd_prefix_len, link->network->dhcp_pd_subnet_id, &prefix);
if (r < 0)
return log_link_warning_errno(link, r,
"subnet id %" PRIu64 " is out of range. Only have %" PRIu64 " subnets.",
"subnet id %" PRIi64 " is out of range. Only have %" PRIu64 " subnets.",
link->network->dhcp_pd_subnet_id, UINT64_C(1) << (64 - pd_prefix_len));
*ret = prefix;

View File

@ -711,7 +711,7 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
return log_link_error_errno(link, n, "Failed to get RDNSS addresses: %m");
if (n >= (int) NDISC_RDNSS_MAX) {
log_link_warning(link, "Too many RDNSS records per link. Only first %i records will be used.", NDISC_RDNSS_MAX);
log_link_warning(link, "Too many RDNSS records per link. Only first %u records will be used.", NDISC_RDNSS_MAX);
n = NDISC_RDNSS_MAX;
}
@ -805,7 +805,7 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
return log_link_error_errno(link, r, "Failed to get DNSSL addresses: %m");
if (strv_length(l) >= NDISC_DNSSL_MAX) {
log_link_warning(link, "Too many DNSSL records per link. Only first %i records will be used.", NDISC_DNSSL_MAX);
log_link_warning(link, "Too many DNSSL records per link. Only first %u records will be used.", NDISC_DNSSL_MAX);
STRV_FOREACH(j, l + NDISC_DNSSL_MAX)
*j = mfree(*j);
}

View File

@ -361,7 +361,7 @@ static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Lin
(void) route_flags_to_string_alloc(nexthop->flags, &flags);
HASHMAP_FOREACH(nhg, nexthop->group)
(void) strextendf_with_separator(&group, ",", "%"PRIu32":%"PRIu32, nhg->id, nhg->weight+1);
(void) strextendf_with_separator(&group, ",", "%"PRIu32":%"PRIu32, nhg->id, nhg->weight+1u);
log_link_debug(link, "%s %s nexthop (%s): id: %"PRIu32", gw: %s, blackhole: %s, group: %s, flags: %s",
str, strna(network_config_source_to_string(nexthop->source)), strna(state),

View File

@ -592,7 +592,7 @@ static void log_route_debug(const Route *route, const char *str, const Link *lin
if (m->ifname)
(void) strextend(&gw_alloc, "@", m->ifname);
else if (m->ifindex > 0)
(void) strextendf(&gw_alloc, "@%"PRIu32, m->ifindex);
(void) strextendf(&gw_alloc, "@%i", m->ifindex);
/* See comments in config_parse_multipath_route(). */
(void) strextendf(&gw_alloc, ":%"PRIu32, m->weight + 1);
}
@ -1706,7 +1706,7 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
return 0;
} else if (r >= 0) {
if (ifindex <= 0) {
log_warning("rtnl: received route message with invalid ifindex %d, ignoring.", ifindex);
log_warning("rtnl: received route message with invalid ifindex %u, ignoring.", ifindex);
return 0;
}
@ -1715,7 +1715,7 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
/* when enumerating we might be out of sync, but we will
* get the route again, so just ignore it */
if (!m->enumerating)
log_warning("rtnl: received route message for link (%d) we do not know about, ignoring", ifindex);
log_warning("rtnl: received route message for link (%u) we do not know about, ignoring", ifindex);
return 0;
}
}

View File

@ -354,7 +354,7 @@ static int oci_oom_score_adj(const char *name, JsonVariant *v, JsonDispatchFlags
k = json_variant_integer(v);
if (k < OOM_SCORE_ADJ_MIN || k > OOM_SCORE_ADJ_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
"oomScoreAdj value out of range: %ji", k);
"oomScoreAdj value out of range: %" PRIi64, k);
s->oom_score_adjust = (int) k;
s->oom_score_adjust_set = true;
@ -373,7 +373,7 @@ static int oci_uid_gid(const char *name, JsonVariant *v, JsonDispatchFlags flags
u = (uid_t) k;
if ((uint64_t) u != k)
return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
"UID/GID out of range: %ji", k);
"UID/GID out of range: %" PRIu64, k);
if (!uid_is_valid(u))
return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
@ -712,7 +712,7 @@ static int oci_uid_gid_range(const char *name, JsonVariant *v, JsonDispatchFlags
u = (uid_t) k;
if ((uint64_t) u != k)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
"UID/GID out of range: %ji", k);
"UID/GID out of range: %" PRIu64, k);
if (u == 0)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
"UID/GID range can't be zero.");
@ -811,7 +811,7 @@ static int oci_device_major(const char *name, JsonVariant *v, JsonDispatchFlags
k = json_variant_unsigned(v);
if (!DEVICE_MAJOR_VALID(k))
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
"Device major %ji out of range.", k);
"Device major %" PRIu64 " out of range.", k);
*u = (unsigned) k;
return 0;
@ -826,7 +826,7 @@ static int oci_device_minor(const char *name, JsonVariant *v, JsonDispatchFlags
k = json_variant_unsigned(v);
if (!DEVICE_MINOR_VALID(k))
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
"Device minor %ji out of range.", k);
"Device minor %" PRIu64 " out of range.", k);
*u = (unsigned) k;
return 0;
@ -1192,7 +1192,7 @@ static int oci_cgroup_memory_limit(const char *name, JsonVariant *v, JsonDispatc
k = json_variant_unsigned(v);
if (k >= UINT64_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
"Memory limit too large: %ji", k);
"Memory limit too large: %" PRIu64, k);
*m = (uint64_t) k;
return 0;

View File

@ -4934,7 +4934,7 @@ static int run_container(
if (l < 0)
return log_error_errno(errno, "Failed to read cgroup mode: %m");
if (l != sizeof(arg_unified_cgroup_hierarchy))
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading cgroup mode (%zu bytes).%s",
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading cgroup mode (%zi bytes).%s",
l, l == 0 ? " The child is most likely dead." : "");
}

View File

@ -325,8 +325,8 @@ char* dns_resource_key_to_string(const DnsResourceKey *key, char *buf, size_t bu
(void) snprintf(buf, buf_size, "%s %s%s%.0u %s%s%.0u",
dns_resource_key_name(key),
strempty(c), c ? "" : "CLASS", c ? 0 : key->class,
strempty(t), t ? "" : "TYPE", t ? 0 : key->type);
strempty(c), c ? "" : "CLASS", c ? 0u : key->class,
strempty(t), t ? "" : "TYPE", t ? 0u : key->type);
return ans;
}

View File

@ -870,7 +870,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
p->ifindex = manager_find_ifindex(m, p->family, &p->destination);
}
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%i, fragsize=%zu, sender=%s, destination=%s",
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%u, fragsize=%zu, sender=%s, destination=%s",
dns_protocol_to_string(protocol), p->size, p->ifindex, p->ttl, p->fragsize,
IN_ADDR_TO_STRING(p->family, &p->sender),
IN_ADDR_TO_STRING(p->family, &p->destination));

View File

@ -75,7 +75,7 @@ static int find_device(
assert(event);
assert(ret);
if (asprintf(&sysname, "rfkill%i", event->idx) < 0)
if (asprintf(&sysname, "rfkill%u", event->idx) < 0)
return log_oom();
r = sd_device_new_from_subsystem_sysname(&device, "rfkill", sysname);
@ -176,7 +176,7 @@ static int load_state(Context *c, const struct rfkill_event *event) {
ssize_t l = write(c->rfkill_fd, &we, sizeof we);
if (l < 0)
return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
return log_error_errno(errno, "Failed to restore rfkill state for %u: %m", event->idx);
if ((size_t)l < RFKILL_EVENT_SIZE_V1) /* l cannot be < 0 here. Cast to fix -Werror=sign-compare */
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).",
@ -347,29 +347,29 @@ static int run(int argc, char *argv[]) {
const char *type = rfkill_type_to_string(event.type);
if (!type) {
log_debug("An rfkill device of unknown type %i discovered, ignoring.", event.type);
log_debug("An rfkill device of unknown type %u discovered, ignoring.", event.type);
continue;
}
switch (event.op) {
case RFKILL_OP_ADD:
log_debug("A new rfkill device has been added with index %i and type %s.", event.idx, type);
log_debug("A new rfkill device has been added with index %u and type %s.", event.idx, type);
(void) load_state(&c, &event);
break;
case RFKILL_OP_DEL:
log_debug("An rfkill device has been removed with index %i and type %s", event.idx, type);
log_debug("An rfkill device has been removed with index %u and type %s", event.idx, type);
(void) save_state_cancel(&c, &event);
break;
case RFKILL_OP_CHANGE:
log_debug("An rfkill device has changed state with index %i and type %s", event.idx, type);
log_debug("An rfkill device has changed state with index %u and type %s", event.idx, type);
(void) save_state_queue(&c, &event);
break;
default:
log_debug("Unknown event %i from /dev/rfkill for index %i and type %s, ignoring.", event.op, event.idx, type);
log_debug("Unknown event %u from /dev/rfkill for index %u and type %s, ignoring.", event.op, event.idx, type);
break;
}
}

View File

@ -1318,7 +1318,7 @@ static int start_transient_service(
log_info("Finished with result: %s", strna(c.result));
if (c.exit_code == CLD_EXITED)
log_info("Main processes terminated with: code=%s/status=%i",
log_info("Main processes terminated with: code=%s/status=%u",
sigchld_code_to_string(c.exit_code), c.exit_status);
else if (c.exit_code > 0)
log_info("Main processes terminated with: code=%s/status=%s",

View File

@ -378,7 +378,7 @@ int unit_show_processes(
if (r == -ENOMEM)
goto finish;
if (r < 0)
log_warning_errno(r, "Invalid process description in GetUnitProcesses reply: cgroup=\"%s\" pid="PID_FMT" command=\"%s\", ignoring: %m",
log_warning_errno(r, "Invalid process description in GetUnitProcesses reply: cgroup=\"%s\" pid=%u command=\"%s\", ignoring: %m",
path, pid, name);
}

View File

@ -62,9 +62,9 @@ char *cpu_set_to_range_string(const CPUSet *set) {
return NULL;
if (range_end > range_start)
r = sprintf(str + len, len > 0 ? " %d-%d" : "%d-%d", range_start, range_end);
r = sprintf(str + len, len > 0 ? " %u-%u" : "%u-%u", range_start, range_end);
else
r = sprintf(str + len, len > 0 ? " %d" : "%d", range_start);
r = sprintf(str + len, len > 0 ? " %u" : "%u", range_start);
assert_se(r > 0);
len += r;
}
@ -74,9 +74,9 @@ char *cpu_set_to_range_string(const CPUSet *set) {
return NULL;
if (range_end > range_start)
r = sprintf(str + len, len > 0 ? " %d-%d" : "%d-%d", range_start, range_end);
r = sprintf(str + len, len > 0 ? " %u-%u" : "%u-%u", range_start, range_end);
else
r = sprintf(str + len, len > 0 ? " %d" : "%d", range_start);
r = sprintf(str + len, len > 0 ? " %u" : "%u", range_start);
assert_se(r > 0);
}

View File

@ -904,7 +904,7 @@ int64_t json_variant_integer(JsonVariant *v) {
if (v->value.unsig <= INT64_MAX)
return (int64_t) v->value.unsig;
log_debug("Unsigned integer %ju requested as signed integer and out of range, returning 0.", v->value.unsig);
log_debug("Unsigned integer %" PRIu64 " requested as signed integer and out of range, returning 0.", v->value.unsig);
return 0;
case JSON_VARIANT_REAL: {
@ -946,7 +946,7 @@ uint64_t json_variant_unsigned(JsonVariant *v) {
if (v->value.integer >= 0)
return (uint64_t) v->value.integer;
log_debug("Signed integer %ju requested as unsigned integer and out of range, returning 0.", v->value.integer);
log_debug("Signed integer %" PRIi64 " requested as unsigned integer and out of range, returning 0.", v->value.integer);
return 0;
case JSON_VARIANT_UNSIGNED:
@ -996,7 +996,7 @@ double json_variant_real(JsonVariant *v) {
if ((int64_t) converted == v->value.integer)
return converted;
log_debug("Signed integer %ji requested as real, and cannot be converted losslessly, returning 0.", v->value.integer);
log_debug("Signed integer %" PRIi64 " requested as real, and cannot be converted losslessly, returning 0.", v->value.integer);
return 0.0;
}
@ -1006,7 +1006,7 @@ double json_variant_real(JsonVariant *v) {
if ((uint64_t) converted == v->value.unsig)
return converted;
log_debug("Unsigned integer %ju requested as real, and cannot be converted losslessly, returning 0.", v->value.unsig);
log_debug("Unsigned integer %" PRIu64 " requested as real, and cannot be converted losslessly, returning 0.", v->value.unsig);
return 0.0;
}

View File

@ -1060,7 +1060,7 @@ static int make_userns(uid_t uid_shift, uid_t uid_range, RemountIdmapFlags flags
/* Allocates a userns file descriptor with the mapping we need. For this we'll fork off a child
* process whose only purpose is to give us a new user namespace. It's killed when we got it. */
if (asprintf(&line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, uid_shift, uid_range) < 0)
if (asprintf(&line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0u, uid_shift, uid_range) < 0)
return log_oom_debug();
/* If requested we'll include an entry in the mapping so that the host root user can make changes to
@ -1076,7 +1076,7 @@ static int make_userns(uid_t uid_shift, uid_t uid_range, RemountIdmapFlags flags
if (flags & REMOUNT_IDMAP_HOST_ROOT)
if (strextendf(&line,
UID_FMT " " UID_FMT " " UID_FMT "\n",
UID_MAPPED_ROOT, 0, 1) < 0)
UID_MAPPED_ROOT, 0u, 1u) < 0)
return log_oom_debug();
/* We always assign the same UID and GID ranges */

View File

@ -395,13 +395,13 @@ int config_parse_sr_iov_uint32(
if (streq(lvalue, "VLANId")) {
if (k == 0 || k > 4095) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV VLANId: %d", k);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV VLANId: %u", k);
return 0;
}
sr_iov->vlan = k;
} else if (streq(lvalue, "VirtualFunction")) {
if (k >= INT_MAX) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV virtual function: %d", k);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV virtual function: %u", k);
return 0;
}
sr_iov->vf = k;

View File

@ -52,7 +52,7 @@ static int get_watchdog_sysfs_path(const char *filename, char **ret_path) {
if (!S_ISCHR(st.st_mode))
return -EBADF;
if (asprintf(ret_path, "/sys/dev/char/%d:%d/%s", major(st.st_rdev), minor(st.st_rdev), filename) < 0)
if (asprintf(ret_path, "/sys/dev/char/%u:%u/%s", major(st.st_rdev), minor(st.st_rdev), filename) < 0)
return -ENOMEM;
return 0;

View File

@ -1256,7 +1256,7 @@ static int add_group(Item *i) {
*/
if (r > 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Failed to create %s: please create GID %d",
"Failed to create %s: please create GID " GID_FMT,
i->name, i->gid);
if (r == 0)
return 0;

View File

@ -322,7 +322,7 @@ static void test_config_parse_one(unsigned i, const char *s) {
{}
};
log_info("== %s[%i] ==", __func__, i);
log_info("== %s[%u] ==", __func__, i);
assert_se(fmkostemp_safe(name, "r+", &f) == 0);
assert_se(fwrite(s, strlen(s), 1, f) == 1);

View File

@ -567,7 +567,7 @@ TEST(dns_name_change_suffix) {
static void test_dns_name_suffix_one(const char *name, unsigned n_labels, const char *result, int ret) {
const char *p = NULL;
log_info("%s, %d, →%s, %d", name, n_labels, strnull(result), ret);
log_info("%s, %u, → %s, %d", name, n_labels, strnull(result), ret);
assert_se(ret == dns_name_suffix(name, n_labels, &p));
assert_se(streq_ptr(p, result));

View File

@ -33,7 +33,7 @@ static void test_xescape_full_one(bool eight_bits) {
assert_se(t = xescape_full("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", "b", i, flags));
log_info("%02d: <%s>", i, t);
log_info("%02u: <%s>", i, t);
if (i >= full_fit)
assert_se(streq(t, escaped));
@ -51,7 +51,7 @@ static void test_xescape_full_one(bool eight_bits) {
assert_se(q = xescape_full("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", "b", i,
flags | XESCAPE_FORCE_ELLIPSIS));
log_info("%02d: <%s>", i, q);
log_info("%02u: <%s>", i, q);
if (i > 0)
assert_se(endswith(q, "."));
assert_se(strlen(q) <= i);

View File

@ -30,10 +30,10 @@ TEST(parse_sleep_config) {
his = strv_join(sleep_config->states[SLEEP_HIBERNATE], ", ");
hym = strv_join(sleep_config->modes[SLEEP_HYBRID_SLEEP], ", ");
hys = strv_join(sleep_config->states[SLEEP_HYBRID_SLEEP], ", ");
log_debug(" allow_suspend: %u", sleep_config->allow[SLEEP_SUSPEND]);
log_debug(" allow_hibernate: %u", sleep_config->allow[SLEEP_HIBERNATE]);
log_debug(" allow_s2h: %u", sleep_config->allow[SLEEP_SUSPEND_THEN_HIBERNATE]);
log_debug(" allow_hybrid_sleep: %u", sleep_config->allow[SLEEP_HYBRID_SLEEP]);
log_debug(" allow_suspend: %s", yes_no(sleep_config->allow[SLEEP_SUSPEND]));
log_debug(" allow_hibernate: %s", yes_no(sleep_config->allow[SLEEP_HIBERNATE]));
log_debug(" allow_s2h: %s", yes_no(sleep_config->allow[SLEEP_SUSPEND_THEN_HIBERNATE]));
log_debug(" allow_hybrid_sleep: %s", yes_no(sleep_config->allow[SLEEP_HYBRID_SLEEP]));
log_debug(" suspend modes: %s", sum);
log_debug(" states: %s", sus);
log_debug(" hibernate modes: %s", him);

View File

@ -34,7 +34,7 @@ TEST(string_erase) {
}
static void test_free_and_strndup_one(char **t, const char *src, size_t l, const char *expected, bool change) {
log_debug("%s: \"%s\", \"%s\", %zd (expect \"%s\", %s)",
log_debug("%s: \"%s\", \"%s\", %zu (expect \"%s\", %s)",
__func__, strnull(*t), strnull(src), l, strnull(expected), yes_no(change));
int r = free_and_strndup(t, src, l);

View File

@ -536,11 +536,11 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
manager_adjust_poll(m, offset, spike);
log_debug("NTP response:\n"
" leap : %u\n"
" version : %u\n"
" mode : %u\n"
" leap : %i\n"
" version : %i\n"
" mode : %i\n"
" stratum : %u\n"
" precision : %.6f sec (%d)\n"
" precision : %.6f sec (%i)\n"
" root distance: %.6f sec\n"
" reference : %.4s\n"
" origin : %.3f\n"

View File

@ -117,7 +117,7 @@ static void dmi_print_memory_size(
code <<= 10;
if (slot_num >= 0)
printf("%s_%u_%s=%"PRIu64"\n", attr_prefix, slot_num, attr_suffix, code);
printf("%s_%i_%s=%"PRIu64"\n", attr_prefix, slot_num, attr_suffix, code);
else
printf("%s_%s=%"PRIu64"\n", attr_prefix, attr_suffix, code);
}

View File

@ -284,7 +284,7 @@ static int scsi_inquiry(struct scsi_id_device *dev_scsi, int fd,
if (buflen > SCSI_INQ_BUFF_LEN)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"buflen %d too long", buflen);
"buflen %u too long", buflen);
resend:
if (dev_scsi->use_sg == 4) {
@ -764,7 +764,7 @@ int scsi_std_inquiry(struct scsi_id_device *dev_scsi, const char *devname) {
err = 2;
goto out;
}
sprintf(dev_scsi->kernel,"%d:%d", major(statbuf.st_rdev),
sprintf(dev_scsi->kernel,"%u:%u", major(statbuf.st_rdev),
minor(statbuf.st_rdev));
memzero(buf, SCSI_INQ_BUFF_LEN);

View File

@ -288,7 +288,7 @@ static bool test_pointers(sd_device *dev,
num_well_known_keys++;
if (num_well_known_keys >= 4 || num_joystick_buttons + num_joystick_axes < 2) {
log_device_debug(dev, "Input device has %zd joystick buttons and %zd axes but also %zd keyboard key sets, "
log_device_debug(dev, "Input device has %zu joystick buttons and %zu axes but also %zu keyboard key sets, "
"assuming this is a keyboard, not a joystick.",
num_joystick_buttons, num_joystick_axes, num_well_known_keys);
is_joystick = false;

View File

@ -78,11 +78,11 @@ static int map_keycode(sd_device *dev, int fd, int scancode, const char *keycode
map.scan = scancode;
map.key = keycode_num;
log_device_debug(dev, "keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
log_device_debug(dev, "keyboard: mapping scan code %u (0x%x) to key code %u (0x%x)",
map.scan, map.scan, map.key, map.key);
if (ioctl(fd, EVIOCSKEYCODE, &map) < 0)
return log_device_error_errno(dev, errno, "Failed to call EVIOCSKEYCODE with scan code 0x%x, and key code %d: %m", map.scan, map.key);
return log_device_error_errno(dev, errno, "Failed to call EVIOCSKEYCODE with scan code 0x%x, and key code %u: %m", map.scan, map.key);
return 0;
}

View File

@ -938,7 +938,7 @@ static int names_mac(sd_device *dev, const LinkInfo *info) {
return log_device_debug_errno(dev, r, "Failed to parse addr_assign_type: %m");
if (i != NET_ADDR_PERM)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
"addr_assign_type=%d, MAC address is not permanent.", i);
"addr_assign_type=%u, MAC address is not permanent.", i);
return 0;
}

View File

@ -374,7 +374,7 @@ static sd_device *handle_scsi_default(sd_device *parent, char **path) {
return hostdev;
host -= basenum;
path_prepend(path, "scsi-%u:%u:%u:%u", host, bus, target, lun);
path_prepend(path, "scsi-%i:%i:%i:%i", host, bus, target, lun);
return hostdev;
}

View File

@ -292,7 +292,7 @@ static int builtin_usb_id(sd_device *dev, sd_netlink **rtnl, int argc, char *arg
} else
set_usb_iftype(type_str, if_class_num, sizeof(type_str)-1);
log_device_debug(dev_interface, "if_class:%d protocol:%d", if_class_num, protocol);
log_device_debug(dev_interface, "if_class:%u protocol:%i", if_class_num, protocol);
/* usb device directory */
r = sd_device_get_parent_with_subsystem_devtype(dev_interface, "usb", "usb_device", &dev_usb);

View File

@ -55,7 +55,7 @@ static void test_xdg_desktop_parse_one(unsigned i, const char *s) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(xdg_autostart_service_freep) XdgAutostartService *service = NULL;
log_info("== %s[%i] ==", __func__, i);
log_info("== %s[%u] ==", __func__, i);
assert_se(fmkostemp_safe(name, "r+", &f) == 0);
assert_se(fwrite(s, strlen(s), 1, f) == 1);