[hackers] [sbase][PATCH] cron: fix repeat for random, and format code

From: Elie Le Vaillant <eolien55_AT_disroot.org>
Date: Mon, 4 Mar 2024 23:03:35 +0100

---
 cron.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/cron.c b/cron.c
index e95c661..9da0c8a 100644
--- a/cron.c
+++ b/cron.c
_AT_@ -287,19 +287,17 @@ parserange(char *str, long low, long high, struct range *r)
 		r->repeat = strtol(repeat, &e, 10);
 		if (*e || errno != 0 || r->repeat == 0)
 			return -1;
+	} else if (random) {
+		r->repeat = r->low;
 	} else {
 		r->repeat = 1;
 	}
 
-	if (random) {
-		/* random replaces low in matchentry() */
-		r->repeat = r->low; /* so that it doesn't repeat */
+	if (random)
 		r->low = rng32_bounded(r->high - r->low+1) + r->low;
-	}
 
-	if (r->low < low || r->low > high || r->high < low || r->high > high || r->repeat < low || r->repeat > high) {
+	if (r->low < low || r->low > high || r->high < low || r->high > high || r->repeat < low || r->repeat > high)
 		return -1;
-	}
 
 	return 0;
 }
-- 
2.44.0
Received on Mon Mar 04 2024 - 23:03:35 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 04 2024 - 23:12:37 CET