tests/file_contexts: avoid using a C99-style for loop
PATCH 1/1 tests/file_contexts: avoid using a C99-style for loop
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.
---
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(-)
tests/file_contexts/internal.c +3 -1
@@ -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];
Signature · 1 line
2.55.0
Quoted 10 lines · Ondrej Mosnacek
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:
Quoted 27 lines
---
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(-)tests/file_contexts/internal.c +3
-2@@ -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
Stephen Smalley
maintainerQuoted 8 lines · Stephen Smalley
Quoted 6 lines · Ondrej Mosnacek
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.
Quoted 7 lines
Quoted 4 lines
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]>
Thanks, merged.