uid-range: add asserts to document overflow safety in coalesce

Coverity flags the x->start + x->nr and y->start + y->nr additions
as potential overflows. These are safe because uid_range_add_internal()
validates start + nr <= UINT32_MAX before inserting entries. Add asserts
to document this invariant for static analyzers.

CID#1548015

Follow-up for 8530dc4467
This commit is contained in:
Luca Boccassi
2026-03-28 19:56:31 +00:00
parent c8b53fcfd3
commit 1b7d2fa978
+4
View File
@@ -63,6 +63,10 @@ static void uid_range_coalesce(UIDRange *range) {
break;
begin = MIN(x->start, y->start);
/* Silence static analyzers, overflow is prevented by uid_range_add_internal() */
assert(x->start <= UINT32_MAX - x->nr);
assert(y->start <= UINT32_MAX - y->nr);
end = MAX(x->start + x->nr, y->start + y->nr);
x->start = begin;