]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: switch to use g_setenv/g_unsetenv
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 18 Dec 2019 17:16:19 +0000 (17:16 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 3 Jan 2020 15:42:12 +0000 (15:42 +0000)
Eliminate direct use of normal setenv/unsetenv calls in
favour of GLib's wrapper. This eliminates two gnulib
modules

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
28 files changed:
src/security/virt-aa-helper.c
src/util/virsystemd.c
src/vbox/vbox_XPCOMCGlue.c
tests/libxlxml2domconfigtest.c
tests/lxcxml2xmltest.c
tests/qemudomaincheckpointxml2xmltest.c
tests/qemudomainsnapshotxml2xmltest.c
tests/qemufirmwaretest.c
tests/qemuhotplugtest.c
tests/qemumemlocktest.c
tests/qemusecuritytest.c
tests/qemuvhostusertest.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c
tests/securityselinuxhelper.c
tests/testutils.c
tests/testutils.h
tests/testutilsqemu.c
tests/vircgrouptest.c
tests/virfiletest.c
tests/virhostdevtest.c
tests/virnettlscontexttest.c
tests/virnettlssessiontest.c
tests/virpcitest.c
tests/virportallocatortest.c
tests/virsystemdtest.c
tests/virtimetest.c
tools/virt-login-shell-helper.c

index f623ff965f637a98446113ccf571d6e01259c94e..6556d07b0b6033ab42f0b6353f86e2dfb98f15e9 100644 (file)
@@ -1447,11 +1447,11 @@ main(int argc, char **argv)
 
     /* clear the environment */
     environ = NULL;
-    if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
+    if (g_setenv("PATH", "/sbin:/usr/sbin", TRUE) == FALSE)
         vah_error(ctl, 1, _("could not set PATH"));
 
     /* ensure the traditional IFS setting */
-    if (setenv("IFS", " \t\n", 1) != 0)
+    if (g_setenv("IFS", " \t\n", TRUE) == FALSE)
         vah_error(ctl, 1, _("could not set IFS"));
 
     if (!(progname = strrchr(argv[0], '/')))
index 2acb54d41ed58c7f50937110a3c9ef41eb0000c2..96d43e544072c1fe39970b84e4a2f486be73a163 100644 (file)
@@ -854,8 +854,8 @@ virSystemdGetListenFDs(void)
         return 0;
     }
 
-    unsetenv("LISTEN_PID");
-    unsetenv("LISTEN_FDS");
+    g_unsetenv("LISTEN_PID");
+    g_unsetenv("LISTEN_FDS");
 
     VIR_DEBUG("Got %u file descriptors", nfds);
 
index f48a78a923aeef0b4c600b051c57c0c9c2645f81..fa5a56ede65cb3932fc3ba41a943a6ac27121b0f 100644 (file)
@@ -104,9 +104,9 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
      */
     if (setAppHome) {
         if (dir != NULL) {
-            setenv("VBOX_APP_HOME", dir, 1 /* always override */);
+            g_setenv("VBOX_APP_HOME", dir, TRUE);
         } else {
-            unsetenv("VBOX_APP_HOME");
+            g_unsetenv("VBOX_APP_HOME");
         }
     }
 
index 35f0ce8f7d2e7dbe89045c4d468b9e94ac893cf4..893b48d2826d32e7e2e0c85e8ed45108e28f88cc 100644 (file)
@@ -160,8 +160,8 @@ mymain(void)
      * results. In order to detect things that just work by a blind
      * chance, we need to set an virtual timezone that no libvirt
      * developer resides in. */
-    if (setenv("TZ", "VIR00:30", 1) < 0) {
-        perror("setenv");
+    if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
+        perror("g_setenv");
         return EXIT_FAILURE;
     }
 
index 7b05f7d01641a3ea7f07d81689a8dad27d18943a..919ad9be3b43ac385b038c4fbf24f8cbda4edfc3 100644 (file)
@@ -75,7 +75,7 @@ mymain(void)
     /* Unset or set all envvars here that are copied in lxcdBuildCommandLine
      * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
      * values for these envvars */
-    setenv("PATH", "/bin", 1);
+    g_setenv("PATH", "/bin", TRUE);
 
     DO_TEST("systemd");
     DO_TEST("hostdev");
index 4d6904a592f6a2ace090a3ba230f800a33ed277e..b73ac74e815ad38c9c7387d3e07f959418c5cb66 100644 (file)
@@ -175,7 +175,7 @@ mymain(void)
     /* Unset or set all envvars here that are copied in qemudBuildCommandLine
      * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
      * values for these envvars */
-    setenv("PATH", "/bin", 1);
+    g_setenv("PATH", "/bin", TRUE);
 
     /* Test a normal user redefine */
     DO_TEST_OUT("redefine", 0);
index 6bff5d14f575e7f74f57f1106878f44691726d8f..220dae33b9995dd8873c49c297ffee3c218ce657 100644 (file)
@@ -160,7 +160,7 @@ mymain(void)
     /* Unset or set all envvars here that are copied in qemudBuildCommandLine
      * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
      * values for these envvars */
-    setenv("PATH", "/bin", 1);
+    g_setenv("PATH", "/bin", TRUE);
 
     DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
                 TEST_INTERNAL);
index 906d594ace6f5589cde5647e093325270f4ce6e1..2b56e5ac8269616fa76587c79d7b341b924a1670 100644 (file)
@@ -70,7 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED)
 
     fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
 
-    setenv("XDG_CONFIG_HOME", fakehome, 1);
+    g_setenv("XDG_CONFIG_HOME", fakehome, TRUE);
 
     if (qemuFirmwareFetchConfigs(&fwList, false) < 0)
         return -1;
index 6ab2d9b0f4c705a18a96a70a703cbe059ba2f3c2..a60c8d1c9389b5f731c5871525b0f6ba719f3819 100644 (file)
@@ -603,7 +603,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
     if (qemuTestDriverInit(&driver) < 0)
         return EXIT_FAILURE;
index 7de0d72410349e7959bfba1bf8822d6d2413d014..3f18fed1c33d970a7bbcca7f08673d7e4afb103c 100644 (file)
@@ -67,7 +67,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
     if (qemuTestDriverInit(&driver) < 0) {
         VIR_FREE(fakerootdir);
index 380c3fed8c3356f9c0f5c0b78f9a122a68523fc3..4b5bfabebae6981a1afe777395ed1b694507a859 100644 (file)
@@ -111,7 +111,7 @@ testDomain(const void *opaque)
 
     /* Mocking is enabled only when this env variable is set.
      * See mock code for explanation. */
-    if (setenv(ENVVAR, "1", 0) < 0)
+    if (g_setenv(ENVVAR, "1", FALSE) == FALSE)
         return -1;
 
     if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
@@ -124,7 +124,7 @@ testDomain(const void *opaque)
 
     ret = 0;
  cleanup:
-    unsetenv(ENVVAR);
+    g_unsetenv(ENVVAR);
     freePaths();
     return ret;
 }
index cc1e5238414e8c396544889d9a7dccdd80f38d1f..273db560e3b5850a8003bd60e5cdbbe413311523 100644 (file)
@@ -68,7 +68,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED)
 
     fakehome = g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config");
 
-    setenv("XDG_CONFIG_HOME", fakehome, 1);
+    g_setenv("XDG_CONFIG_HOME", fakehome, TRUE);
 
     if (qemuVhostUserFetchConfigs(&vuList, false) < 0)
         return -1;
index bfbed5c31dec4abf02a4c6edeb879f1895dc46bc..8af2ba38d3f3420ee3bb0be1be6dc43171e7062e 100644 (file)
@@ -618,15 +618,15 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
     /* 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
      * chance, we need to set an virtual timezone that no libvirt
      * developer resides in. */
-    if (setenv("TZ", "VIR00:30", 1) < 0) {
-        perror("setenv");
+    if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
+        perror("g_setenv");
         return EXIT_FAILURE;
     }
 
@@ -797,15 +797,15 @@ mymain(void)
     /* Unset or set all envvars here that are copied in qemudBuildCommandLine
      * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
      * values for these envvars */
-    setenv("PATH", "/bin", 1);
-    setenv("USER", "test", 1);
-    setenv("LOGNAME", "test", 1);
-    setenv("HOME", "/home/test", 1);
-    unsetenv("TMPDIR");
-    unsetenv("LD_PRELOAD");
-    unsetenv("LD_LIBRARY_PATH");
-    unsetenv("QEMU_AUDIO_DRV");
-    unsetenv("SDL_AUDIODRIVER");
+    g_setenv("PATH", "/bin", TRUE);
+    g_setenv("USER", "test", TRUE);
+    g_setenv("LOGNAME", "test", TRUE);
+    g_setenv("HOME", "/home/test", TRUE);
+    g_unsetenv("TMPDIR");
+    g_unsetenv("LD_PRELOAD");
+    g_unsetenv("LD_LIBRARY_PATH");
+    g_unsetenv("QEMU_AUDIO_DRV");
+    g_unsetenv("SDL_AUDIODRIVER");
 
     DO_TEST("minimal", NONE);
     DO_TEST("minimal-sandbox",
index 34c2ec8c5fd5cdbfb5d7330f4b0f180131ac8195..262fc835f5ca1a3238b069c68c249c41db2fab25 100644 (file)
@@ -147,7 +147,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
     /* Required for tpm-emulator tests
      */
@@ -234,7 +234,7 @@ mymain(void)
     /* Unset or set all envvars here that are copied in qemudBuildCommandLine
      * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
      * values for these envvars */
-    setenv("PATH", "/bin", 1);
+    g_setenv("PATH", "/bin", TRUE);
 
     DO_TEST("minimal", NONE);
     DO_TEST_CAPS_LATEST("genid");
index 8b90ddada9f20917929758f68384590917045152..f89224c07a48d2524fe04ea8de36180124864cb0 100644 (file)
@@ -145,7 +145,7 @@ int setcon_raw(const char *context)
         errno = EINVAL;
         return -1;
     }
-    return setenv("FAKE_SELINUX_CONTEXT", context, 1);
+    return g_setenv("FAKE_SELINUX_CONTEXT", context, TRUE);
 }
 
 int setcon(const char *context)
@@ -224,7 +224,7 @@ int security_disable(void)
         return -1;
     }
 
-    return setenv("FAKE_SELINUX_DISABLED", "1", 1);
+    return g_setenv("FAKE_SELINUX_DISABLED", "1", TRUE);
 }
 
 int security_getenforce(void)
index 6efc877d0c7b1148d32c99c6001dcee8be7ee859..f3f66169675534aed43b41bbe5e53d9a424e71ce 100644 (file)
@@ -127,7 +127,7 @@ virTestRun(const char *title,
     /* Some test are fragile about environ settings.  If that's
      * the case, don't poison it. */
     if (getenv("VIR_TEST_MOCK_PROGNAME"))
-        setenv("VIR_TEST_MOCK_TESTNAME", title, 1);
+        g_setenv("VIR_TEST_MOCK_TESTNAME", title, TRUE);
 
     if (testCounter == 0 && !virTestGetVerbose())
         fprintf(stderr, "      ");
@@ -176,7 +176,7 @@ virTestRun(const char *title,
             fprintf(stderr, "!");
     }
 
-    unsetenv("VIR_TEST_MOCK_TESTNAME");
+    g_unsetenv("VIR_TEST_MOCK_TESTNAME");
     return ret;
 }
 
@@ -836,7 +836,7 @@ virTestSetEnvPath(void)
     }
 
     if (new_path &&
-        setenv("PATH", new_path, 1) < 0)
+        g_setenv("PATH", new_path, TRUE) < 0)
         goto cleanup;
 
     ret = 0;
@@ -870,7 +870,7 @@ int virTestMain(int argc,
     if (STRPREFIX(progname, "lt-"))
         progname += 3;
 
-    setenv("VIR_TEST_MOCK_PROGNAME", progname, 1);
+    g_setenv("VIR_TEST_MOCK_PROGNAME", progname, TRUE);
 
     virFileActivateDirOverrideForProg(argv[0]);
 
index dcb7cc4c0451d55c82800587336fc2ee697d5864..f62d435555cb833c6f386efe72146d809be2a684 100644 (file)
@@ -121,7 +121,7 @@ int virTestMain(int argc,
 #ifdef __APPLE__
 # define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
 # define FORCE_FLAT_NAMESPACE \
-            setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
+            g_setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", TRUE);
 # define MOCK_EXT ".dylib"
 #else
 # define PRELOAD_VAR "LD_PRELOAD"
@@ -143,7 +143,7 @@ int virTestMain(int argc,
             } else { \
                 newenv = g_strdup_printf("%s:%s", lib, preload); \
             } \
-            setenv(PRELOAD_VAR, newenv, 1); \
+            g_setenv(PRELOAD_VAR, newenv, TRUE); \
             FORCE_FLAT_NAMESPACE \
             execv(argv[0], argv); \
         } \
index d077f8cd2dc92964dff7b35c277c2da6ec68f1cb..8a4fdb194966cd0b843e89ebfde5631fda68a936 100644 (file)
@@ -260,10 +260,10 @@ qemuTestSetHostCPU(virQEMUDriverPtr driver,
             cpu = cpuPower8;
     }
 
-    unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
+    g_unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
     if (cpu) {
         if (cpu->model)
-            setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
+            g_setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, TRUE);
     }
     if (driver) {
         if (cpu)
index 5e9f619a847918b242bead8aa0085eaef7b82d5a..2d6f52fb6ebf6681015736e6761f1a882f7ccf3e 100644 (file)
@@ -187,7 +187,7 @@ testCgroupDetectMounts(const void *args)
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     size_t i;
 
-    setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
+    g_setenv("VIR_CGROUP_MOCK_FILENAME", data->file, TRUE);
 
     parsed = g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir, data->file);
 
@@ -215,7 +215,7 @@ testCgroupDetectMounts(const void *args)
     result = 0;
 
  cleanup:
-    unsetenv("VIR_CGROUP_MOCK_FILENAME");
+    g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
     VIR_FREE(parsed);
     virCgroupFree(&group);
     virBufferFreeAndReset(&buf);
@@ -994,13 +994,13 @@ initFakeFS(const char *mode,
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
     if (mode)
-        setenv("VIR_CGROUP_MOCK_MODE", mode, 1);
+        g_setenv("VIR_CGROUP_MOCK_MODE", mode, TRUE);
 
     if (filename)
-        setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1);
+        g_setenv("VIR_CGROUP_MOCK_FILENAME", filename, TRUE);
 
     return fakerootdir;
 }
@@ -1012,9 +1012,9 @@ cleanupFakeFS(char *fakerootdir)
         virFileDeleteTree(fakerootdir);
 
     VIR_FREE(fakerootdir);
-    unsetenv("LIBVIRT_FAKE_ROOT_DIR");
-    unsetenv("VIR_CGROUP_MOCK_MODE");
-    unsetenv("VIR_CGROUP_MOCK_FILENAME");
+    g_unsetenv("LIBVIRT_FAKE_ROOT_DIR");
+    g_unsetenv("VIR_CGROUP_MOCK_MODE");
+    g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
 }
 
 static int
index 781c640e2b958beb5624ed51810edc45b8cb20f3..a412fdad23ab97eae145aaf2fbefc8bcd7077173 100644 (file)
@@ -327,7 +327,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
 
     mtabFile = g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabFile);
 
-    if (setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) {
+    if (g_setenv("LIBVIRT_MTAB", mtabFile, TRUE) == FALSE) {
         fprintf(stderr, "Unable to set env variable\n");
         goto cleanup;
     }
@@ -343,7 +343,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
     ret = 0;
  cleanup:
     VIR_FREE(mtabFile);
-    unsetenv("LIBVIRT_MTAB");
+    g_unsetenv("LIBVIRT_MTAB");
     return ret;
 #endif
 }
index ffd7ce1aabfd7b63dc2785daf028291553dd4e87..b76b78eb5688456def286945202e8a2a10317357 100644 (file)
@@ -603,7 +603,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
 # define DO_TEST(fnc) \
     do { \
index 6c0133642089f83c398af15bed20a64f866e7eae..8013f9eda8fb36c25961e83c417850aa5d198a8a 100644 (file)
@@ -111,7 +111,7 @@ mymain(void)
 {
     int ret = 0;
 
-    setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+    g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
 
     testTLSInit(KEYFILE);
 
index 997cf5a372ab79dc60011a024f5aecf6a495a9d5..4f1b2aa8d2e5e757fa7de519137aafb83418d338 100644 (file)
@@ -239,7 +239,7 @@ mymain(void)
 {
     int ret = 0;
 
-    setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+    g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
 
     testTLSInit(KEYFILE);
 
index 68fe9c8345476ebebd5bac48a88797bde81d35e3..6f064a3f858fe49aa202c83b55bb8dc46914fedc 100644 (file)
@@ -334,7 +334,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
 
 # define DO_TEST(fnc) \
     do { \
index 8e62fc451923ef98d466ca5efca3eb63b753586a..7690377ad310d554f35f70ba7e378bd143dfd15b 100644 (file)
@@ -171,7 +171,7 @@ mymain(void)
     if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0)
         ret = -1;
 
-    setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1);
+    g_setenv("LIBVIRT_TEST_IPV4ONLY", "really", TRUE);
 
     if (virTestRun("Test IPv4-only alloc all", testAllocAll, NULL) < 0)
         ret = -1;
index b5624241bb022152d8366f702ded186432e6830a..9b95ca6789fd1419de16dc2bf0fdb97a87222145 100644 (file)
@@ -236,7 +236,7 @@ static int testCreateNoSystemd(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_NO_SERVICE", "1", 1);
+    g_setenv("FAIL_NO_SERVICE", "1", TRUE);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -246,11 +246,11 @@ static int testCreateNoSystemd(const void *opaque G_GNUC_UNUSED)
                                       false,
                                       0, NULL,
                                       NULL, 0)) == 0) {
-        unsetenv("FAIL_NO_SERVICE");
+        g_unsetenv("FAIL_NO_SERVICE");
         fprintf(stderr, "%s", "Unexpected create machine success\n");
         return -1;
     }
-    unsetenv("FAIL_NO_SERVICE");
+    g_unsetenv("FAIL_NO_SERVICE");
 
     if (rv != -2) {
         fprintf(stderr, "%s", "Unexpected create machine error\n");
@@ -270,7 +270,7 @@ static int testCreateSystemdNotRunning(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_NOT_REGISTERED", "1", 1);
+    g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -280,11 +280,11 @@ static int testCreateSystemdNotRunning(const void *opaque G_GNUC_UNUSED)
                                       false,
                                       0, NULL,
                                       NULL, 0)) == 0) {
-        unsetenv("FAIL_NOT_REGISTERED");
+        g_unsetenv("FAIL_NOT_REGISTERED");
         fprintf(stderr, "%s", "Unexpected create machine success\n");
         return -1;
     }
-    unsetenv("FAIL_NOT_REGISTERED");
+    g_unsetenv("FAIL_NOT_REGISTERED");
 
     if (rv != -2) {
         fprintf(stderr, "%s", "Unexpected create machine error\n");
@@ -304,7 +304,7 @@ static int testCreateBadSystemd(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_BAD_SERVICE", "1", 1);
+    g_setenv("FAIL_BAD_SERVICE", "1", TRUE);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -314,11 +314,11 @@ static int testCreateBadSystemd(const void *opaque G_GNUC_UNUSED)
                                       false,
                                       0, NULL,
                                       NULL, 0)) == 0) {
-        unsetenv("FAIL_BAD_SERVICE");
+        g_unsetenv("FAIL_BAD_SERVICE");
         fprintf(stderr, "%s", "Unexpected create machine success\n");
         return -1;
     }
-    unsetenv("FAIL_BAD_SERVICE");
+    g_unsetenv("FAIL_BAD_SERVICE");
 
     if (rv != -1) {
         fprintf(stderr, "%s", "Unexpected create machine error\n");
@@ -445,7 +445,7 @@ static int testPMSupportHelper(const void *opaque)
     const struct testPMSupportData *data = opaque;
 
     for (i = 0; i < 4; i++) {
-        setenv("RESULT_SUPPORT",  results[i], 1);
+        g_setenv("RESULT_SUPPORT",  results[i], TRUE);
         if ((rv = data->tested(&result)) < 0) {
             fprintf(stderr, "%s", "Unexpected canSuspend error\n");
             return -1;
@@ -455,12 +455,12 @@ static int testPMSupportHelper(const void *opaque)
             fprintf(stderr, "Unexpected result for answer '%s'\n", results[i]);
             goto error;
         }
-        unsetenv("RESULT_SUPPORT");
+        g_unsetenv("RESULT_SUPPORT");
     }
 
     return 0;
  error:
-    unsetenv("RESULT_SUPPORT");
+    g_unsetenv("RESULT_SUPPORT");
     return -1;
 }
 
@@ -470,14 +470,14 @@ static int testPMSupportHelperNoSystemd(const void *opaque)
     bool result;
     const struct testPMSupportData *data = opaque;
 
-    setenv("FAIL_NO_SERVICE", "1", 1);
+    g_setenv("FAIL_NO_SERVICE", "1", TRUE);
 
     if ((rv = data->tested(&result)) == 0) {
-        unsetenv("FAIL_NO_SERVICE");
+        g_unsetenv("FAIL_NO_SERVICE");
         fprintf(stderr, "%s", "Unexpected canSuspend success\n");
         return -1;
     }
-    unsetenv("FAIL_NO_SERVICE");
+    g_unsetenv("FAIL_NO_SERVICE");
 
     if (rv != -2) {
         fprintf(stderr, "%s", "Unexpected canSuspend error\n");
@@ -493,14 +493,14 @@ static int testPMSupportSystemdNotRunning(const void *opaque)
     bool result;
     const struct testPMSupportData *data = opaque;
 
-    setenv("FAIL_NOT_REGISTERED", "1", 1);
+    g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
 
     if ((rv = data->tested(&result)) == 0) {
-        unsetenv("FAIL_NOT_REGISTERED");
+        g_unsetenv("FAIL_NOT_REGISTERED");
         fprintf(stderr, "%s", "Unexpected canSuspend success\n");
         return -1;
     }
-    unsetenv("FAIL_NOT_REGISTERED");
+    g_unsetenv("FAIL_NOT_REGISTERED");
 
     if (rv != -2) {
         fprintf(stderr, "%s", "Unexpected canSuspend error\n");
@@ -567,13 +567,13 @@ testActivation(bool useNames)
     g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
     g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
 
-    setenv("LISTEN_FDS", nfdstr, 1);
-    setenv("LISTEN_PID", pidstr, 1);
+    g_setenv("LISTEN_FDS", nfdstr, TRUE);
+    g_setenv("LISTEN_PID", pidstr, TRUE);
 
     if (useNames)
-        setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
+        g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), TRUE);
     else
-        unsetenv("LISTEN_FDNAMES");
+        g_unsetenv("LISTEN_FDNAMES");
 
     map[0].name = "demo-unix.socket";
     map[0].family = AF_UNIX;
@@ -640,7 +640,7 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED)
 {
     virSystemdActivationPtr act;
 
-    unsetenv("LISTEN_FDS");
+    g_unsetenv("LISTEN_FDS");
 
     if (virSystemdGetActivation(NULL, 0, &act) < 0)
         return -1;
index 1eb321858b5005e89a266d1d8b81846c8fa6886a..f8a81ff09066b7ea3544ba20b4ca29a9f3192afb 100644 (file)
@@ -79,8 +79,8 @@ testTimeLocalOffset(const void *args)
     const testTimeLocalOffsetData *data = args;
     long actual;
 
-    if (setenv("TZ", data->zone, 1) < 0) {
-        perror("setenv");
+    if (g_setenv("TZ", data->zone, TRUE) == FALSE) {
+        perror("g_setenv");
         return -1;
     }
     tzset();
index ace8733968d3758218cfdcd74a528009af62f181..cdd64d9a59553804724ad9fe638a63ca8ce7d2fc 100644 (file)
@@ -382,13 +382,13 @@ main(int argc, char **argv)
         }
 
         clearenv();
-        setenv("PATH", "/bin:/usr/bin", 1);
-        setenv("SHELL", shcmd, 1);
-        setenv("USER", name, 1);
-        setenv("LOGNAME", name, 1);
-        setenv("HOME", homedir, 1);
+        g_setenv("PATH", "/bin:/usr/bin", TRUE);
+        g_setenv("SHELL", shcmd, TRUE);
+        g_setenv("USER", name, TRUE);
+        g_setenv("LOGNAME", name, TRUE);
+        g_setenv("HOME", homedir, TRUE);
         if (term)
-            setenv("TERM", term, 1);
+            g_setenv("TERM", term, TRUE);
 
         if (execv(shcmd, (char *const*) shargv) < 0) {
             virReportSystemError(errno, _("Unable to exec shell %s"),