aboutsummaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-08-18 12:11:02 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-09-30 19:11:36 +0200
commita4c13869f95cb45d657cc1df3803f633221d4971 (patch)
tree8ebf036c107ff7aad647eb31d070fafe7115bb82 /util/oslib-posix.c
parent05512f55aaca92505b75d8fa6818b088a5eeb07f (diff)
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>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index f5f676f079..18531fc859 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -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)