File 0062-module-Simplify-module_load.patch of Package qemu.6354

From 754fe22ac19657f2567e78417bfc6fc49f1d1e29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
Date: Fri, 20 Jun 2014 16:46:50 +0200
Subject: [PATCH] module: Simplify module_load()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry-picked from commit f9e13f8fd87710063f9fa0feaf7de0348b32612a)
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 util/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/util/module.c b/util/module.c
index 214effb39f..9fd30309ae 100644
--- a/util/module.c
+++ b/util/module.c
@@ -202,18 +202,16 @@ static void module_load(module_init_type type)
         for (i = 0; i < ARRAY_SIZE(dirs); i++) {
             fname = g_strdup_printf("%s/%s%s", dirs[i], *mp, HOST_DSOSUF);
             ret = module_load_file(fname);
+            g_free(fname);
+            fname = NULL;
             /* Try loading until loaded a module file */
             if (!ret) {
                 break;
             }
-            g_free(fname);
-            fname = NULL;
         }
         if (ret == -ENOENT) {
             fprintf(stderr, "Can't find module: %s\n", *mp);
         }
-
-        g_free(fname);
     }
 
     for (i = 0; i < ARRAY_SIZE(dirs); i++) {
openSUSE Build Service is sponsored by