From patchwork Mon Jul 18 09:27:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 649417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rtHtt4d3zz9s3s for ; Mon, 18 Jul 2016 19:29:26 +1000 (AEST) Received: from localhost ([::1]:45379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP4rc-0005W5-CQ for incoming@patchwork.ozlabs.org; Mon, 18 Jul 2016 05:29:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP4qH-0003NZ-1N for qemu-devel@nongnu.org; Mon, 18 Jul 2016 05:28:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP4qG-0006VE-1y for qemu-devel@nongnu.org; Mon, 18 Jul 2016 05:28:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP4qF-0006V8-Sb for qemu-devel@nongnu.org; Mon, 18 Jul 2016 05:27:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EE1A63E0B; Mon, 18 Jul 2016 09:27:59 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6I9RuIu025611; Mon, 18 Jul 2016 05:27:58 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 18 Jul 2016 11:27:33 +0200 Message-Id: <1468834075-25669-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1468834075-25669-1-git-send-email-pbonzini@redhat.com> References: <1468834075-25669-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Jul 2016 09:27:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/23] use g_path_get_dirname instead of dirname X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Jiangang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Jiangang 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 Message-Id: <1459997185-15669-3-git-send-email-weijg.fnst@cn.fujitsu.com> Signed-off-by: Paolo Bonzini --- os-posix.c | 3 ++- util/oslib-posix.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/os-posix.c b/os-posix.c index 3755265..c6ddb7d 100644 --- a/os-posix.c +++ b/os-posix.c @@ -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; } diff --git a/util/oslib-posix.c b/util/oslib-posix.c index d8e5dcf..6d70d9a 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -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)