From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4821BD4415B for ; Fri, 12 Dec 2025 09:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aNWWbtRHdCuSJhDLIWy0mZbp4FuZ58c4nbWjNON5XjY=; b=1DpzwEMBdvM5NMbKn9cwE3dlkv AxVcLr/qGVuBV6HcqxmtOCQ1gG//3JkEoOBBhpueG47fZD60lHa8jL8Y8b2iAsOPp6YOI/Pf6Wein 0eYG6KdNNKK3WW3yVaDl862mSv7tpCQXltPMFD/tV7KX0CROTGhhUtiU9ndwdGyqu/IfUhS+R68Ch 9/psvCx43WoCpbe73BcbUAycq125MQAIPhdVQ14SrTXYS98ZdgwPHC0n16WpDaWZeLbXaOb+jquPr sqr8f21YVR/Zye0oj9vManFOqLvL1jnH0tl3wqOLrXgIpwjDT6Wda96AXwQhGf6eZEOf8sx2hymCz beJfkFHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTzS4-00000000Lul-16yu; Fri, 12 Dec 2025 09:28:40 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTzS1-00000000LuF-3a3N for linux-arm-kernel@lists.infradead.org; Fri, 12 Dec 2025 09:28:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 4BCCE417E1; Fri, 12 Dec 2025 09:28:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2462EC4CEF1; Fri, 12 Dec 2025 09:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765531716; bh=W0rU0ZoF6KH9m1aZIblf+y0H8Wfvx3C1oFibvVqu4v0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RotuDtiUo6aJuiOF1avUBU/UsoYG9796vH4RbeE/SUGdNbZbbhSWiTOrxZeuTwUGu DtVTfUt4Ug8l0YjTmDpC5yUjq+lIlucwd79j1J8aGjGaOzsKyf8FCxRkiqKDYm2ztM PqH3GAExY5DahWOFRiStK2fAFJthLKY19zhvwYK4FXLVtv9JLrBW6J+5RZoqmDHKvd o4/ci8WUb5pH9m7aAkwEBAFK8viEYDVm8m1Af+JRu+9lC7DTa4l+zYCaAUKN5flf6y c060QJWRAUIOUTmebE9mEKoP+TZxTmtL277Z+8zsyV3Dr5cy8kR8HZbnW7VlAURTrw Nf3gWN2JRBi/g== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vTzRx-0000000CCQb-3IyC; Fri, 12 Dec 2025 09:28:33 +0000 Date: Fri, 12 Dec 2025 09:28:33 +0000 Message-ID: <86qzt0nj5q.wl-maz@kernel.org> From: Marc Zyngier To: Osama Abdelkader Cc: Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: vgic: add default case to switch statement In-Reply-To: <20251211224033.18079-1-osama.abdelkader@gmail.com> References: <20251211224033.18079-1-osama.abdelkader@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: osama.abdelkader@gmail.com, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251212_012837_928726_8D0F13E1 X-CRM114-Status: GOOD ( 18.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 11 Dec 2025 22:40:28 +0000, Osama Abdelkader wrote: > > The switch statement in vgic_validate_injection() handles all enum > values for irq->config, but lacked a default case. Add one to match > the pattern used in other switch statements in the same file and make News flash: there is no other switch statement in this file. This is the only one. > the defensive return explicit. I'd suggest you read the code more carefully, and consider the following observations: enum vgic_irq_config { VGIC_CONFIG_EDGE = 0, VGIC_CONFIG_LEVEL }; struct vgic_irq { [...] enum vgic_irq_config config:1; /* Level or edge */ [...] }; With these two definitions in mind, let's revisit the function you are patching: static bool vgic_validate_injection(struct vgic_irq *irq, bool level, void *owner) { [...] switch (irq->config) { case VGIC_CONFIG_LEVEL: return irq->line_level != level; case VGIC_CONFIG_EDGE: return level; } return false; } Please explain how it is possible that the switch does not cover *exhaustively* all the possible values that are constraint to exactly One. Single. Bit? How adding a default case makes things better? The compiler already knows that we are covering all the possible values of the enum (yes, even a C compiler can achieve that), so it can *prove* that there is no need for a default. If anything, I'd have expected a patch dropping the last return, as it is remarkably pointless. But just moving it? What does it change? I'd suggest you think a bit more before posting random patches and wasting people's time. I spent a good 15 minutes writing this, which you could have used yourself to realise this change is pointless. Thanks, M. -- Without deviation from the norm, progress is not possible.