Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1E6BC2D0A3 for ; Sat, 24 Oct 2020 17:15:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A051208E4 for ; Sat, 24 Oct 2020 17:15:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A051208E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28EF96E8F8; Sat, 24 Oct 2020 17:15:04 +0000 (UTC) Received: from asavdk3.altibox.net (asavdk3.altibox.net [109.247.116.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 482B56E8F8 for ; Sat, 24 Oct 2020 17:15:02 +0000 (UTC) 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 Subject: Re: Re: [PATCH] gpu/drm/mgag200:remove break after return Message-ID: <20201024171457.GA76883@ravnborg.org> References: MIME-Version: 1.0 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: opensource.kernel@vivo.com, David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Dave Airlie Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel