]> git.proxmox.com Git - mirror_qemu.git/commitdiff
use g_path_get_dirname instead of dirname
authorWei Jiangang <weijg.fnst@cn.fujitsu.com>
Thu, 7 Apr 2016 02:46:24 +0000 (10:46 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 17 Jul 2016 07:59:21 +0000 (09:59 +0200)
Use g_path_get_basename to get the directory components of
a file name, and free its return when no longer needed.

Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Message-Id: <1459997185-15669-3-git-send-email-weijg.fnst@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
os-posix.c
util/oslib-posix.c

index 3755265582514fff6f820a651d808140bb53ba51..c6ddb7d830198929d2805d74b64336fae12def08 100644 (file)
@@ -89,7 +89,7 @@ char *os_find_datadir(void)
     if (exec_dir == NULL) {
         return NULL;
     }
-    dir = dirname(exec_dir);
+    dir = g_path_get_dirname(exec_dir);
 
     max_len = strlen(dir) +
         MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
@@ -103,6 +103,7 @@ char *os_find_datadir(void)
         }
     }
 
+    g_free(dir);
     g_free(exec_dir);
     return res;
 }
index d8e5dcfede36b0bd216c3d7a86bd487a562ca596..6d70d9a7068c33ab1d6649d991cdc4c1630f0b13 100644 (file)
@@ -299,9 +299,11 @@ void qemu_init_exec_dir(const char *argv0)
             return;
         }
     }
-    dir = dirname(p);
+    dir = g_path_get_dirname(p);
 
     pstrcpy(exec_dir, sizeof(exec_dir), dir);
+
+    g_free(dir);
 }
 
 char *qemu_get_exec_dir(void)