[PATCH testsuite] tests/file_contexts: avoid using a C99-style for loop

Ondrej Mosnacek <[email protected]> Mon, 27 Jul 2026 13:52:47 +0200
Newsgroups org.kernel.vger.selinux
Message-ID <[email protected]>
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]>
---

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