This code snippet has clearly been cargo-culted, and all its
instances can be safely dropped seeing as 1) a much better
way to handle the scenario in C programs would be to pass the
value via the preprocessor, and 2) the value is actually not
used anywhere after being defined.

Signed-off-by: Andrea Bolognani <abolo...@redhat.com>
---
 tests/libxlxml2domconfigtest.c   | 5 -----
 tests/networkxml2firewalltest.c  | 6 ------
 tests/nwfilterxml2firewalltest.c | 6 ------
 tests/qemumemlocktest.c          | 5 -----
 tests/qemuxml2argvtest.c         | 5 -----
 tests/virscsitest.c              | 5 -----
 6 files changed, 32 deletions(-)

diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index 863d8cded5..a96422b3f9 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -41,7 +41,6 @@
 
 # define VIR_FROM_THIS VIR_FROM_LIBXL
 
-static const char *abs_top_srcdir;
 static virCapsPtr caps;
 
 static int
@@ -172,10 +171,6 @@ mymain(void)
 {
     int ret = 0;
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
     /* Set the timezone because we are mocking the time() function.
      * If we don't do that, then localtime() may return unpredictable
      * results. In order to detect things that just work by a blind
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index 91bb6e6b8a..575b68379a 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -36,8 +36,6 @@
 
 # define VIR_FROM_THIS VIR_FROM_NONE
 
-static const char *abs_top_srcdir;
-
 # ifdef __linux__
 #  define RULESTYPE "linux"
 # else
@@ -136,10 +134,6 @@ mymain(void)
 {
     int ret = 0;
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
 # define DO_TEST(name) \
     do { \
         static struct testInfo info = { \
diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c
index b4cfe5769e..bea267f0fc 100644
--- a/tests/nwfilterxml2firewalltest.c
+++ b/tests/nwfilterxml2firewalltest.c
@@ -35,8 +35,6 @@
 
 # define VIR_FROM_THIS VIR_FROM_NONE
 
-static const char *abs_top_srcdir;
-
 # ifdef __linux__
 #  define RULESTYPE "linux"
 # else
@@ -459,10 +457,6 @@ mymain(void)
 {
     int ret = 0;
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
 # define DO_TEST(name) \
     do { \
         static struct testInfo info = { \
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index 786f647cf0..42a4643338 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -19,7 +19,6 @@
 
 # define VIR_FROM_THIS VIR_FROM_QEMU
 
-static const char *abs_top_srcdir;
 static virQEMUDriver driver;
 
 struct testInfo {
@@ -74,10 +73,6 @@ mymain(void)
 
     setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
     if (qemuTestDriverInit(&driver) < 0) {
         VIR_FREE(fakerootdir);
         return EXIT_FAILURE;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 03e8d79595..67c5c74ec5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -33,7 +33,6 @@
 
 # define VIR_FROM_THIS VIR_FROM_QEMU
 
-static const char *abs_top_srcdir;
 static virQEMUDriver driver;
 
 static unsigned char *
@@ -653,10 +652,6 @@ mymain(void)
 
     setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
     /* Set the timezone because we are mocking the time() function.
      * If we don't do that, then localtime() may return unpredictable
      * results. In order to detect things that just work by a blind
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index 665f70e28b..be3ef6234e 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -30,7 +30,6 @@
 
 VIR_LOG_INIT("tests.scsitest");
 
-static const char *abs_top_srcdir;
 static char *virscsi_prefix;
 
 static int
@@ -195,10 +194,6 @@ mymain(void)
     char *tmpdir = NULL;
     char template[] = "/tmp/libvirt_XXXXXX";
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir)
-        abs_top_srcdir = abs_srcdir "/..";
-
     if (virAsprintf(&virscsi_prefix, "%s" VIR_SCSI_DATA, abs_srcdir) < 0) {
         ret = -1;
         goto cleanup;
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to