[libvirt PATCH v2 03/13] tests: always declare environ

Daniel P. Berrangé berrange at redhat.com
Thu Jan 16 15:24:38 UTC 2020


Some UNIX platforms don't declare 'environ' in their
header files. We can unconditionally declare it ourselves
to avoid this problem.

There is no need to do this in the aa-helper code
since that is Linux only code.

Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 tests/commandhelper.c | 3 +++
 tests/commandtest.c   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 77cbcd4680..a7a3c44e33 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -31,6 +31,9 @@
 
 #ifndef WIN32
 
+/* Some UNIX lack it in headers & it doesn't hurt to redeclare */
+extern char **environ;
+
 # define VIR_FROM_THIS VIR_FROM_NONE
 
 static int envsort(const void *a, const void *b)
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 5df1aa4221..cc8676811e 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -58,6 +58,9 @@ main(void)
 
 #else
 
+/* Some UNIX lack it in headers & it doesn't hurt to redeclare */
+extern char **environ;
+
 static int checkoutput(const char *testname,
                        char *prefix)
 {
-- 
2.24.1




More information about the libvir-list mailing list