From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id AE13B5A0270 for ; Thu, 6 Apr 2023 04:50:13 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsQvz6FLmz4xFj; Thu, 6 Apr 2023 12:50:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680749407; bh=zCSuVFyYF2fYSYfKMbSSTcHLNViOsYJaV9GDCAjThus=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kide26P1jKJXA1axF34O6ILNm8flGDLXuO4qPjnhzN0dtSFAP+gJcA3mJIVotL+j/ IGcXioy0cmaI5NpWhESH/6PMpDNF3gToQ0zvyVbEzXGnh3O65VRlUBztMm92BpBGG5 fnh1d390gJQadzsPraTS4XBPHgWWHZSdVOXmCFZE= Date: Thu, 6 Apr 2023 10:55:37 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 08/14] nstool: Helpers to iterate through namespace types Message-ID: References: <20230404014638.3225556-1-david@gibson.dropbear.id.au> <20230404014638.3225556-9-david@gibson.dropbear.id.au> <20230405135844.26b4e08d@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="G87HKgNe5ESiIDEg" Content-Disposition: inline In-Reply-To: <20230405135844.26b4e08d@elisabeth> Message-ID-Hash: LAFGTCFP6LZZEZPN7VBKEX2GEYJDVBCR X-Message-ID-Hash: LAFGTCFP6LZZEZPN7VBKEX2GEYJDVBCR 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 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: --G87HKgNe5ESiIDEg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 05, 2023 at 01:58:44PM +0200, Stefano Brivio wrote: > On Tue, 4 Apr 2023 11:46:32 +1000 > David Gibson wrote: >=20 > > Will make things a bit less verbose in future. > >=20 > > Signed-off-by: David Gibson > > --- > > test/nstool.c | 22 ++++++++++++---------- > > 1 file changed, 12 insertions(+), 10 deletions(-) > >=20 > > diff --git a/test/nstool.c b/test/nstool.c > > index e995f3e..5681ce8 100644 > > --- a/test/nstool.c > > +++ b/test/nstool.c > > @@ -46,6 +46,14 @@ const struct ns_type nstypes[] =3D { > > { CLONE_NEWUTS, "uts" }, > > }; > > =20 > > +#define for_each_nst(_nst, _flags) \ > > + for ((_nst) =3D &nstypes[0]; \ > > + ((_nst) - nstypes) < ARRAY_SIZE(nstypes); \ > > + (_nst)++) \ > > + if ((_flags) & (_nst)->flag) > > + > > +#define for_every_nst(_nst) for_each_nst(_nst, 0x7fffffff) >=20 > Strictly speaking this should be 0x7fffff00 (minus CSIGNAL). So, I'm here deliberately not trying to embed knowledge of which ns types actually exist (if I need that, we really need to probe the kernel to find out). So this is just intended to be every bit in a positive int. I've now replaced it with INT_MAX, which is probably a better choice here. --=20 David Gibson | 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 --G87HKgNe5ESiIDEg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmQuGIIACgkQzQJF27ox 2Gd+qw//W1ZuG/VegwbMQnOa4T6QSUdRCWivNDfBGZyOji6TttbiSanJmCL0+264 ENmTghv6nlb3iRTov8D2T6NPaLRCggDv0gxSg1J+3I0H0FEudE17ac9HcPL+wR4Y PPSFG5xp3SttPcF+P7wQpLkBj62+0i43I59BkYl9RA2NV5++l6M+oZcCfNOep3aJ PWOz0kWqcgaQUrhynwv7paY0YX4Fdfj1wB259CDcu/wR9OuxLfJpNcNNWsMALojr ZUL77n36gjwGfQAu1LSdRb7XOKveUkep75ifAx2xJRqfGUf463SE9DNpeh3Hh0Jt CPTqKBBpgi1z1T5jQYauzFP2Tu1LZIMMTdm0u5ov44FubpKEhqL+FK2wY8DcVWxy RCwGy2qNrpz1wWMzjk74mHU++4LjTxKsrrdOYrTm7mc0qcpdg0GGGIxI7qScgXob I5/zc17gTCYLFNQ9bnmsT2m79rEH6NMYNJsCR3Yva3Ix1uYHMLb5E/WvtNQzHVGT WPUNkQy2ubAzX5t7Q3BBu7QIvRRrFHgLR5kjfbT7NYMoPdHlHVbKBthuX+m7ZLdc 1phm/ZJuD+xa9agzTtTjw/rjo4RX+6AYD0miepx4q0dk3iA1n5jKq3nziMW+8HAQ EoX6pdP4tqT66X8Os7l1GD2VRzIqx8mk72awN5kppkQsdaAaMQg= =KjGm -----END PGP SIGNATURE----- --G87HKgNe5ESiIDEg--