From nobody Tue Feb 10 10:19:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1667247443652451.6932663042388; Mon, 31 Oct 2022 13:17:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opbBw-0007e9-A4; Mon, 31 Oct 2022 16:15:28 -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 1opbBu-0007dE-Kf; Mon, 31 Oct 2022 16:15:26 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opbBs-0000jW-Ve; Mon, 31 Oct 2022 16:15:26 -0400 Received: from [2a00:23c4:8ba8:7100:6571:576d:97b8:647b] (helo=kentang.home) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opbBn-0003Dd-Do; Mon, 31 Oct 2022 20:15:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UHqiYzuk1mAmwGDYyXBPOqWTR/rY54X3mLbfuba1quE=; b=a/IFh3pfoGk76kbDl2w5ZOmLxf xJh4SxhQN7eK5FdNMHD0W0aTL85gUFYqsxB6hYS+MbitbFQTaAf3lWb6pN6w0auKdc3cyjiN9h4Bg eP7k/lx9LyZQuxT5oPIHBxAx3yilfjp41M9fhzgoond193qRGeVyM773CZTiaQCzmsZ19foNavJaR df07sCUD1fAp17O3b1yn9dBT4Wvg2V0ODzkvKITKrPMTPdegdGgi5xh0s49EU3qmY/d4+FE0hjRTu ICDqBkIvowNgSFA4s/RtoRaMemr8zcBubqhgwb5e0vLhmS4n7tDa1JLtykxQaXOyCYZd8w/4NZsFo j9tJojg7wZ9q8QQKeY+ewJ1qMrcmIGY/f68wceHRD8yNg8HX0FoodPts9ovD83BjtthRZCLDf93Vl 6HMTzqS6IZDrUF6qT02QU/vyqeeSIEbMGX/Q/daiDte3iyXD7ABd19zYV4k1RZbUwLhWe4nG7IiRF Dh1aD7bbGbdBmcI9Oj6jmJ3+CShkapBs7QSCncjCzzPe7IaGfRXH+U+E1DAUDPGKFruSbHzUxdFZ3 PJ6gV/k4lru1DEGxZBiAUNqye6dJl9IjeKoUwNeGSgOwwm2Xv9S/7/yjbxQ0qn5Q+gxmJaFOSF4DX J25wu68dnmp8nH9w7uWn7Y6O4kQL/O6D7nnrkfa9Q=; From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, stefanha@redhat.com Date: Mon, 31 Oct 2022 20:14:25 +0000 Message-Id: <20221031201435.677168-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221031201435.677168-1-mark.cave-ayland@ilande.co.uk> References: <20221031201435.677168-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba8:7100:6571:576d:97b8:647b X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 04/14] mac_{old|new}world: Avoid else branch by setting default value X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1667247445816100006 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Several variables are set in if-else branches where the else branch can be removed by setting a default value at the variable declaration which leads to simlpler code that is easier to follow. Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland Message-Id: <8dac3515b29976a61dacda07752175d7531dca3c.1666957578.git.balato= n@eik.bme.hu> Signed-off-by: Mark Cave-Ayland --- hw/ppc/mac_newworld.c | 19 ++++--------------- hw/ppc/mac_oldworld.c | 18 ++++-------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 6327694f85..6bc3bd19be 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -111,11 +111,11 @@ static void ppc_core99_init(MachineState *machine) CPUPPCState *env =3D NULL; char *filename; IrqLines *openpic_irqs; - int i, j, k, ppc_boot_device, machine_arch, bios_size; + int i, j, k, ppc_boot_device, machine_arch, bios_size =3D -1; const char *bios_name =3D machine->firmware ?: PROM_FILENAME; MemoryRegion *bios =3D g_new(MemoryRegion, 1); - hwaddr kernel_base, initrd_base, cmdline_base =3D 0; - long kernel_size, initrd_size; + hwaddr kernel_base =3D 0, initrd_base =3D 0, cmdline_base =3D 0; + long kernel_size =3D 0, initrd_size =3D 0; UNINHostState *uninorth_pci; PCIBus *pci_bus; PCIDevice *macio; @@ -165,8 +165,6 @@ static void ppc_core99_init(MachineState *machine) bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE); } g_free(filename); - } else { - bios_size =3D -1; } if (bios_size < 0 || bios_size > PROM_SIZE) { error_report("could not load PowerPC bios '%s'", bios_name); @@ -174,15 +172,12 @@ static void ppc_core99_init(MachineState *machine) } =20 if (machine->kernel_filename) { - int bswap_needed; + int bswap_needed =3D 0; =20 #ifdef BSWAP_NEEDED bswap_needed =3D 1; -#else - bswap_needed =3D 0; #endif kernel_base =3D KERNEL_LOAD_ADDR; - kernel_size =3D load_elf(machine->kernel_filename, NULL, translate_kernel_address, NULL, NULL, NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); @@ -212,16 +207,10 @@ static void ppc_core99_init(MachineState *machine) } cmdline_base =3D TARGET_PAGE_ALIGN(initrd_base + initrd_size); } else { - initrd_base =3D 0; - initrd_size =3D 0; cmdline_base =3D TARGET_PAGE_ALIGN(kernel_base + kernel_size += KERNEL_GAP); } ppc_boot_device =3D 'm'; } else { - kernel_base =3D 0; - kernel_size =3D 0; - initrd_base =3D 0; - initrd_size =3D 0; ppc_boot_device =3D '\0'; /* We consider that NewWorld PowerMac never have any floppy drive * For now, OHW cannot boot from the network. diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 5cabc410e7..cb67e44081 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -84,11 +84,11 @@ static void ppc_heathrow_init(MachineState *machine) PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; char *filename; - int i, bios_size; + int i, bios_size =3D -1; MemoryRegion *bios =3D g_new(MemoryRegion, 1); uint64_t bios_addr; - uint32_t kernel_base, initrd_base, cmdline_base =3D 0; - int32_t kernel_size, initrd_size; + uint32_t kernel_base =3D 0, initrd_base =3D 0, cmdline_base =3D 0; + int32_t kernel_size =3D 0, initrd_size =3D 0; PCIBus *pci_bus; PCIDevice *macio; MACIOIDEState *macio_ide; @@ -139,8 +139,6 @@ static void ppc_heathrow_init(MachineState *machine) bios_addr =3D PROM_BASE; } g_free(filename); - } else { - bios_size =3D -1; } if (bios_size < 0 || bios_addr - PROM_BASE + bios_size > PROM_SIZE) { error_report("could not load PowerPC bios '%s'", bios_name); @@ -148,12 +146,10 @@ static void ppc_heathrow_init(MachineState *machine) } =20 if (machine->kernel_filename) { - int bswap_needed; + int bswap_needed =3D 0; =20 #ifdef BSWAP_NEEDED bswap_needed =3D 1; -#else - bswap_needed =3D 0; #endif kernel_base =3D KERNEL_LOAD_ADDR; kernel_size =3D load_elf(machine->kernel_filename, NULL, @@ -186,16 +182,10 @@ static void ppc_heathrow_init(MachineState *machine) } cmdline_base =3D TARGET_PAGE_ALIGN(initrd_base + initrd_size); } else { - initrd_base =3D 0; - initrd_size =3D 0; cmdline_base =3D TARGET_PAGE_ALIGN(kernel_base + kernel_size += KERNEL_GAP); } ppc_boot_device =3D 'm'; } else { - kernel_base =3D 0; - kernel_size =3D 0; - initrd_base =3D 0; - initrd_size =3D 0; ppc_boot_device =3D '\0'; for (i =3D 0; machine->boot_config.order[i] !=3D '\0'; i++) { /* --=20 2.30.2