Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1446810pxu; Sat, 24 Oct 2020 10:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwKtVUm+ahoFBAFBRlASaDGztcvcM4JaKCBaK06XpDGtWbKX1bGULtXhs5vEIh5hJ78nAm X-Received: by 2002:a17:906:bb14:: with SMTP id jz20mr8011809ejb.424.1603562272900; Sat, 24 Oct 2020 10:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603562272; cv=none; d=google.com; s=arc-20160816; b=RCc6iUtAMk5QioChbZEpZw+bC60MtcH20M2Qe0WQlewfEtm9tCrFWIJdSfa1tQCJmx yUbMRhKerKRlQqfIou8j2SV/oPRI59mM6ZB9IED/cN9lpeJ86Nt+VbmQvcwN1GSzeXRY JSJoJlmF7X/E875329w8IOm/KLwfM2Pguv+3kwxiiOjPSyFEeFrjO5/jiZDNfA6T2uLW JLFGVgWvopkANq5+0XZnADrIwZ4k4oNiAv6Qw1SFT1iVxBibxeKG4Nqd9iwCL1cY6uwd RkPonh+1aLRx/HaMcoXhSpqVybq+fchujIpduCDOuDWQ7fIEGZ5wbihJLruoMISjVWIZ jtjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Ytj07sUDZzInu/q9PdSVj247Wsc1QFn/oDugQqX237M=; b=Dcl2tCLsbK2H4Iaf3Hq02N9ge1xZCkTl3CpEK/Nngm+m+l5FW0/jZ/noDVqzaYeijb dul1m633ycgRbUd6RADlnDsJe7bESKHWwx9KUtLEiWhpRkURMbzpLqSZjfkhjwtvX37f C9blvwCmXnKt0mVyoTnJGsIv95PA3H3lfsMM2ODAI7876ydpC2ZQ+igtSSgIARGSo79i RNmPEfNz4F19Ch/VYgqjbclfCjiE15VnDxVrX3w6Yiy6Q1Fpq11V/UzajaPxHlYG/ehM MOphZ7YutdFxyPHJ2CKBDijq8JkUnd/l+3LFKXUByxiRp4mT1V705OVfJpxpvAw1CsLR nj+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si3440213ejh.287.2020.10.24.10.57.30; Sat, 24 Oct 2020 10:57:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762530AbgJXRPE (ORCPT + 99 others); Sat, 24 Oct 2020 13:15:04 -0400 Received: from asavdk3.altibox.net ([109.247.116.14]:46594 "EHLO asavdk3.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762526AbgJXRPD (ORCPT ); Sat, 24 Oct 2020 13:15:03 -0400 Received: from ravnborg.org (unknown [188.228.123.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 539B820020; Sat, 24 Oct 2020 19:14:59 +0200 (CEST) Date: Sat, 24 Oct 2020 19:14:57 +0200 From: Sam Ravnborg To: Bernard Cc: Thomas Zimmermann , opensource.kernel@vivo.com, David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Airlie Subject: Re: Re: [PATCH] gpu/drm/mgag200:remove break after return Message-ID: <20201024171457.GA76883@ravnborg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=S433PrkP c=1 sm=1 tr=0 a=S6zTFyMACwkrwXSdXUNehg==:117 a=S6zTFyMACwkrwXSdXUNehg==:17 a=kj9zAlcOel0A:10 a=1WtWmnkvAAAA:8 a=20KFwNOVAAAA:8 a=VwQbUJbxAAAA:8 a=24COTcmDj64ZDdr2WTQA:9 a=CjuIK1q_8ugA:10 a=-_UHfarfsM-RsASml2Jt:22 a=AjGcO6oz07-iQ99wixmX:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bernard. On Fri, Oct 23, 2020 at 03:48:49PM +0800, Bernard wrote: > > > From: Thomas Zimmermann > Date: 2020-10-23 15:13:30 > To: Bernard Zhao ,Dave Airlie ,David Airlie ,Daniel Vetter ,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org > Cc: opensource.kernel@vivo.com > Subject: Re: [PATCH] gpu/drm/mgag200:remove break after return>Hi > > > >On 23.10.20 09:00, Bernard Zhao wrote: > >> In function mgag200_set_pci_regs, there are some switch cases > >> returned, then break. These break will never run. > >> This patch is to make the code a bit readable. > >> > >> Signed-off-by: Bernard Zhao > >> --- > >> drivers/gpu/drm/mgag200/mgag200_mode.c | 5 +---- > >> 1 file changed, 1 insertion(+), 4 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c > >> index 38672f9e5c4f..de873a5d276e 100644 > >> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c > >> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c > >> @@ -794,20 +794,17 @@ static int mgag200_crtc_set_plls(struct mga_device *mdev, long clock) > >> case G200_SE_A: > >> case G200_SE_B: > >> return mga_g200se_set_plls(mdev, clock); > >> - break; > >> case G200_WB: > >> case G200_EW3: > >> return mga_g200wb_set_plls(mdev, clock); > >> - break; > >> case G200_EV: > >> return mga_g200ev_set_plls(mdev, clock); > >> - break; > >> case G200_EH: > >> case G200_EH3: > >> return mga_g200eh_set_plls(mdev, clock); > >> - break; > >> case G200_ER: > >> return mga_g200er_set_plls(mdev, clock); > >> + default: > > > >No default case here. If one of the enum values is not handled by the > >switch, the compiler should warn about it. > > Hi > > For this point I was a little confused, about this switch variable "mdev->type", my understanding is that this variable`s value can be certain only when the code is running. > How does the compiler warn this("If one of the enum values is not handled") before the code runs? If the switch/case does not include "G200_ER" then the compiler can see one enum value is missing from the list and can warn. As a test - Try to drop the default and drop G200_ER - then the compiler (hopefully) will warn. Sam