module: Simplify module_load()

The file path is not used for error reporting, so we can free it
directly after use.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Andreas Färber 2014-07-15 16:04:25 +02:00 committed by Paolo Bonzini
parent f52b768782
commit f9e13f8fd8

View File

@ -202,18 +202,16 @@ static void module_load(module_init_type type)
for (i = 0; i < ARRAY_SIZE(dirs); i++) { for (i = 0; i < ARRAY_SIZE(dirs); i++) {
fname = g_strdup_printf("%s/%s%s", dirs[i], *mp, HOST_DSOSUF); fname = g_strdup_printf("%s/%s%s", dirs[i], *mp, HOST_DSOSUF);
ret = module_load_file(fname); ret = module_load_file(fname);
g_free(fname);
fname = NULL;
/* Try loading until loaded a module file */ /* Try loading until loaded a module file */
if (!ret) { if (!ret) {
break; break;
} }
g_free(fname);
fname = NULL;
} }
if (ret == -ENOENT) { if (ret == -ENOENT) {
fprintf(stderr, "Can't find module: %s\n", *mp); fprintf(stderr, "Can't find module: %s\n", *mp);
} }
g_free(fname);
} }
for (i = 0; i < ARRAY_SIZE(dirs); i++) { for (i = 0; i < ARRAY_SIZE(dirs); i++) {