From a4c13869f95cb45d657cc1df3803f633221d4971 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 18 Aug 2020 12:11:02 +0200 Subject: 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 --- util/oslib-posix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'util/oslib-posix.c') 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) -- cgit 1.4.1