On Wed, Apr 05, 2023 at 01:58:44PM +0200, Stefano Brivio wrote:On Tue, 4 Apr 2023 11:46:32 +1000 David Gibson <david(a)gibson.dropbear.id.au> wrote: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. -- 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/~dgibsonWill make things a bit less verbose in future. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/nstool.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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[] = { { CLONE_NEWUTS, "uts" }, }; +#define for_each_nst(_nst, _flags) \ + for ((_nst) = &nstypes[0]; \ + ((_nst) - nstypes) < ARRAY_SIZE(nstypes); \ + (_nst)++) \ + if ((_flags) & (_nst)->flag) + +#define for_every_nst(_nst) for_each_nst(_nst, 0x7fffffff)Strictly speaking this should be 0x7fffff00 (minus CSIGNAL).