From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=cCMnuihZ; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id CE83A5A0772 for ; Wed, 07 Jan 2026 01:16:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1767744971; bh=xUHp9nGk43ZnTA0HUhQvFb9daeMc16wiuhWqRnUdV5s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cCMnuihZMMtMZLj0oLG7JCt9BNBXT8R2gvwKkjNGEK9AwI49WBkC0qlFGyHZZwfWs OvBF9iP/uaoSKvRSJeO1/PyzYgWfTaeq1VnSUUFbQsGTOoaUMIak3QD5Or3umtnPyV 8RNn1L7Y2veC/JIupcrALELIELIOY6hJcgHPd02rD6bpI2G7eABLMoJaOaqVFSBjpm YVTS6SQqgsfZFVylE4onqDmlmeY9h4rSx3PEdH4Zt7Y0TJE6k8BFaUGisJqWOD2q1u mBGXQqPy5tpF7UCs1J5TKCTob7iOgGkgBWw02+Fhas6Iqse5GgdysL5kvT7G2AEl7m CnQUgyQ5QsyJQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dm7qb11BQz4wR5; Wed, 07 Jan 2026 11:16:11 +1100 (AEDT) Date: Wed, 7 Jan 2026 11:10:22 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 2/5] migrate: Don't use terminator element for versions[] array Message-ID: References: <20260105075337.1724962-1-david@gibson.dropbear.id.au> <20260105075337.1724962-3-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mC32/IbY0aORPctP" Content-Disposition: inline In-Reply-To: Message-ID-Hash: 5VWUTYOCTGJC2SAYEN2LR6P2MY5ATVLW X-Message-ID-Hash: 5VWUTYOCTGJC2SAYEN2LR6P2MY5ATVLW X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Stefano Brivio X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --mC32/IbY0aORPctP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. > >=20 > > Signed-off-by: David Gibson > > --- > > migrate.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > >=20 > > 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[] =3D { > > * 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 =3D versions; v->id; v++) > > + for (v =3D versions; (v - versions) < ARRAY_SIZE(versions); v++) > > if (v->id <=3D id && v->id >=3D compat_id) > > return v; >=20 > As we don't need to check v->id on the loop perhaps we can use something = more standard like: >=20 > for (i =3D 0; i < ARRAY_SIZE(versions); i++) > if (versions[i].id <=3D id && versions[i].id >=3D compat_id) > return &versions[i]; Good idea, done. --=20 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 --mC32/IbY0aORPctP Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmldpG0ACgkQzQJF27ox 2Gfasg//bwX/URkoHi+IiNL+QEOxX4UP7X4TQohYhnZe9WBngjX+ea88hujn7tES tI4VDb7tFiiR+nBlr6qBdU+FlmFwuGk977HcHHMnqalRyGLxSQI50bMfPQo51XTM I7TfgBoESddCRQEfDYMYASyuQ8ZPObhcNO8Coue9dC6Vk803gKE/0nhUUr50bgeA m25PWAc3HyMWc+O81Qot3ZHxzOee0NDScrKnVJhjvNCVFcc7gShvjFrcNbcpvH4S vpN8anMIfq0iQM3vByH9oItNg9jeDrkaK+TkWsQ3Wl/i7O1Ic2Q211Gce6+Tb0FX 1/5uRSicYNJ/I6I7ek7kfRn5+zH3aV66PecHJ3BCHdQdxtBYUR3iY4P4OKxyctF6 wrlq749scX2fS22zKbLfXGJZeSQLPty/WdDvDYxfXqwIz4Um1ZFm383B4df671G9 xWvXqi3/v98vFATl1XXbDYGcCRRzwXY1OqbvC2kdUypFvZivLT8wo69zRVff2hk5 8ohkgOfMr2/7QXVl5tu6iyFSRp3W3WxmW5qkA8kpNiSM1xucZ7ao0yCN6NdxxkOH ayx/rfEbal1dG1KVPhg0SIsH2eru4m5Td76htAc6iUp4jF6wfQn2eT5WKP18JNzr cc5+wvM13yNIMbCV/9HSTB+cskVCEdtDrwKzSIckwVvL6q+nias= =wpFi -----END PGP SIGNATURE----- --mC32/IbY0aORPctP--