mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-10-03 01:34:41 +00:00
glib: use portable g_setenv()
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> Message-Id: <1576074210-52834-7-git-send-email-pbonzini@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
e858e04dd4
commit
e468ffdc6d
|
@ -67,8 +67,6 @@ int getpagesize(void);
|
||||||
# define EPROTONOSUPPORT EINVAL
|
# define EPROTONOSUPPORT EINVAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int setenv(const char *name, const char *value, int overwrite);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long tv_sec;
|
long tv_sec;
|
||||||
long tv_usec;
|
long tv_usec;
|
||||||
|
|
22
os-win32.c
22
os-win32.c
|
@ -30,28 +30,6 @@
|
||||||
#include "qemu-options.h"
|
#include "qemu-options.h"
|
||||||
#include "sysemu/runstate.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)
|
static BOOL WINAPI qemu_ctrl_handler(DWORD type)
|
||||||
{
|
{
|
||||||
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_SIGNAL);
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_SIGNAL);
|
||||||
|
|
|
@ -254,7 +254,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
|
||||||
s->expected_status = 0;
|
s->expected_status = 0;
|
||||||
s->qemu_pid = fork();
|
s->qemu_pid = fork();
|
||||||
if (s->qemu_pid == 0) {
|
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);
|
execlp("/bin/sh", "sh", "-c", command, NULL);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
module_call_init(MODULE_INIT_QOM);
|
module_call_init(MODULE_INIT_QOM);
|
||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
mkdir(WORKDIR, 0700);
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
module_call_init(MODULE_INIT_QOM);
|
module_call_init(MODULE_INIT_QOM);
|
||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
mkdir(WORKDIR, 0700);
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
module_call_init(MODULE_INIT_QOM);
|
module_call_init(MODULE_INIT_QOM);
|
||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
||||||
|
|
||||||
mkdir(WORKDIR, 0700);
|
mkdir(WORKDIR, 0700);
|
||||||
|
|
||||||
|
|
|
@ -1325,7 +1325,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
module_call_init(MODULE_INIT_QOM);
|
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_init(&argc, &argv, NULL);
|
||||||
g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
|
g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
|
||||||
|
|
|
@ -772,7 +772,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
|
||||||
* This is a bit hackish but saves us from bigger problem.
|
* This is a bit hackish but saves us from bigger problem.
|
||||||
* Maybe it's a good idea to fix this in SDL instead.
|
* Maybe it's a good idea to fix this in SDL instead.
|
||||||
*/
|
*/
|
||||||
setenv("SDL_VIDEODRIVER", "x11", 0);
|
g_setenv("SDL_VIDEODRIVER", "x11", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO)) {
|
if (SDL_Init(SDL_INIT_VIDEO)) {
|
||||||
|
|
Loading…
Reference in a new issue