From patchwork Mon Jul 2 18:06:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 168623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E194D2C0081 for ; Tue, 3 Jul 2012 04:06:42 +1000 (EST) Received: from localhost ([::1]:44650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll1E-0001YV-Gj for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2012 14:06:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll0q-000199-BE for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sll0k-0001rM-47 for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:06:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll0j-0001qS-S1 for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:06:10 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q62I5pTO013477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Jul 2012 14:05:51 -0400 Received: from blackpad.lan.raisama.net (vpn1-4-141.gru2.redhat.com [10.97.4.141]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q62I5oTW027731; Mon, 2 Jul 2012 14:05:51 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 829B62004BA; Mon, 2 Jul 2012 15:06:40 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2012 15:06:34 -0300 Message-Id: <1341252398-12268-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1341252398-12268-1-git-send-email-ehabkost@redhat.com> References: <1341252398-12268-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Andrea Arcangeli , Andre Przywara , kvm@vger.kernel.org, Blue Swirl , Bharata B Rao , Bill Gray Subject: [Qemu-devel] [PATCH 2/6] file_ram_alloc(): use g_strdup_printf() instead of asprintf() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Cc: Blue Swirl Signed-off-by: Eduardo Habkost Acked-by: Blue Swirl --- exec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exec.c b/exec.c index c8bfd27..d856325 100644 --- a/exec.c +++ b/exec.c @@ -24,6 +24,9 @@ #include #endif +#include +#include + #include "qemu-common.h" #include "cpu.h" #include "tcg.h" @@ -2357,7 +2360,7 @@ static void *file_ram_alloc(RAMBlock *block, ram_addr_t memory, const char *path) { - char *filename; + gchar *filename; void *area; int fd; #ifdef MAP_POPULATE @@ -2379,18 +2382,15 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } - if (asprintf(&filename, "%s/qemu_back_mem.XXXXXX", path) == -1) { - return NULL; - } - + filename = g_strdup_printf("%s/qemu_back_mem.XXXXXX", path); fd = mkstemp(filename); if (fd < 0) { perror("unable to create backing store for hugepages"); - free(filename); + g_free(filename); return NULL; } unlink(filename); - free(filename); + g_free(filename); memory = (memory + hpagesize - 1) & ~(hpagesize - 1);