From nobody Mon Nov 25 02:28:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717666666; cv=none; d=zohomail.com; s=zohoarc; b=T+0MFPTpojUKjys6lVkQXSJUL9RCtOtU6nXEyIBPnKH0IVgt6Creax8i1Ez28RSDnyIKLH42wxb4AgEGUyv9M9/A2REUb7fvB5jp73ldaDJS36AiUShqahuZWzY/c5myaxta9Wi/AFq18Hr2AglefObIyaxmJi75e+66+2Bgd5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717666666; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+GCbTdM0GZ7BVxsKLSoCw+rPoe+MChxl2looUyeu6OM=; b=ckfaDGkxsP+RII36EPmyHPE6+FphUTbqpLTqqCZgew12aMlVKl1loa5zV5yK9e/DvNxfCdNLzUEqj7yEwq/1qLWtLEUYGX/grUV//CNROszCOdELbgrb/FINVWO/JGMKGNYBDzSdDh0g2sbilVcxezDlY97mxdHYvzHyyjTNZY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717666666677768.6201787894712; Thu, 6 Jun 2024 02:37:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF9Yl-0001lu-UI; Thu, 06 Jun 2024 05:37:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF9Yj-0001lC-TY for qemu-devel@nongnu.org; Thu, 06 Jun 2024 05:37:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF9Yi-0007ZC-E5 for qemu-devel@nongnu.org; Thu, 06 Jun 2024 05:37:25 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-347-MwumC35ZP2iQGGxaK4CceQ-1; Thu, 06 Jun 2024 05:37:19 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a68e0faf0e6so37358166b.2 for ; Thu, 06 Jun 2024 02:37:18 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806ec893sm71265666b.140.2024.06.06.02.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 02:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717666643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+GCbTdM0GZ7BVxsKLSoCw+rPoe+MChxl2looUyeu6OM=; b=iMuuos96JChsnteUupfnDFVmMF9tNFvsOCr3Go328wRGGZ2K1+vHa2xQ3RKFoADq8u2C63 CxtLcgyVvRJclJPJ8nGrZo3DRgDd3AsdQzeWqxDHw9f4/gwUlPg7yu1QBQS8a9kouGazMb sV/EbMXm+YSYjRgTko1bh0QAa+HzXS0= X-MC-Unique: MwumC35ZP2iQGGxaK4CceQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717666637; x=1718271437; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+GCbTdM0GZ7BVxsKLSoCw+rPoe+MChxl2looUyeu6OM=; b=uABiQz6R6OGeqGLuZ6PnsAPVCB/eyxpZxnreUvzTkaaoV3etzaI78nTrNLSq44IY4W RpLPLXmlvG6Dw1wdiBYae4GOd1CU27p8xkA6lIFZf7IcBM4ltrJvOo+mdiofRw1csMuC ezp8qTUY9aombknJzlGhLQ6xvHVpXR/UJsY8MLZIaVvGgDHjUN4/1m+tY6cjdNf6OSc/ GFpOV5QCSgUmn2RguWAJ6pik4qD4Qku9/mHmlj8gjfaurltcddR4J3xVD3875ykzpvo9 VDoGpIh4zJj2jej1BLP4lsFqxlG0SNjdapdIHvQyQyj83AdpFK8YCtCsfob2bnmo5MJC bL1Q== X-Gm-Message-State: AOJu0YyuS+1wZX4wuStSofPwDR9BNiUfsdSnyAmAGIl1OVFB2/+VRUVL wNlNTwWKU/YE6X6cRQaxZPcIayDiDqgNzGAOyXp6Tc0sXWCFf300r2YdiHRmMu+qFaeShvQCstK 09lu6DO3IFez+lgvDKxuwIAkic4quAk8xhAem2aVb4JLV7lPK13K+G3KXxzl8o8KvZ/dnkKEM6C uBDfsejJQX8MTvbyHZANCzzlhZwUceNDXCXmWP X-Received: by 2002:a17:906:fccf:b0:a64:e418:f93f with SMTP id a640c23a62f3a-a69a024ce23mr291021366b.60.1717666636731; Thu, 06 Jun 2024 02:37:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwj1ooVpHb7MZruSuxRO0F2MU0kBdsGAEZK1kz3tEDUYrykgPVZW/UNb/XhO89GwBUG5vHsQ== X-Received: by 2002:a17:906:fccf:b0:a64:e418:f93f with SMTP id a640c23a62f3a-a69a024ce23mr291019666b.60.1717666636187; Thu, 06 Jun 2024 02:37:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: mprivozn@redhat.com Subject: [PATCH] hostmem: simplify the code Date: Thu, 6 Jun 2024 11:37:13 +0200 Message-ID: <20240606093713.2469676-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717666667727100001 Content-Type: text/plain; charset="utf-8" No semantic change, just simpler control flow. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- backends/hostmem.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 37be93c8bb3..33baca6a974 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -178,12 +178,8 @@ static void host_memory_backend_set_merge(Object *obj,= bool value, Error **errp) return; } =20 - if (!host_memory_backend_mr_inited(backend)) { - backend->merge =3D value; - return; - } - - if (value !=3D backend->merge) { + if (!host_memory_backend_mr_inited(backend) && + value !=3D backend->merge) { void *ptr =3D memory_region_get_ram_ptr(&backend->mr); uint64_t sz =3D memory_region_size(&backend->mr); =20 @@ -194,9 +190,9 @@ static void host_memory_backend_set_merge(Object *obj, = bool value, Error **errp) object_get_typename(obj)); return; } - - backend->merge =3D value; } + + backend->merge =3D value; } =20 static bool host_memory_backend_get_dump(Object *obj, Error **errp) @@ -218,12 +214,8 @@ static void host_memory_backend_set_dump(Object *obj, = bool value, Error **errp) return; } =20 - if (!host_memory_backend_mr_inited(backend)) { - backend->dump =3D value; - return; - } - - if (value !=3D backend->dump) { + if (host_memory_backend_mr_inited(backend) && + value !=3D backend->dump) { void *ptr =3D memory_region_get_ram_ptr(&backend->mr); uint64_t sz =3D memory_region_size(&backend->mr); =20 @@ -234,9 +226,9 @@ static void host_memory_backend_set_dump(Object *obj, b= ool value, Error **errp) object_get_typename(obj)); return; } - - backend->dump =3D value; } + + backend->dump =3D value; } =20 static bool host_memory_backend_get_prealloc(Object *obj, Error **errp) --=20 2.45.1