mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
tree-wide: Fix field width specifier warnings
The casting here isn't pretty, but at least it makes it obvious what is happening instead of implicit and it allows enabling -Wformat-signedness.
This commit is contained in:
parent
5570a09702
commit
f996072fe0
@ -631,7 +631,7 @@ static void display(Hashmap *a) {
|
|||||||
|
|
||||||
if (on_tty()) {
|
if (on_tty()) {
|
||||||
const char *on, *off;
|
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;
|
path_columns = columns() - 36 - cpu_len;
|
||||||
if (path_columns < 10)
|
if (path_columns < 10)
|
||||||
@ -685,7 +685,9 @@ static void display(Hashmap *a) {
|
|||||||
else
|
else
|
||||||
fputs(" -", stdout);
|
fputs(" -", stdout);
|
||||||
} else
|
} 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->memory_valid, g->memory));
|
||||||
printf(" %8s", MAYBE_FORMAT_BYTES(g->io_valid, g->io_input_bps));
|
printf(" %8s", MAYBE_FORMAT_BYTES(g->io_valid, g->io_input_bps));
|
||||||
|
@ -161,7 +161,7 @@ static int show_menu(char **x, unsigned n_columns, unsigned width, unsigned perc
|
|||||||
if (!e)
|
if (!e)
|
||||||
return log_oom();
|
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');
|
putchar('\n');
|
||||||
|
@ -1013,7 +1013,7 @@ void bus_match_dump(FILE *out, struct bus_match_node *node, unsigned level) {
|
|||||||
if (!node)
|
if (!node)
|
||||||
return;
|
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->type == BUS_MATCH_VALUE) {
|
||||||
if (node->parent->type == BUS_MATCH_MESSAGE_TYPE)
|
if (node->parent->type == BUS_MATCH_MESSAGE_TYPE)
|
||||||
|
@ -16,8 +16,8 @@ TEST(journal_print) {
|
|||||||
assert_se(sd_journal_print(LOG_INFO, "XXX") == 0);
|
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, "%s", "YYY") == 0);
|
||||||
assert_se(sd_journal_print(LOG_INFO, "X%4094sY", "ZZZ") == 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", (int) 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 - 2, "ZZZ") == -ENOBUFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(journal_send) {
|
TEST(journal_send) {
|
||||||
|
@ -1396,7 +1396,7 @@ static int status_print_strv_ifindex(int ifindex, const char *ifname, char **p)
|
|||||||
printf(" %s", *i);
|
printf(" %s", *i);
|
||||||
position = size_add(size_add(position, 1), our_len);
|
position = size_add(size_add(position, 1), our_len);
|
||||||
} else {
|
} else {
|
||||||
printf("\n%*s%s", indent, "", *i);
|
printf("\n%*s%s", (int) indent, "", *i);
|
||||||
position = size_add(our_len, indent);
|
position = size_add(our_len, indent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ static void show_pid_array(
|
|||||||
else
|
else
|
||||||
printf("%s%s", prefix, special_glyph(((more || i < n_pids-1) ? SPECIAL_GLYPH_TREE_BRANCH : SPECIAL_GLYPH_TREE_RIGHT)));
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +242,8 @@ static bool print_multiline(
|
|||||||
for (pos = message;
|
for (pos = message;
|
||||||
pos < message + message_len;
|
pos < message + message_len;
|
||||||
pos = end + 1, line++) {
|
pos = end + 1, line++) {
|
||||||
bool continuation = line > 0;
|
|
||||||
bool tail_line;
|
bool tail_line;
|
||||||
int len;
|
int len, indent = (line > 0) * prefix;
|
||||||
for (end = pos; end < message + message_len && *end != '\n'; end++)
|
for (end = pos; end < message + message_len && *end != '\n'; end++)
|
||||||
;
|
;
|
||||||
len = end - pos;
|
len = end - pos;
|
||||||
@ -266,7 +265,7 @@ static bool print_multiline(
|
|||||||
highlight[0] < (size_t) len) {
|
highlight[0] < (size_t) len) {
|
||||||
|
|
||||||
fprintf(f, "%*s%s%.*s",
|
fprintf(f, "%*s%s%.*s",
|
||||||
continuation * prefix, "",
|
indent, "",
|
||||||
color_on, (int) highlight[0], pos);
|
color_on, (int) highlight[0], pos);
|
||||||
fprintf(f, "%s%.*s",
|
fprintf(f, "%s%.*s",
|
||||||
highlight_on,
|
highlight_on,
|
||||||
@ -281,7 +280,7 @@ static bool print_multiline(
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
fprintf(f, "%*s%s%.*s%s\n",
|
fprintf(f, "%*s%s%.*s%s\n",
|
||||||
continuation * prefix, "",
|
indent, "",
|
||||||
color_on, len, pos, color_off);
|
color_on, len, pos, color_off);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -292,7 +291,7 @@ static bool print_multiline(
|
|||||||
if (prefix < n_columns && n_columns - prefix >= 3) {
|
if (prefix < n_columns && n_columns - prefix >= 3) {
|
||||||
if (n_columns - prefix > (unsigned) len + 3)
|
if (n_columns - prefix > (unsigned) len + 3)
|
||||||
fprintf(f, "%*s%s%.*s...%s\n",
|
fprintf(f, "%*s%s%.*s...%s\n",
|
||||||
continuation * prefix, "",
|
indent, "",
|
||||||
color_on, len, pos, color_off);
|
color_on, len, pos, color_off);
|
||||||
else {
|
else {
|
||||||
_cleanup_free_ char *e = NULL;
|
_cleanup_free_ char *e = NULL;
|
||||||
@ -301,11 +300,11 @@ static bool print_multiline(
|
|||||||
tail_line ? 100 : 90);
|
tail_line ? 100 : 90);
|
||||||
if (!e)
|
if (!e)
|
||||||
fprintf(f, "%*s%s%.*s%s\n",
|
fprintf(f, "%*s%s%.*s%s\n",
|
||||||
continuation * prefix, "",
|
indent, "",
|
||||||
color_on, len, pos, color_off);
|
color_on, len, pos, color_off);
|
||||||
else
|
else
|
||||||
fprintf(f, "%*s%s%s%s\n",
|
fprintf(f, "%*s%s%s%s\n",
|
||||||
continuation * prefix, "",
|
indent, "",
|
||||||
color_on, e, color_off);
|
color_on, e, color_off);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -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);
|
double dev = (count[i] - exp) / sqrt(exp * (mod > 1 ? mod - 1 : 1) / mod);
|
||||||
log_debug("%02zu: %5u (%+.3f)%*s",
|
log_debug("%02zu: %5u (%+.3f)%*s",
|
||||||
i, count[i], dev,
|
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
|
assert_se(fabs(dev) < 6); /* 6 sigma is excessive, but this check should be enough to
|
||||||
* identify catastrophic failure while minimizing false
|
* identify catastrophic failure while minimizing false
|
||||||
|
Loading…
Reference in New Issue
Block a user