1
0
mirror of https://github.com/systemd/systemd synced 2025-11-08 11:24:45 +01:00

Compare commits

..

10 Commits

Author SHA1 Message Date
Chris Down
87afd40b5a man: systemd.service: systemd-analyze exit-codes -> exit-status
5238d9a83a52 renames this to exit-status, but systemd.service was not
updated.

The rest of the doc seems a bit inconsistent in its use of the terms
"exit code" and "exit status", but it's not that confusing, so leave
those alone for now.
2020-05-05 21:38:29 +02:00
Ferran Pallarès Roca
a8acbf9748 Add Zowie ZA12 details to mouse hwdb 2020-05-05 19:06:29 +02:00
Zbigniew Jędrzejewski-Szmek
eaf7ac4929
Merge pull request #15645 from poettering/calender-expression-doc-fix
some calendar expression fixes and documentation updates
2020-05-05 16:07:11 +02:00
Frantisek Sumsal
05c7d9bf5b Revert "logs-show: declare [static 2] on all highlight parameters"
This reverts commit 5444520628830aacab85be630a6cdeb179ff510b.

See: https://github.com/systemd/systemd/pull/15706
2020-05-05 16:37:45 +03:00
Lennart Poettering
2edc7aea7a man: expand on the star…end/repetition time expressions
And attempt to explain what is requested in #15030, but still be
concise.

Fixes: #15030
2020-05-05 08:57:14 +02:00
Lennart Poettering
c9c9f6f450 calendarspec: be more graceful with two kinds of calendar expressions
This changes the calendarspec parser to allow expressions such as
"00:05..05", i.e. a range where start and end is the same. It also
allows expressions such as "00:1-2/3", i.e. where the repetition value
does not fit even once in the specified range. With this patch both
cases will now be optimized away, i.e. the range is removed and a fixed
value is used, which is functionally equivalent.

See #15030 for an issue where the inability to parse such expressions
caused confusion.

I think it's probably better to accept these gracefully and optimizing
them away instead of refusing them with a plain EINVAL. With a tool such
as "systemd-analyze" calendar it should be easy to figure out the
normalized form with the redundant bits optimized away.
2020-05-05 08:57:14 +02:00
Lennart Poettering
05851cb9df calendarspec: minor simplification 2020-05-05 08:57:14 +02:00
Lennart Poettering
3c6f0300ae calendarspec: drop _pure_ from static function
For static functions the compiler should be able to determine this on
its own, let's not add needless decorators.
2020-05-05 08:57:14 +02:00
Lennart Poettering
80b19994a4 calendarspec: pack our flags a bit 2020-05-05 08:57:14 +02:00
Lennart Poettering
a4d6d711cf calendarspec: encode that it's OK to store µs in 'int's 2020-05-05 08:57:14 +02:00
8 changed files with 52 additions and 29 deletions

View File

@ -760,3 +760,9 @@ mouse:usb:v3057p0001:*
MOUSE_DPI=400@125 *800@125 1600@125 3200@125 400@500 800@500 1600@500 3200@500 400@1000 800@1000 1600@1000 3200@1000
MOUSE_WHEEL_CLICK_COUNT=16
MOUSE_WHEEL_CLICK_ANGLE=23
# Zowie ZA12
mouse:usb:v1af3p0001:name:Kingsis Peripherals ZOWIE Gaming mouse:
MOUSE_DPI=400@125 *800@125 1600@125 3200@125 400@500 800@500 1600@500 3200@500 400@1000 800@1000 1600@1000 3200@1000
MOUSE_WHEEL_CLICK_COUNT=16
MOUSE_WHEEL_CLICK_ANGLE=23

View File

@ -872,7 +872,7 @@
<constant>SIGKILL</constant> are considered clean service terminations.</para>
</example>
<para>Note: <command>systemd-analyze exit-codes</command> may be used to list exit
<para>Note: <command>systemd-analyze exit-status</command> may be used to list exit
codes and translate between numerical code values and names.</para></listitem>
</varlistentry>

View File

@ -199,15 +199,14 @@ tomorrow Pacific/Auckland → Thu 2012-11-23 19:00:00
continuous weekdays. <literal>,</literal> and <literal>..</literal>
may be combined freely.</para>
<para>In the date and time specifications, any component may be
specified as <literal>*</literal> in which case any value will
match. Alternatively, each component can be specified as a list of
values separated by commas. Values may be suffixed with
<literal>/</literal> and a repetition value, which indicates that
the value itself and the value plus all multiples of the repetition value
are matched. Two values separated by <literal>..</literal> may be used
to indicate a range of values; ranges may also be followed with
<literal>/</literal> and a repetition value.</para>
<para>In the date and time specifications, any component may be specified as <literal>*</literal> in
which case any value will match. Alternatively, each component can be specified as a list of values
separated by commas. Values may be suffixed with <literal>/</literal> and a repetition value, which
indicates that the value itself and the value plus all multiples of the repetition value are matched.
Two values separated by <literal>..</literal> may be used to indicate a range of values; ranges may also
be followed with <literal>/</literal> and a repetition value, in which case the expression matches all
times starting with the start value, and continuing with all multiples of the repetition value relative
to the start value, ending at the end value the latest.</para>
<para>A date specification may use <literal>~</literal> to indicate the
last day(s) in a month. For example, <literal>*-02~03</literal> means

View File

@ -30,6 +30,9 @@
* linked compenents anyway. */
#define CALENDARSPEC_COMPONENTS_MAX 240
/* Let's make sure that the microsecond component is safe to be stored in an 'int' */
assert_cc(INT_MAX >= USEC_PER_SEC);
static void chain_free(CalendarComponent *c) {
CalendarComponent *n;
@ -88,6 +91,16 @@ static void normalize_chain(CalendarComponent **c) {
if (i->stop > i->start && i->repeat > 0)
i->stop -= (i->stop - i->start) % i->repeat;
/* If a repeat value is specified, but it cannot even be triggered once, let's suppress
* it.
*
* Similar, if the stop value is the same as the start value, then let's just make this a
* non-repeating chain element */
if ((i->stop > i->start && i->repeat > 0 && i->start + i->repeat > i->stop) ||
i->start == i->stop) {
i->repeat = 0;
i->stop = -1;
}
}
if (n <= 1)
@ -162,7 +175,7 @@ int calendar_spec_normalize(CalendarSpec *c) {
return 0;
}
_pure_ static bool chain_valid(CalendarComponent *c, int from, int to, bool end_of_month) {
static bool chain_valid(CalendarComponent *c, int from, int to, bool end_of_month) {
assert(to >= from);
if (!c)
@ -366,14 +379,13 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
}
r = fflush_and_check(f);
fclose(f);
if (r < 0) {
free(buf);
fclose(f);
return r;
}
fclose(f);
*p = buf;
return 0;
}
@ -643,6 +655,12 @@ static int prepend_component(const char **p, bool usec, unsigned nesting, Calend
if (repeat == 0)
return -ERANGE;
} else {
/* If no repeat value is specified for the µs component, then let's explicitly refuse ranges
* below 1s because our default repeat granularity is beyond that. */
if (usec && stop >= 0 && start + repeat > stop)
return -EINVAL;
}
if (!IN_SET(*e, 0, ' ', ',', '-', '~', ':'))

View File

@ -19,9 +19,9 @@ typedef struct CalendarComponent {
typedef struct CalendarSpec {
int weekdays_bits;
bool end_of_month;
bool utc;
int dst;
bool end_of_month:1;
bool utc:1;
signed int dst:2;
char *timezone;
CalendarComponent *year;

View File

@ -158,7 +158,7 @@ static bool print_multiline(
bool audit,
const char* message,
size_t message_len,
size_t highlight[static 2]) {
size_t highlight[2]) {
const char *color_on = "", *color_off = "", *highlight_on = "";
const char *pos, *end;
@ -370,7 +370,7 @@ static int output_short(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
int r;
const void *data;
@ -534,7 +534,7 @@ static int output_verbose(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
const void *data;
size_t length;
@ -653,7 +653,7 @@ static int output_export(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
@ -883,7 +883,7 @@ static int output_json(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
char sid[SD_ID128_STRING_MAX], usecbuf[DECIMAL_STR_MAX(usec_t)];
_cleanup_(json_variant_unrefp) JsonVariant *object = NULL;
@ -1021,7 +1021,7 @@ static int output_cat_field(
sd_journal *j,
OutputFlags flags,
const char *field,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
const char *highlight_on, *highlight_off;
const void *data;
@ -1074,7 +1074,7 @@ static int output_cat(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) {
const size_t highlight[2]) {
const char *field;
Iterator iterator;
@ -1104,7 +1104,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
unsigned n_columns,
OutputFlags flags,
Set *output_fields,
const size_t highlight[static 2]) = {
const size_t highlight[2]) = {
[OUTPUT_SHORT] = output_short,
[OUTPUT_SHORT_ISO] = output_short,
@ -1130,7 +1130,7 @@ int show_journal_entry(
unsigned n_columns,
OutputFlags flags,
char **output_fields,
const size_t highlight[static 2],
const size_t highlight[2],
bool *ellipsized) {
int ret;

View File

@ -20,7 +20,7 @@ int show_journal_entry(
unsigned n_columns,
OutputFlags flags,
char **output_fields,
const size_t highlight[static 2],
const size_t highlight[2],
bool *ellipsized);
int show_journal(
FILE *f,

View File

@ -185,6 +185,8 @@ int main(int argc, char* argv[]) {
test_one("@1493187147 UTC", "2017-04-26 06:12:27 UTC");
test_one("@0", "1970-01-01 00:00:00 UTC");
test_one("@0 UTC", "1970-01-01 00:00:00 UTC");
test_one("*:05..05", "*-*-* *:05:00");
test_one("*:05..10/6", "*-*-* *:05:00");
test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);
@ -237,8 +239,6 @@ int main(int argc, char* argv[]) {
assert_se(calendar_spec_from_string("*~29", &c) < 0);
assert_se(calendar_spec_from_string("*~16..31", &c) < 0);
assert_se(calendar_spec_from_string("12..1/2-*", &c) < 0);
assert_se(calendar_spec_from_string("*:05..05", &c) < 0);
assert_se(calendar_spec_from_string("*:05..10/6", &c) < 0);
assert_se(calendar_spec_from_string("20/4:00", &c) < 0);
assert_se(calendar_spec_from_string("00:00/60", &c) < 0);
assert_se(calendar_spec_from_string("00:00:2300", &c) < 0);