From: Luca Boccassi Date: Tue, 7 Apr 2026 22:45:30 +0000 (+0100) Subject: uid-range: add assert to silence coverity X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1934c65108505d0cd1888a889494467660a330c6;p=thirdparty%2Fsystemd.git uid-range: add assert to silence coverity Coverity flags range->n_entries - j - 1 and j-- as potential underflows. Add an assert that j > 0 before decrementing, since j starts at i + 1 >= 1 and is never decremented below its initial value. CID#1548015 Follow-up for 8dcc66cefc8ab489568c737adcba960756d76a3c --- diff --git a/src/basic/uid-range.c b/src/basic/uid-range.c index 628710a8709..3d8f8445c45 100644 --- a/src/basic/uid-range.c +++ b/src/basic/uid-range.c @@ -76,6 +76,9 @@ static void uid_range_coalesce(UIDRange *range) { memmove(y, y + 1, sizeof(UIDRangeEntry) * (range->n_entries - j - 1)); range->n_entries--; + + /* Silence static analyzers, j cannot be 0 here since it starts at i + 1, i.e. >= 1 */ + assert(j > 0); j--; } }