oslib: do not call g_strdup from qemu_get_exec_dir

Just return the directory without requiring the caller to free it.
This also removes a bogus check for NULL in os_find_datadir and
module_load_one; g_strdup of a static variable cannot return NULL.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2020-08-18 12:11:02 +02:00
parent 05512f55aa
commit a4c13869f9
7 changed files with 20 additions and 27 deletions

View file

@ -366,7 +366,9 @@ void qemu_init_exec_dir(const char *argv0)
char *p = NULL;
char buf[PATH_MAX];
assert(!exec_dir[0]);
if (exec_dir[0]) {
return;
}
#if defined(__linux__)
{
@ -439,9 +441,9 @@ void qemu_init_exec_dir(const char *argv0)
g_free(dir);
}
char *qemu_get_exec_dir(void)
const char *qemu_get_exec_dir(void)
{
return g_strdup(exec_dir);
return exec_dir;
}
static void sigbus_handler(int signal)