From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC5492D94AA; Fri, 12 Dec 2025 09:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765531716; cv=none; b=HC1oMvd1u2zRHSa0XFS30GrIeeeVEIAXwF9jsHdjS0treMfoAYznzImCB5gldr+mwdfRDa3uFiWJ4UOuDlqRbPYFV6YQX4VfXMvuVHg8axO76iZADEWQx++xjVzlW4uzuC7dfNxCQFSOycVCNpBoJrbzRvUfV9J28Sq5/v18okQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765531716; c=relaxed/simple; bh=W0rU0ZoF6KH9m1aZIblf+y0H8Wfvx3C1oFibvVqu4v0=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=hhc08gOVLB8Sjr+jYqI8t3BFPp4ZmZS6YTIElxlVJYT6Sb9hlZjYHfgnFFA+ok9XcDLQRbCajbXXjHLSye1HKIx9PcYH8wy4ndAc90DIfb9CZo58d9i+KYBvihwRJ0VphO7ZHgXXfz+XxiiyvRVgdtYsfU4wsRwQOD0H4xW9TZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RotuDtiU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RotuDtiU" 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) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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 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.