From nobody Sat Nov 8 06:03:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550061629313770.4236860568177; Wed, 13 Feb 2019 04:40:29 -0800 (PST) Received: from localhost ([127.0.0.1]:55896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gttpv-0007ok-5n for importer@patchew.org; Wed, 13 Feb 2019 07:40:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gttok-0007Aw-7j for qemu-devel@nongnu.org; Wed, 13 Feb 2019 07:39:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gttoj-0006V9-DB for qemu-devel@nongnu.org; Wed, 13 Feb 2019 07:39:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gttoj-0006Uf-84 for qemu-devel@nongnu.org; Wed, 13 Feb 2019 07:39:09 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 816932DDA5; Wed, 13 Feb 2019 12:39:08 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAFD15FCC7; Wed, 13 Feb 2019 12:39:02 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 13 Feb 2019 07:38:58 -0500 Message-Id: <20190213123858.24620-1-imammedo@redhat.com> In-Reply-To: <20190213071401.11544-1-stefanha@redhat.com> References: <20190213071401.11544-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Feb 2019 12:39:08 +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] [PATCH] hostmem: simplify ifdef-s in file_backend_memory_alloc() 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: Haozhong Zhang , Wei Yang , Eduardo Habkost , Stefan Hajnoczi , Zhang Yi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" cleanup file_backend_memory_alloc() by using one CONFIG_POSIX ifdef instead of several ones within the function to make it simpler to follow. Signed-off-by: Igor Mammedov Suggested-by: Wei Yang Reviewed-by: Wei Yang --- Cc: Haozhong Zhang Cc: Zhang Yi Cc: Eduardo Habkost Cc: Stefan Hajnoczi CC: Wei Yang --- backends/hostmem-file.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index ba601ce940..ce54788048 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -41,10 +41,12 @@ struct HostMemoryBackendFile { static void file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { +#ifndef CONFIG_POSIX + error_setg(errp, "backend '%s' not supported on this host", + object_get_typename(OBJECT(backend))); +#else HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(backend); -#ifdef CONFIG_POSIX gchar *name; -#endif =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -54,9 +56,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) error_setg(errp, "mem-path property not set"); return; } -#ifndef CONFIG_POSIX - error_setg(errp, "-mem-path not supported on this host"); -#else backend->force_prealloc =3D mem_prealloc; name =3D host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), --=20 2.18.1