* [PATCH] glib: use portable g_setenv()
@ 2019-12-11 14:23 Paolo Bonzini
2019-12-11 19:32 ` Thomas Huth
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2019-12-11 14:23 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
We have a setenv() wrapper in os-win32.c that no one is actually using.
Drop it and change to g_setenv() uniformly.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/sysemu/os-win32.h | 2 --
os-win32.c | 22 ----------------------
tests/libqtest.c | 2 +-
tests/test-crypto-tlscredsx509.c | 2 +-
tests/test-crypto-tlssession.c | 2 +-
tests/test-io-channel-tls.c | 2 +-
tests/test-vmstate.c | 2 +-
ui/sdl2.c | 2 +-
8 files changed, 6 insertions(+), 30 deletions(-)
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index ff18b23..d8978e2 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -67,8 +67,6 @@ int getpagesize(void);
# define EPROTONOSUPPORT EINVAL
#endif
-int setenv(const char *name, const char *value, int overwrite);
-
typedef struct {
long tv_sec;
long tv_usec;
diff --git a/os-win32.c b/os-win32.c
index 1336cd3..6b86e02 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -30,28 +30,6 @@
#include "qemu-options.h"
#include "sysemu/runstate.h"
-/***********************************************************/
-/* Functions missing in mingw */
-
-int setenv(const char *name, const char *value, int overwrite)
-{
- int result = 0;
- if (overwrite || !getenv(name)) {
- size_t length = strlen(name) + strlen(value) + 2;
- char *string = g_malloc(length);
- snprintf(string, length, "%s=%s", name, value);
- result = putenv(string);
-
- /* Windows takes a copy and does not continue to use our string.
- * Therefore it can be safely freed on this platform. POSIX code
- * typically has to leak the string because according to the spec it
- * becomes part of the environment.
- */
- g_free(string);
- }
- return result;
-}
-
static BOOL WINAPI qemu_ctrl_handler(DWORD type)
{
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_SIGNAL);
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 91e9cb2..f36e30a 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -254,7 +254,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
s->expected_status = 0;
s->qemu_pid = fork();
if (s->qemu_pid == 0) {
- setenv("QEMU_AUDIO_DRV", "none", true);
+ g_setenv("QEMU_AUDIO_DRV", "none", true);
execlp("/bin/sh", "sh", "-c", command, NULL);
exit(1);
}
diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx509.c
index a27efb7..f487349 100644
--- a/tests/test-crypto-tlscredsx509.c
+++ b/tests/test-crypto-tlscredsx509.c
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
g_test_init(&argc, &argv, NULL);
- setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+ g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
mkdir(WORKDIR, 0700);
diff --git a/tests/test-crypto-tlssession.c b/tests/test-crypto-tlssession.c
index 6560d71..8b2453f 100644
--- a/tests/test-crypto-tlssession.c
+++ b/tests/test-crypto-tlssession.c
@@ -398,7 +398,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
g_test_init(&argc, &argv, NULL);
- setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+ g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
mkdir(WORKDIR, 0700);
diff --git a/tests/test-io-channel-tls.c b/tests/test-io-channel-tls.c
index 3c9ef6f..ad7554c 100644
--- a/tests/test-io-channel-tls.c
+++ b/tests/test-io-channel-tls.c
@@ -273,7 +273,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
g_test_init(&argc, &argv, NULL);
- setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+ g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
mkdir(WORKDIR, 0700);
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 1e5be1d..8f184f3 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1325,7 +1325,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
- setenv("QTEST_SILENT_ERRORS", "1", 1);
+ g_setenv("QTEST_SILENT_ERRORS", "1", 1);
g_test_init(&argc, &argv, NULL);
g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
diff --git a/ui/sdl2.c b/ui/sdl2.c
index bd4e736..9030f1c 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -772,7 +772,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
* This is a bit hackish but saves us from bigger problem.
* Maybe it's a good idea to fix this in SDL instead.
*/
- setenv("SDL_VIDEODRIVER", "x11", 0);
+ g_setenv("SDL_VIDEODRIVER", "x11", 0);
#endif
if (SDL_Init(SDL_INIT_VIDEO)) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] glib: use portable g_setenv()
2019-12-11 14:23 [PATCH] glib: use portable g_setenv() Paolo Bonzini
@ 2019-12-11 19:32 ` Thomas Huth
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2019-12-11 19:32 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial, Marc-André Lureau
On 11/12/2019 15.23, Paolo Bonzini wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> We have a setenv() wrapper in os-win32.c that no one is actually using.
> Drop it and change to g_setenv() uniformly.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> include/sysemu/os-win32.h | 2 --
> os-win32.c | 22 ----------------------
> tests/libqtest.c | 2 +-
> tests/test-crypto-tlscredsx509.c | 2 +-
> tests/test-crypto-tlssession.c | 2 +-
> tests/test-io-channel-tls.c | 2 +-
> tests/test-vmstate.c | 2 +-
> ui/sdl2.c | 2 +-
> 8 files changed, 6 insertions(+), 30 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-11 19:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 14:23 [PATCH] glib: use portable g_setenv() Paolo Bonzini
2019-12-11 19:32 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).