Merge pull request #24499 from medhefgo/format-signedness

meson: Compile with -Werror=format-signedness
This commit is contained in:
Yu Watanabe
2022-08-31 18:46:27 +09:00
committed by GitHub
82 changed files with 171 additions and 163 deletions
+1 -1
View File
@@ -347,7 +347,6 @@ endif
# Those generate many false positives, and we do not want to change the code to
# avoid them.
basic_disabled_warnings = [
'-Wno-format-signedness',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
]
@@ -356,6 +355,7 @@ possible_common_cc_flags = [
'-Wdate-time',
'-Wendif-labels',
'-Werror=format=2',
'-Werror=format-signedness',
'-Werror=implicit-function-declaration',
'-Werror=incompatible-pointer-types',
'-Werror=int-conversion',
+4 -4
View File
@@ -13,12 +13,12 @@
#include <unistd.h>
/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
#define HOME_UID_MIN 60001
#define HOME_UID_MAX 60513
#define HOME_UID_MIN ((uid_t) 60001)
#define HOME_UID_MAX ((uid_t) 60513)
/* Users mapped from host into a container */
#define MAP_UID_MIN 60514
#define MAP_UID_MAX 60577
#define MAP_UID_MIN ((uid_t) 60514)
#define MAP_UID_MAX ((uid_t) 60577)
bool uid_is_valid(uid_t uid);
+2 -2
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
+5 -3
View File
@@ -631,7 +631,7 @@ static void display(Hashmap *a) {
if (on_tty()) {
const char *on, *off;
unsigned cpu_len = arg_cpu_type == CPU_PERCENT ? 6 : maxtcpu;
int cpu_len = arg_cpu_type == CPU_PERCENT ? 6 : maxtcpu;
path_columns = columns() - 36 - cpu_len;
if (path_columns < 10)
@@ -685,7 +685,9 @@ static void display(Hashmap *a) {
else
fputs(" -", stdout);
} else
printf(" %*s", maxtcpu, MAYBE_FORMAT_TIMESPAN((usec_t) (g->cpu_usage / NSEC_PER_USEC), 0));
printf(" %*s",
(int) maxtcpu,
MAYBE_FORMAT_TIMESPAN((usec_t) (g->cpu_usage / NSEC_PER_USEC), 0));
printf(" %8s", MAYBE_FORMAT_BYTES(g->memory_valid, g->memory));
printf(" %8s", MAYBE_FORMAT_BYTES(g->io_valid, g->io_input_bps));
@@ -1086,7 +1088,7 @@ static int run(int argc, char *argv[]) {
default:
if (key < ' ')
fprintf(stdout, "\nUnknown key '\\x%x'. Ignoring.", key);
fprintf(stdout, "\nUnknown key '\\x%x'. Ignoring.", (unsigned) key);
else
fprintf(stdout, "\nUnknown key '%c'. Ignoring.", key);
fflush(stdout);
+2 -2
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;
}
+2 -2
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)
+1 -1
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;
+1 -1
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;
}
+1 -1
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;
}
+1 -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");
}
+2 -2
View File
@@ -43,8 +43,8 @@
/* internal helper */
#define ANY_LUKS "LUKS"
/* as in src/cryptsetup.h */
#define CRYPT_SECTOR_SIZE 512
#define CRYPT_MAX_SECTOR_SIZE 4096
#define CRYPT_SECTOR_SIZE 512U
#define CRYPT_MAX_SECTOR_SIZE 4096U
typedef enum PassphraseType {
PASSPHRASE_NONE,
+1 -1
View File
@@ -161,7 +161,7 @@ static int show_menu(char **x, unsigned n_columns, unsigned width, unsigned perc
if (!e)
return log_oom();
printf("%4zu) %-*s", j * per_column + i + 1, width, e);
printf("%4zu) %-*s", j * per_column + i + 1, (int) width, e);
}
putchar('\n');
+2 -2
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();
+1 -1
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);
+4 -4
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;
+1 -1
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();
+1 -1
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);
+1 -1
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;
+1 -1
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);
+2 -2
View File
@@ -339,13 +339,13 @@ static void test_option_set(void) {
if (verbose)
printf("%2d: 0x%02x(0x%02x) (options)\n", 9, result->options[9],
SD_DHCP_OPTION_END);
(unsigned) SD_DHCP_OPTION_END);
assert_se(result->options[9] == SD_DHCP_OPTION_END);
if (verbose)
printf("%2d: 0x%02x(0x%02x) (options)\n", 10, result->options[10],
SD_DHCP_OPTION_PAD);
(unsigned) SD_DHCP_OPTION_PAD);
assert_se(result->options[10] == SD_DHCP_OPTION_PAD);
+2 -2
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]);
+1 -1
View File
@@ -1013,7 +1013,7 @@ void bus_match_dump(FILE *out, struct bus_match_node *node, unsigned level) {
if (!node)
return;
fprintf(out, "%*s[%s]", 2 * level, "", bus_match_node_type_to_string(node->type, buf, sizeof(buf)));
fprintf(out, "%*s[%s]", 2 * (int) level, "", bus_match_node_type_to_string(node->type, buf, sizeof(buf)));
if (node->type == BUS_MATCH_VALUE) {
if (node->parent->type == BUS_MATCH_MESSAGE_TYPE)
+3 -3
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 */
@@ -81,8 +81,8 @@ int journal_file_hmac_start(JournalFile *f) {
err = gcry_md_setkey(f->hmac, key, sizeof(key));
if (gcry_err_code(err) != GPG_ERR_NO_ERROR)
return log_debug_errno(SYNTHETIC_ERRNO(EIO),
"gcry_md_setkey() failed with error code: %d",
gcry_err_code(err));
"gcry_md_setkey() failed with error code: %s",
gcry_strerror(err));
f->hmac_running = true;
@@ -16,8 +16,8 @@ TEST(journal_print) {
assert_se(sd_journal_print(LOG_INFO, "XXX") == 0);
assert_se(sd_journal_print(LOG_INFO, "%s", "YYY") == 0);
assert_se(sd_journal_print(LOG_INFO, "X%4094sY", "ZZZ") == 0);
assert_se(sd_journal_print(LOG_INFO, "X%*sY", LONG_LINE_MAX - 8 - 3, "ZZZ") == 0);
assert_se(sd_journal_print(LOG_INFO, "X%*sY", LONG_LINE_MAX - 8 - 2, "ZZZ") == -ENOBUFS);
assert_se(sd_journal_print(LOG_INFO, "X%*sY", (int) LONG_LINE_MAX - 8 - 3, "ZZZ") == 0);
assert_se(sd_journal_print(LOG_INFO, "X%*sY", (int) LONG_LINE_MAX - 8 - 2, "ZZZ") == -ENOBUFS);
}
TEST(journal_send) {
+1 -1
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);
}
}
+1 -1
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)
+3 -3
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)
+1 -1
View File
@@ -65,7 +65,7 @@
* to store arbitrary amounts either. As we are not stingy here, we
* allow 4k.
*/
#define WALL_MESSAGE_MAX 4096
#define WALL_MESSAGE_MAX 4096U
#define SHUTDOWN_SCHEDULE_FILE "/run/systemd/shutdown/scheduled"
+1 -1
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);
+1 -1
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)
+2 -2
View File
@@ -4,8 +4,8 @@
#include "conf-parser.h"
#include "netdev.h"
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128U
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63U
typedef struct Bridge {
NetDev meta;
+1 -1
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;
}
+1 -1
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)) {
+4 -4
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");
@@ -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;
+2 -2
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);
}
+1 -1
View File
@@ -45,7 +45,7 @@
#include "util.h"
/* Let's assume that anything above this number is a user misconfiguration. */
#define MAX_NTP_SERVERS 128
#define MAX_NTP_SERVERS 128U
static int network_resolve_netdev_one(Network *network, const char *name, NetDevKind kind, NetDev **ret) {
const char *kind_string;
+1 -1
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),
+3 -3
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;
}
}
+6 -6
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;
+1 -1
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." : "");
}
+1 -1
View File
@@ -1396,7 +1396,7 @@ static int status_print_strv_ifindex(int ifindex, const char *ifname, char **p)
printf(" %s", *i);
position = size_add(size_add(position, 1), our_len);
} else {
printf("\n%*s%s", indent, "", *i);
printf("\n%*s%s", (int) indent, "", *i);
position = size_add(our_len, indent);
}
}
+2 -2
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;
}
+1 -1
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));
+7 -7
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;
}
}
+1 -1
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",
+1 -1
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);
}
+1 -1
View File
@@ -74,7 +74,7 @@ static void show_pid_array(
else
printf("%s%s", prefix, special_glyph(((more || i < n_pids-1) ? SPECIAL_GLYPH_TREE_BRANCH : SPECIAL_GLYPH_TREE_RIGHT)));
printf("%s%*"PID_PRI" %s%s\n", ansi_grey(), pid_width, pids[i], strna(t), ansi_normal());
printf("%s%*"PID_PRI" %s%s\n", ansi_grey(), (int) pid_width, pids[i], strna(t), ansi_normal());
}
}
+4 -4
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);
}
+2 -1
View File
@@ -60,7 +60,8 @@ int efi_loader_get_boot_usec(usec_t *ret_firmware, usec_t *ret_loader) {
int efi_loader_get_device_part_uuid(sd_id128_t *ret) {
_cleanup_free_ char *p = NULL;
int r, parsed[16];
int r;
unsigned parsed[16];
if (!is_efi_boot())
return -EOPNOTSUPP;
+1 -1
View File
@@ -23,7 +23,7 @@
#define LINE_CHUNK 8*1024u
/* The maximum number of fields in an entry */
#define ENTRY_FIELD_COUNT_MAX 1024
#define ENTRY_FIELD_COUNT_MAX 1024u
typedef struct JournalImporter {
int fd;
+5 -5
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;
}
@@ -1512,7 +1512,7 @@ static void json_format_string(FILE *f, const char *q, JsonFormatFlags flags) {
default:
if ((signed char) *q >= 0 && *q < ' ')
fprintf(f, "\\u%04x", *q);
fprintf(f, "\\u%04x", (unsigned) *q);
else
fputc(*q, f);
break;
+6 -7
View File
@@ -242,9 +242,8 @@ static bool print_multiline(
for (pos = message;
pos < message + message_len;
pos = end + 1, line++) {
bool continuation = line > 0;
bool tail_line;
int len;
int len, indent = (line > 0) * prefix;
for (end = pos; end < message + message_len && *end != '\n'; end++)
;
len = end - pos;
@@ -266,7 +265,7 @@ static bool print_multiline(
highlight[0] < (size_t) len) {
fprintf(f, "%*s%s%.*s",
continuation * prefix, "",
indent, "",
color_on, (int) highlight[0], pos);
fprintf(f, "%s%.*s",
highlight_on,
@@ -281,7 +280,7 @@ static bool print_multiline(
} else
fprintf(f, "%*s%s%.*s%s\n",
continuation * prefix, "",
indent, "",
color_on, len, pos, color_off);
continue;
}
@@ -292,7 +291,7 @@ static bool print_multiline(
if (prefix < n_columns && n_columns - prefix >= 3) {
if (n_columns - prefix > (unsigned) len + 3)
fprintf(f, "%*s%s%.*s...%s\n",
continuation * prefix, "",
indent, "",
color_on, len, pos, color_off);
else {
_cleanup_free_ char *e = NULL;
@@ -301,11 +300,11 @@ static bool print_multiline(
tail_line ? 100 : 90);
if (!e)
fprintf(f, "%*s%s%.*s%s\n",
continuation * prefix, "",
indent, "",
color_on, len, pos, color_off);
else
fprintf(f, "%*s%s%s%s\n",
continuation * prefix, "",
indent, "",
color_on, e, color_off);
}
} else
+2 -2
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 */
+2 -2
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;
+1 -1
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;
+4 -1
View File
@@ -148,7 +148,10 @@ static int pattern_split(
}
if (!valid_char(*e))
return log_debug_errno(SYNTHETIC_ERRNO(EBADRQC), "Invalid character 0x%0x in pattern, refusing.", *e);
return log_debug_errno(
SYNTHETIC_ERRNO(EBADRQC),
"Invalid character 0x%0x in pattern, refusing.",
(unsigned) *e);
last_literal = true;
+3 -3
View File
@@ -141,13 +141,13 @@ static void maybe_emit_login_defs_warning(void) {
log_warning("login.defs specifies UID allocation range "UID_FMT"–"UID_FMT
" that is different than the built-in defaults ("UID_FMT"–"UID_FMT")",
login_defs.system_alloc_uid_min, login_defs.system_uid_max,
SYSTEM_ALLOC_UID_MIN, SYSTEM_UID_MAX);
(uid_t) SYSTEM_ALLOC_UID_MIN, (uid_t) SYSTEM_UID_MAX);
if (login_defs.system_alloc_gid_min != SYSTEM_ALLOC_GID_MIN ||
login_defs.system_gid_max != SYSTEM_GID_MAX)
log_warning("login.defs specifies GID allocation range "GID_FMT"–"GID_FMT
" that is different than the built-in defaults ("GID_FMT"–"GID_FMT")",
login_defs.system_alloc_gid_min, login_defs.system_gid_max,
SYSTEM_ALLOC_GID_MIN, SYSTEM_GID_MAX);
(gid_t) SYSTEM_ALLOC_GID_MIN, (gid_t) SYSTEM_GID_MAX);
login_defs_need_warning = false;
}
@@ -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;
+1 -1
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);
+1 -1
View File
@@ -10,7 +10,7 @@ TEST(coredump_filter_to_from_string) {
const char *n;
assert_se(n = coredump_filter_to_string(i));
log_info("0x%x\t%s", 1<<i, n);
log_info("0x%x\t%s", 1u << i, n);
assert_se(coredump_filter_from_string(n) == i);
uint64_t f;
+1 -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));
+2 -2
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);
+2 -2
View File
@@ -114,10 +114,10 @@ static void test_gethostbyname4_r(void *handle, const char *module, const char *
status = f(name, &pat, buffer, sizeof buffer, &errno1, &errno2, &ttl);
if (status == NSS_STATUS_SUCCESS) {
log_info("%s(\"%s\") → status=%s%-20spat=buffer+0x%tx errno=%d/%s h_errno=%d/%s ttl=%"PRIi32,
log_info("%s(\"%s\") → status=%s%-20spat=buffer+0x%"PRIxPTR" errno=%d/%s h_errno=%d/%s ttl=%"PRIi32,
fname, name,
nss_status_to_string(status, pretty_status, sizeof pretty_status), "\n",
pat ? (char*) pat - buffer : 0,
pat ? (uintptr_t) pat - (uintptr_t) buffer : 0,
errno1, errno_to_name(errno1) ?: "---",
errno2, hstrerror(errno2),
ttl);
+1 -1
View File
@@ -94,7 +94,7 @@ static int _check_states(unsigned line,
UNIT(path)->id,
path_state_to_string(path->state),
path_result_to_string(path->result),
end - n);
(int64_t) (end - n));
log_info("line %u: %s: state = %s; result = %s",
line,
UNIT(service)->id,
+1 -1
View File
@@ -63,7 +63,7 @@ static void test_random_u64_range_one(unsigned mod) {
double dev = (count[i] - exp) / sqrt(exp * (mod > 1 ? mod - 1 : 1) / mod);
log_debug("%02zu: %5u (%+.3f)%*s",
i, count[i], dev,
count[i] / scale, "x");
(int) (count[i] / scale), "x");
assert_se(fabs(dev) < 6); /* 6 sigma is excessive, but this check should be enough to
* identify catastrophic failure while minimizing false
+4 -4
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);
+3 -3
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);
@@ -1106,7 +1106,7 @@ TEST(strextendf) {
assert_se(strextendf(&p, "<%80i>", 88) >= 0);
assert_se(streq(p, "<77><99>< 88>"));
assert_se(strextendf(&p, "<%08x>", 0x1234) >= 0);
assert_se(strextendf(&p, "<%08x>", 0x1234u) >= 0);
assert_se(streq(p, "<77><99>< 88><00001234>"));
p = mfree(p);
@@ -1120,7 +1120,7 @@ TEST(strextendf) {
assert_se(strextendf_with_separator(&p, ",", "<%80i>", 88) >= 0);
assert_se(streq(p, "<77>,<99>,< 88>"));
assert_se(strextendf_with_separator(&p, ",", "<%08x>", 0x1234) >= 0);
assert_se(strextendf_with_separator(&p, ",", "<%08x>", 0x1234u) >= 0);
assert_se(streq(p, "<77>,<99>,< 88>,<00001234>"));
}
+4 -4
View File
@@ -23,10 +23,10 @@ static void test_read_login_defs_one(const char *path) {
"SYS_UID_MAX "UID_FMT"\n"
"SYS_GID_MIN "GID_FMT"\n"
"SYS_GID_MAX "GID_FMT"\n",
SYSTEM_ALLOC_UID_MIN + 5,
SYSTEM_UID_MAX + 5,
SYSTEM_ALLOC_GID_MIN + 5,
SYSTEM_GID_MAX + 5);
(uid_t) (SYSTEM_ALLOC_UID_MIN + 5),
(uid_t) (SYSTEM_UID_MAX + 5),
(gid_t) (SYSTEM_ALLOC_GID_MIN + 5),
(gid_t) (SYSTEM_GID_MAX + 5));
assert_se(fflush_and_check(f) >= 0);
}
+4 -4
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"
+1 -1
View File
@@ -147,7 +147,7 @@ static int clock_state_update(
tx.time.tv_usec /= 1000;
t = timeval_load(&tx.time);
log_info("adjtime state %d status %x time %s", sp->adjtime_state, tx.status,
log_info("adjtime state %i status %x time %s", sp->adjtime_state, (unsigned) tx.status,
FORMAT_TIMESTAMP_STYLE(t, TIMESTAMP_US_UTC) ?: "unrepresentable");
sp->has_watchfile = access("/run/systemd/timesync/synchronized", F_OK) >= 0;
+7 -1
View File
@@ -3107,7 +3107,13 @@ static int parse_line(
case RELABEL_PATH:
case RECURSIVE_RELABEL_PATH:
if (i.argument)
log_syntax(NULL, LOG_WARNING, fname, line, 0, "%c lines don't take argument fields, ignoring.", i.type);
log_syntax(NULL,
LOG_WARNING,
fname,
line,
0,
"%c lines don't take argument fields, ignoring.",
(char) i.type);
break;
+4 -4
View File
@@ -140,9 +140,9 @@ static int set_drive_feature(Context *c, Feature f) {
}
#define ERRCODE(s) ((((s)[2] & 0x0F) << 16) | ((s)[12] << 8) | ((s)[13]))
#define SK(errcode) (((errcode) >> 16) & 0xF)
#define ASC(errcode) (((errcode) >> 8) & 0xFF)
#define ASCQ(errcode) ((errcode) & 0xFF)
#define SK(errcode) (((errcode) >> 16) & 0xFU)
#define ASC(errcode) (((errcode) >> 8) & 0xFFU)
#define ASCQ(errcode) ((errcode) & 0xFFU)
#define CHECK_CONDITION 0x01
static int log_scsi_debug_errno(int error, const char *msg) {
@@ -712,7 +712,7 @@ static int cd_media_toc(Context *c) {
block = unaligned_read_be32(&toc[i + 4]);
log_debug("track=%u info=0x%x(%s) start_block=%"PRIu32,
toc[i + 2], toc[i + 1] & 0x0f, is_data_track ? "data":"audio", block);
toc[i + 2], toc[i + 1] & 0x0FU, is_data_track ? "data":"audio", block);
if (is_data_track)
c->media_track_count_data++;
+1 -1
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);
}
+1 -1
View File
@@ -357,7 +357,7 @@ static int per_dev_options(struct scsi_id_device *dev_scsi, int *good_bad, int *
break;
default:
log_error("Unknown or bad option '%c' (0x%x)", option, option);
log_error("Unknown or bad option '%c' (0x%x)", option, (unsigned) option);
retval = -1;
break;
}
+5 -8
View File
@@ -154,10 +154,7 @@ static int sg_err_category4(struct sg_io_v4 *hp) {
static int scsi_dump_sense(struct scsi_id_device *dev_scsi,
unsigned char *sense_buffer, int sb_len) {
int s;
int code;
int sense_class;
int sense_key;
int asc, ascq;
unsigned code, sense_class, sense_key, asc, ascq;
/*
* Figure out and print the sense key, asc and ascq.
@@ -221,11 +218,11 @@ static int scsi_dump_sense(struct scsi_id_device *dev_scsi,
4 - sb_len);
if (sense_buffer[0] < 15)
log_debug("%s: old sense key: 0x%x", dev_scsi->kernel, sense_buffer[0] & 0x0f);
log_debug("%s: old sense key: 0x%x", dev_scsi->kernel, sense_buffer[0] & 0x0fu);
else
log_debug("%s: sense = %2x %2x",
dev_scsi->kernel, sense_buffer[0], sense_buffer[2]);
log_debug("%s: non-extended sense class %d code 0x%0x",
log_debug("%s: non-extended sense class %u code 0x%0x",
dev_scsi->kernel, sense_class, code);
}
@@ -284,7 +281,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 +761,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);
+1 -1
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;
+2 -2
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;
}
+1 -1
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;
}
+1 -1
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;
}
+1 -1
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);
@@ -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);