From: Zbigniew Jędrzejewski-Szmek Date: Fri, 25 Sep 2020 15:51:41 +0000 (+0200) Subject: shared/uid-range: reduce scope of iterator variables X-Git-Tag: v247-rc1~134^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=196b596867b09838c3391566ada0539d972e2d2c;p=thirdparty%2Fsystemd.git shared/uid-range: reduce scope of iterator variables --- diff --git a/src/shared/uid-range.c b/src/shared/uid-range.c index 7cb7d8a477e..201d27ab63a 100644 --- a/src/shared/uid-range.c +++ b/src/shared/uid-range.c @@ -18,13 +18,11 @@ static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) { } static void uid_range_coalesce(UidRange **p, unsigned *n) { - unsigned i, j; - assert(p); assert(n); - for (i = 0; i < *n; i++) { - for (j = i + 1; j < *n; j++) { + for (unsigned i = 0; i < *n; i++) { + for (unsigned j = i + 1; j < *n; j++) { UidRange *x = (*p)+i, *y = (*p)+j; if (uid_range_intersect(x, y->start, y->nr)) { @@ -59,7 +57,6 @@ static int uid_range_compare(const UidRange *a, const UidRange *b) { int uid_range_add(UidRange **p, unsigned *n, uid_t start, uid_t nr) { bool found = false; UidRange *x; - unsigned i; assert(p); assert(n); @@ -67,7 +64,7 @@ int uid_range_add(UidRange **p, unsigned *n, uid_t start, uid_t nr) { if (nr <= 0) return 0; - for (i = 0; i < *n; i++) { + for (unsigned i = 0; i < *n; i++) { x = (*p) + i; if (uid_range_intersect(x, start, nr)) { found = true; @@ -143,14 +140,13 @@ int uid_range_add_str(UidRange **p, unsigned *n, const char *s) { int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid) { uid_t closest = UID_INVALID, candidate; - unsigned i; assert(p); assert(uid); candidate = *uid - 1; - for (i = 0; i < n; i++) { + for (unsigned i = 0; i < n; i++) { uid_t begin, end; begin = p[i].start; @@ -173,12 +169,10 @@ int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid) { } bool uid_range_contains(const UidRange *p, unsigned n, uid_t uid) { - unsigned i; - assert(p); assert(uid); - for (i = 0; i < n; i++) + for (unsigned i = 0; i < n; i++) if (uid >= p[i].start && uid < p[i].start + p[i].nr) return true;