mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-10 00:58:20 +03:00
various: use CONST_MAX for array allocation
IIUC, with MAX() we get a VLA and the size is "decided" at runtime, even though the result is always the same, but with CONST_MAX() we get a normal stack variable.
This commit is contained in:
parent
a5b28b7721
commit
89eb3d7c95
@ -339,7 +339,7 @@ static int output_timestamp_monotonic(FILE *f, sd_journal *j, const char *monoto
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, OutputFlags flags, const char *realtime) {
|
static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, OutputFlags flags, const char *realtime) {
|
||||||
char buf[MAX(FORMAT_TIMESTAMP_MAX, 64U)];
|
char buf[CONST_MAX(FORMAT_TIMESTAMP_MAX, 64U)];
|
||||||
uint64_t x;
|
uint64_t x;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ TEST(usec_sub_signed) {
|
|||||||
|
|
||||||
TEST(format_timestamp) {
|
TEST(format_timestamp) {
|
||||||
for (unsigned i = 0; i < 100; i++) {
|
for (unsigned i = 0; i < 100; i++) {
|
||||||
char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
|
char buf[CONST_MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
|
||||||
usec_t x, y;
|
usec_t x, y;
|
||||||
|
|
||||||
x = random_u64_range(2147483600 * USEC_PER_SEC) + 1;
|
x = random_u64_range(2147483600 * USEC_PER_SEC) + 1;
|
||||||
@ -374,7 +374,7 @@ TEST(FORMAT_TIMESTAMP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(format_timestamp_relative) {
|
TEST(format_timestamp_relative) {
|
||||||
char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
|
char buf[CONST_MAX(FORMAT_TIMESTAMP_MAX, FORMAT_TIMESPAN_MAX)];
|
||||||
usec_t x;
|
usec_t x;
|
||||||
|
|
||||||
/* Only testing timestamps in the past so we don't need to add some delta to account for time passing
|
/* Only testing timestamps in the past so we don't need to add some delta to account for time passing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user