From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Subject: Re: [PATCH 2/5] migrate: Don't use terminator element for versions[] array
Date: Wed, 7 Jan 2026 11:10:22 +1100 [thread overview]
Message-ID: <aV2kbsBjVHoLrWR3@zatzit> (raw)
In-Reply-To: <e8c05f15-6a84-42f4-b739-3874d9974b21@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]
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 <david@gibson.dropbear.id.au>
> > ---
> > 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-01-07 0:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 7:53 [PATCH 0/5] Fixes for Fedora 43 (or other bitrot) David Gibson
2026-01-05 7:53 ` [PATCH 1/5] util: Be more defensive about buffer overruns in read_file() David Gibson
2026-01-06 13:37 ` Laurent Vivier
2026-01-05 7:53 ` [PATCH 2/5] migrate: Don't use terminator element for versions[] array David Gibson
2026-01-06 13:43 ` Laurent Vivier
2026-01-06 13:47 ` Laurent Vivier
2026-01-07 0:10 ` David Gibson [this message]
2026-01-05 7:53 ` [PATCH 3/5] treewide: Don't rely on terminator records in ip[46].dns arrays David Gibson
2026-01-06 13:53 ` Laurent Vivier
2026-01-07 0:11 ` David Gibson
2026-01-05 7:53 ` [PATCH 4/5] test: Handle Operating System Command escapes in terminal output David Gibson
2026-01-06 14:07 ` Laurent Vivier
2026-01-05 7:53 ` [PATCH 5/5] test: Include sshd-auth in mbuto guest image David Gibson
2026-01-06 14:11 ` Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aV2kbsBjVHoLrWR3@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).