From patchwork Wed May 8 17:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 795509 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:34e:ceec:bfcd with SMTP id k28csp904685wrc; Wed, 8 May 2024 10:50:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBbX8pbGFo/fch9bu8Sx0qEksZnIKz3LfQWJ2IWLe818H+QW+ap8xb0n0lMMfbWQnots26pJNnKXJclnhRosfl X-Google-Smtp-Source: AGHT+IGhSfLO5zv5ZkT69YXjVWNrRb/s3iSP0mRa95/ebcGiD1tS78Zri2Is/e0pBtrnW+AeTXit X-Received: by 2002:a9d:6416:0:b0:6f0:2819:7d23 with SMTP id 46e09a7af769-6f0b7831ccfmr3200908a34.3.1715190644687; Wed, 08 May 2024 10:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715190644; cv=none; d=google.com; s=arc-20160816; b=XmdXpucQsgJVNMiaLrUknf1p9c1xGDwLHvQ+yB9xV/fMgYN9pWbucx+K0eMg3qw2zZ e5+VxXDfiFui1oCfkhcY2GpZ6QdFAYPm4krbQ2Zr/ppi7UDmhGDN4YoyoHWIJ8yxhkcq aThhEYEyh48MpxF6kdt9Gh8j/VeNyJh2nTKCf8eCWHfHT+txAWAQzYQee1JfQ5NgFflp XUPvud7D8kB+MIZ9D/KD3CzRCxPD+1FM0Ywi4vIxbIs2WPcTzOpbW5WztYV8t6rPrdIG vQYNmjPGVMrcurmPL8nACD3B2nWp7AxyLJ6sjG7Y5XeLLfdU8rWV4Ymg9AXY0wtxOwz1 qW2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qcFeebFaXd8v0A/qKGNyCc1bIKWkAGLVbbLNEb4Qok8=; fh=pGYVoKmEbmBJXedzdvuKSuqi1EMwZm5z032l2+Fj52I=; b=D3cGmnUapE/Eet+uhwMVfBFKrLw+IdRju2s7Aw13utcoleXIHcCXJoGHZpLiC0aM9g AYprcRSruILzib6GyCOteSMD6tPc/DM6eYXk1hsy1Rbb9pZcp1b0M8rVQVpaKFSpVwdQ zea5lUjYDJc/RDzs4Tmde2Ytl2pdppEbpw1GW3BcX0m8fFGNeS8wygk9q1Dk/ZpqyE03 wljsRNs3MaU6IwDsxQdBjOQu9NKOD8cXFjSZy1Jqfyy9F5qMF6zAbLI7GMDb2p55H8XV m0qWzbS7ICzwW2rto/7V+xh+VRIwKQJ6dcCKfvYNpqTwo84HrzVyz1ZdSKCCv74thDRB ZSSQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZUlr0Xb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id vr1-20020a05620a55a100b007929fe7bb5bsi5742340qkn.65.2024.05.08.10.50.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2024 10:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZUlr0Xb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4lNN-0001UB-Sj; Wed, 08 May 2024 13:46:45 -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 1s4lN1-0000db-Bh for qemu-devel@nongnu.org; Wed, 08 May 2024 13:46:30 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4lMz-0007kB-P6 for qemu-devel@nongnu.org; Wed, 08 May 2024 13:46:23 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a599eedc8eeso60266b.1 for ; Wed, 08 May 2024 10:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715190379; x=1715795179; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qcFeebFaXd8v0A/qKGNyCc1bIKWkAGLVbbLNEb4Qok8=; b=JZUlr0XbKLoRRKT34Ci96HeWztKchZEGAh07qntfN0VGjKQpgY68n9lzpwiWNeouI0 wFwj6qbfzVVPKkKM5RFcmQqyqJ08w4M+aXYtxsC0vmULVN6FJ4gftZTmS/u++AH4tNCO mQCJIGdKqbk22vhLAWwxkG25X1ydpFw07KuJLm1fJowvO5e9u8adimJ/7AdJrp4Zbb5U c7oLmqeulh/lyt6c0WpHGWJNvoeKOkyyxhvRg0SZiVD+ZQCPd5UB+E27Yw46P6B4egPE kKU+5wlNHxNnCY4TQguvlmjVNtPJIi974MAEQqeMJr5cjyo82WFpVMX6UMv6wSjdeYye ed3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715190379; x=1715795179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qcFeebFaXd8v0A/qKGNyCc1bIKWkAGLVbbLNEb4Qok8=; b=PbWXG/sGFIm671v0qjtC9gPUZsdaZFXbtEV2t7zYtWSA2ASjwtpxtWqHv3P9mVyoeb MCX5MVxkvKFh+QdHHCS64eQ8WawZPBO9cWq4q1sXdF2regJTiC3BLOx0tPG+N2U9BUW4 KfidyHwd4bFKj5UaXjvOAqHtFlwP4GIMQoSXrevJjEhyyky02AUFkGgNo31iDCVmwS2D IDlhGU75qwcGem/3LY3Zm6gZAvJunCRtcK7I22Nj/wvkz76HlBjrmYoXo0yMfFrKbeQ6 dViolCAcUHnzH3auDK4ZPAkv24m9d7ZI68F142lRfbuWnb7UHU/kU7f8w6z7ddEaAI76 iGOA== X-Gm-Message-State: AOJu0YyfGiQfo+SmBcrZvw8GL0pVRsybMRhh+gYiuwzxt8FyNel+ISJe 9b8fomH9SxcKNSkioa8RElz8XyTBupN8UgQ9Aqk0cmOXji3aaYYDC15NGFkR5/7QJNILx7yf3fC I X-Received: by 2002:a17:906:61a:b0:a59:9ef3:f6df with SMTP id a640c23a62f3a-a59fb941d7bmr183102766b.22.1715190378732; Wed, 08 May 2024 10:46:18 -0700 (PDT) Received: from m1x-phil.lan (sar95-h02-176-184-10-250.dsl.sta.abo.bbox.fr. [176.184.10.250]) by smtp.gmail.com with ESMTPSA id z3-20020a170906270300b00a55bb18e3d7sm7763243ejc.168.2024.05.08.10.46.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 May 2024 10:46:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init() Date: Wed, 8 May 2024 19:44:56 +0200 Message-ID: <20240508174510.60470-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240508174510.60470-1-philmd@linaro.org> References: <20240508174510.60470-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=philmd@linaro.org; helo=mail-ej1-x630.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Bernhard Beschow Given that memory_region_set_readonly() is a no-op when the readonlyness is already as requested it is possible to simplify the pattern if (condition) { foo(true); } to foo(condition); which is shorter and allows to see the invariant of the code more easily. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240430150643.111976-2-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/x86.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 3d5b51e92d..2a4f3ee285 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1163,9 +1163,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware, load_image_size(filename, ptr, bios_size); x86_firmware_configure(ptr, bios_size); } else { - if (!isapc_ram_fw) { - memory_region_set_readonly(bios, true); - } + memory_region_set_readonly(bios, !isapc_ram_fw); ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret != 0) { goto bios_error; @@ -1182,9 +1180,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware, 0x100000 - isa_bios_size, isa_bios, 1); - if (!isapc_ram_fw) { - memory_region_set_readonly(isa_bios, true); - } + memory_region_set_readonly(isa_bios, !isapc_ram_fw); /* map all the bios at the top of memory */ memory_region_add_subregion(rom_memory,