On Tue, Jan 06, 2026 at 02:47:18PM +0100, Laurent Vivier wrote: > 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]; Good idea, done. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson