Skip to contentSkip to conversation

libselinux/utils/getseuser.c: fix build with gcc 4.8

PATCH Applied Fabrice Fontaine 2 participants 3 messages Jul 1, 2021 – Jul 3, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux/utils/getseuser.c: fix build with gcc 4.8

Fix the following build failure with gcc 4.8 which is raised since version 3.2 and
https://github.com/SELinuxProject/selinux/commit/156dd0de5cad31e7d437c64e11a8aef027f0a691

getseuser.c:53:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < n; i++)
^

Fixes:
- http://autobuild.buildroot.org/results/37eb0952a763256fbf6ef3c668f6c95fbdf2dd35

---
 libselinux/utils/getseuser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/utils/getseuser.c +2 -2
index ce1b7b27..34f2e887 100644
@@ -9,7 +9,7 @@ int main(int argc, char **argv)
 {
 	char *seuser = NULL, *level = NULL;
 	char **contextlist;
-	int rc, n;
+	int rc, n, i;
 
 	if (argc != 3) {
 		fprintf(stderr, "usage:  %s linuxuser fromcon\n", argv[0]);
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
 	if (n == 0)
 		printf("no valid context found\n");
 
-	for (int i = 0; i < n; i++)
+	for (i = 0; i < n; i++)
 		printf("Context %d\t%s\n", i, contextlist[i]);
 
 	freeconary(contextlist);
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Fabrice Fontaine

Fix the following build failure with gcc 4.8 which is raised since version 3.2 and
https://github.com/SELinuxProject/selinux/commit/156dd0de5cad31e7d437c64e11a8aef027f0a691

Quoted 8 lines

getseuser.c:53:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < n; i++)
^

Fixes:
- http://autobuild.buildroot.org/results/37eb0952a763256fbf6ef3c668f6c95fbdf2dd35

If nobody else has comments, I will apply this patch tomorrow. Thanks!
Nicolas

Quoted 29 lines
---
 libselinux/utils/getseuser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/utils/getseuser.c +2 -3
index ce1b7b27..34f2e887 100644
@@ -9,7 +9,7 @@ int main(int argc, char **argv)
 {
        char *seuser = NULL, *level = NULL;
        char **contextlist;
-       int rc, n;
+       int rc, n, i;
 
        if (argc != 3) {
                fprintf(stderr, "usage:  %s linuxuser fromcon\n", argv[0]);
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
        if (n == 0)
                printf("no valid context found\n");
 
-       for (int i = 0; i < n; i++)
+       for (i = 0; i < n; i++)
                printf("Context %d\t%s\n", i, contextlist[i]);
 
        freeconary(contextlist);
--

2.30.2

#2 lore raw
Quoted 15 lines · Nicolas Iooss
Quoted 12 lines · Fabrice Fontaine

Fix the following build failure with gcc 4.8 which is raised since version 3.2 and
https://github.com/SELinuxProject/selinux/commit/156dd0de5cad31e7d437c64e11a8aef027f0a691

getseuser.c:53:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < n; i++)
^

Fixes:
- http://autobuild.buildroot.org/results/37eb0952a763256fbf6ef3c668f6c95fbdf2dd35

Quoted 7 lines
Quoted 1 line

If nobody else has comments, I will apply this patch tomorrow. Thanks!
Nicolas

Applied.
Thanks,
Nicolas

Quoted 29 lines
Quoted 29 lines
---
 libselinux/utils/getseuser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/utils/getseuser.c +2 -3
index ce1b7b27..34f2e887 100644
@@ -9,7 +9,7 @@ int main(int argc, char **argv)
 {
        char *seuser = NULL, *level = NULL;
        char **contextlist;
-       int rc, n;
+       int rc, n, i;
 
        if (argc != 3) {
                fprintf(stderr, "usage:  %s linuxuser fromcon\n", argv[0]);
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
        if (n == 0)
                printf("no valid context found\n");
 
-       for (int i = 0; i < n; i++)
+       for (i = 0; i < n; i++)
                printf("Context %d\t%s\n", i, contextlist[i]);
 
        freeconary(contextlist);
--

2.30.2