Re: [PATCH testsuite] tests/file_contexts: avoid using a C99-style for loop
Stephen Smalley <[email protected]> Mon, 27 Jul 2026 09:33:45 -0400
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <CAEjxPJ7WpL2N7ZJ=jkNFNKpvFtWga+Ub8ufFwaPFZWzMQ=LqYg@mail.gmail.com> |
On Mon, Jul 27, 2026 at 7:54 AM Ondrej Mosnacek <[email protected]> wrote: > > The for loop in assertContextsMatch() seems to be the only code that > makes use of C99 features, which means that it fails to build with older > compilers, such as GCC on RHEL-7. Avoid this by moving the declaration > out of the for loop. > > An alternative would be to instead add -std=c99 to CFLAGS, but it seems > simpler to just revert to the C90 status quo ante. > > Signed-off-by: Ondrej Mosnacek <[email protected]> It makes me sad that there are still people using RHEL-7 but: Acked-by: Stephen Smalley <[email protected]> > --- > > If someone strongly prefers the -std=c99 solution, feel free to submit > an alternative patch. I don't have a strong preference here. > > tests/file_contexts/internal.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tests/file_contexts/internal.c b/tests/file_contexts/internal.c > index 22b5790..20ab428 100644 > --- a/tests/file_contexts/internal.c > +++ b/tests/file_contexts/internal.c > @@ -13,7 +13,9 @@ > void assertContextsMatch(struct selabel_handle *hnd, struct test_t *tests, > size_t n) > { > - for (int i = 0; i < n; i++) { > + int i; > + > + for (i = 0; i < n; i++) { > char *context = NULL; > struct test_t test = tests[i]; > > -- > 2.55.0 > >