Skip to content

Commit 2c33532

Browse files
committed
src: switch to use g_setenv/g_unsetenv
Eliminate direct use of normal setenv/unsetenv calls in favour of GLib's wrapper. This eliminates two gnulib modules Reviewed-by: Fabiano Fidêncio <[email protected]> Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent 4eed65a commit 2c33532

28 files changed

+87
-87
lines changed

src/security/virt-aa-helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,11 +1447,11 @@ main(int argc, char **argv)
14471447

14481448
/* clear the environment */
14491449
environ = NULL;
1450-
if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
1450+
if (g_setenv("PATH", "/sbin:/usr/sbin", TRUE) == FALSE)
14511451
vah_error(ctl, 1, _("could not set PATH"));
14521452

14531453
/* ensure the traditional IFS setting */
1454-
if (setenv("IFS", " \t\n", 1) != 0)
1454+
if (g_setenv("IFS", " \t\n", TRUE) == FALSE)
14551455
vah_error(ctl, 1, _("could not set IFS"));
14561456

14571457
if (!(progname = strrchr(argv[0], '/')))

src/util/virsystemd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ virSystemdGetListenFDs(void)
854854
return 0;
855855
}
856856

857-
unsetenv("LISTEN_PID");
858-
unsetenv("LISTEN_FDS");
857+
g_unsetenv("LISTEN_PID");
858+
g_unsetenv("LISTEN_FDS");
859859

860860
VIR_DEBUG("Got %u file descriptors", nfds);
861861

src/vbox/vbox_XPCOMCGlue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
104104
*/
105105
if (setAppHome) {
106106
if (dir != NULL) {
107-
setenv("VBOX_APP_HOME", dir, 1 /* always override */);
107+
g_setenv("VBOX_APP_HOME", dir, TRUE);
108108
} else {
109-
unsetenv("VBOX_APP_HOME");
109+
g_unsetenv("VBOX_APP_HOME");
110110
}
111111
}
112112

tests/libxlxml2domconfigtest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ mymain(void)
160160
* results. In order to detect things that just work by a blind
161161
* chance, we need to set an virtual timezone that no libvirt
162162
* developer resides in. */
163-
if (setenv("TZ", "VIR00:30", 1) < 0) {
164-
perror("setenv");
163+
if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
164+
perror("g_setenv");
165165
return EXIT_FAILURE;
166166
}
167167

tests/lxcxml2xmltest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ mymain(void)
7575
/* Unset or set all envvars here that are copied in lxcdBuildCommandLine
7676
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
7777
* values for these envvars */
78-
setenv("PATH", "/bin", 1);
78+
g_setenv("PATH", "/bin", TRUE);
7979

8080
DO_TEST("systemd");
8181
DO_TEST("hostdev");

tests/qemudomaincheckpointxml2xmltest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ mymain(void)
175175
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
176176
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
177177
* values for these envvars */
178-
setenv("PATH", "/bin", 1);
178+
g_setenv("PATH", "/bin", TRUE);
179179

180180
/* Test a normal user redefine */
181181
DO_TEST_OUT("redefine", 0);

tests/qemudomainsnapshotxml2xmltest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mymain(void)
160160
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
161161
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
162162
* values for these envvars */
163-
setenv("PATH", "/bin", 1);
163+
g_setenv("PATH", "/bin", TRUE);
164164

165165
DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
166166
TEST_INTERNAL);

tests/qemufirmwaretest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED)
7070

7171
fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
7272

73-
setenv("XDG_CONFIG_HOME", fakehome, 1);
73+
g_setenv("XDG_CONFIG_HOME", fakehome, TRUE);
7474

7575
if (qemuFirmwareFetchConfigs(&fwList, false) < 0)
7676
return -1;

tests/qemuhotplugtest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ mymain(void)
603603
abort();
604604
}
605605

606-
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
606+
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
607607

608608
if (qemuTestDriverInit(&driver) < 0)
609609
return EXIT_FAILURE;

tests/qemumemlocktest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mymain(void)
6767
abort();
6868
}
6969

70-
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
70+
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
7171

7272
if (qemuTestDriverInit(&driver) < 0) {
7373
VIR_FREE(fakerootdir);

0 commit comments

Comments
 (0)