[systemd-devel] [PATCH 3/5] readability: cases sorted by time

Daniele Medri dmedri at gmail.com
Thu Oct 30 04:19:13 PDT 2014


---
 src/shared/calendarspec.c | 50 +++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 3115bba..a937f8b 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -679,10 +679,10 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
                 if (r < 0)
                         goto fail;
 
-        } else if (strcaseeq(p, "monthly")) {
-                r = const_chain(1, &c->day);
-                if (r < 0)
-                        goto fail;
+        } else if (strcaseeq(p, "weekly")) {
+
+                c->weekdays_bits = 1;
+
                 r = const_chain(0, &c->hour);
                 if (r < 0)
                         goto fail;
@@ -693,13 +693,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
                 if (r < 0)
                         goto fail;
 
-        } else if (strcaseeq(p, "annually") ||
-                   strcaseeq(p, "yearly") ||
-                   strcaseeq(p, "anually") /* backwards compatibility */ ) {
-
-                r = const_chain(1, &c->month);
-                if (r < 0)
-                        goto fail;
+        } else if (strcaseeq(p, "monthly")) {
                 r = const_chain(1, &c->day);
                 if (r < 0)
                         goto fail;
@@ -713,20 +707,6 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
                 if (r < 0)
                         goto fail;
 
-        } else if (strcaseeq(p, "weekly")) {
-
-                c->weekdays_bits = 1;
-
-                r = const_chain(0, &c->hour);
-                if (r < 0)
-                        goto fail;
-                r = const_chain(0, &c->minute);
-                if (r < 0)
-                        goto fail;
-                r = const_chain(0, &c->second);
-                if (r < 0)
-                        goto fail;
-
         } else if (strcaseeq(p, "quarterly")) {
 
                 r = const_chain(1, &c->month);
@@ -779,6 +759,26 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
                 if (r < 0)
                         goto fail;
 
+        } else if (strcaseeq(p, "annually") ||
+                   strcaseeq(p, "yearly") ||
+                   strcaseeq(p, "anually") /* backwards compatibility */ ) {
+
+                r = const_chain(1, &c->month);
+                if (r < 0)
+                        goto fail;
+                r = const_chain(1, &c->day);
+                if (r < 0)
+                        goto fail;
+                r = const_chain(0, &c->hour);
+                if (r < 0)
+                        goto fail;
+                r = const_chain(0, &c->minute);
+                if (r < 0)
+                        goto fail;
+                r = const_chain(0, &c->second);
+                if (r < 0)
+                        goto fail;
+
         } else {
                 r = parse_weekdays(&p, c);
                 if (r < 0)
-- 
1.9.3



More information about the systemd-devel mailing list