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: 1147561 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C1940DFFAD for ; Mon, 2 Jul 2012 18:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932358Ab2GBSGQ (ORCPT ); Mon, 2 Jul 2012 14:06:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932336Ab2GBSGN (ORCPT ); Mon, 2 Jul 2012 14:06:13 -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 Cc: kvm@vger.kernel.org, Bill Gray , Andrea Arcangeli , Bharata B Rao , Andre Przywara , Blue Swirl Subject: [PATCH 2/6] file_ram_alloc(): use g_strdup_printf() instead of asprintf() 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);