From 4dda6d155588ed573f8ba70bad022601f76f9a7a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 8 May 2024 09:36:39 +0200 Subject: [PATCH] libdm: stats uses overflowing counter Here we need to annotate counter as it starts with UINT64_MAX and overflows to 0 is expected. --- libdm/libdm-stats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index ad74fb881..a8e0c0103 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -1444,8 +1444,9 @@ static void _stats_walk_next_present(const struct dm_stats *dms, } /* advance to next present, non-skipped region or end */ - while ((*cur_r < UINT64_MAX) && - ++(*cur_r) <= dms->max_region) { + /* count can start as UINT64_MAX, probably rework to use post++ */ + /* coverity[overflow_const] overflow is expected here */ + while (++(*cur_r) <= dms->max_region) { cur = &dms->regions[*cur_r]; if (!_stats_region_present(cur)) continue;