On 1/5/26 08:53, David Gibson wrote:
When scanning the versions[] array we use a dummy entry to detect when we're finished. Use ARRAY_SIZE() instead, which is almost as easy, a little safer, and doesn't cause clang-tidy 21.1.7 to complain.
Signed-off-by: David Gibson
--- migrate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migrate.c b/migrate.c index 48d63a07..18ca18a8 100644 --- a/migrate.c +++ b/migrate.c @@ -123,7 +123,6 @@ static const struct migrate_version versions[] = { * MSS and omitted timestamps, which meant it usually wouldn't work. * Therefore we don't attempt to support compatibility with it. */ - { 0 }, };
/* Current encoding version */ @@ -196,7 +195,7 @@ static const struct migrate_version *migrate_target_read_header(int fd) return NULL; }
- for (v = versions; v->id; v++) + for (v = versions; (v - versions) < ARRAY_SIZE(versions); v++) if (v->id <= id && v->id >= compat_id) return v;
As we don't need to check v->id on the loop perhaps we can use something more standard like: for (i = 0; i < ARRAY_SIZE(versions); i++) if (versions[i].id <= id && versions[i].id >= compat_id) return &versions[i]; Thanks, Laurent