mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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:
parent
05512f55aa
commit
a4c13869f9
7 changed files with 20 additions and 27 deletions
|
@ -172,7 +172,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
|
|||
|
||||
#ifdef CONFIG_MODULES
|
||||
char *fname = NULL;
|
||||
char *exec_dir;
|
||||
#ifdef CONFIG_MODULE_UPGRADES
|
||||
char *version_dir;
|
||||
#endif
|
||||
|
@ -199,13 +198,12 @@ bool module_load_one(const char *prefix, const char *lib_name)
|
|||
return true;
|
||||
}
|
||||
|
||||
exec_dir = qemu_get_exec_dir();
|
||||
search_dir = getenv("QEMU_MODULE_DIR");
|
||||
if (search_dir != NULL) {
|
||||
dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
|
||||
}
|
||||
dirs[n_dirs++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
|
||||
dirs[n_dirs++] = g_strdup_printf("%s", exec_dir ? : "");
|
||||
dirs[n_dirs++] = g_strdup(qemu_get_exec_dir());
|
||||
|
||||
#ifdef CONFIG_MODULE_UPGRADES
|
||||
version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION),
|
||||
|
@ -216,9 +214,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
|
|||
|
||||
assert(n_dirs <= ARRAY_SIZE(dirs));
|
||||
|
||||
g_free(exec_dir);
|
||||
exec_dir = NULL;
|
||||
|
||||
for (i = 0; i < n_dirs; i++) {
|
||||
fname = g_strdup_printf("%s/%s%s",
|
||||
dirs[i], module_name, CONFIG_HOST_DSOSUF);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue