[systemd-devel] [PATCH 2/7] calendar: constant value for weekdays
Lennart Poettering
lennart at poettering.net
Mon Oct 27 05:38:35 PDT 2014
On Mon, 27.10.14 08:42, Daniele Medri (dmedri at gmail.com) wrote:
Could you merge the #define for BITS_WEEKDAYS into this patch please,
as this patch appears to be the one that starts making use of this?
> ---
> src/shared/calendarspec.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
> index 73f87c6..67fd76a 100644
> --- a/src/shared/calendarspec.c
> +++ b/src/shared/calendarspec.c
> @@ -126,7 +126,7 @@ static void fix_year(CalendarComponent *c) {
> int calendar_spec_normalize(CalendarSpec *c) {
> assert(c);
>
> - if (c->weekdays_bits <= 0 || c->weekdays_bits >= 127)
> + if (c->weekdays_bits <= 0 || c->weekdays_bits >= BITS_WEEKDAYS)
> c->weekdays_bits = -1;
>
> fix_year(c->year);
> @@ -160,7 +160,7 @@ _pure_ static bool chain_valid(CalendarComponent *c, int from, int to) {
> _pure_ bool calendar_spec_valid(CalendarSpec *c) {
> assert(c);
>
> - if (c->weekdays_bits > 127)
> + if (c->weekdays_bits > BITS_WEEKDAYS)
> return false;
>
> if (!chain_valid(c->year,
> @@ -202,7 +202,7 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
>
> assert(f);
> assert(c);
> - assert(c->weekdays_bits > 0 && c->weekdays_bits <= 127);
> + assert(c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS);
>
> for (x = 0, l = -1; x < (int) ELEMENTSOF(days); x++) {
>
> @@ -267,7 +267,7 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
> if (!f)
> return -ENOMEM;
>
> - if (c->weekdays_bits > 0 && c->weekdays_bits <= 127) {
> + if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
> format_weekdays(f, c);
> fputc(' ', f);
> }
> @@ -830,7 +830,7 @@ static bool matches_weekday(int weekdays_bits, const struct tm *tm) {
> struct tm t;
> int k;
>
> - if (weekdays_bits < 0 || weekdays_bits >= 127)
> + if (weekdays_bits < 0 || weekdays_bits >= BITS_WEEKDAYS)
> return true;
>
> t = *tm;
> --
> 1.9.3
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list