Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp326412pxu; Fri, 23 Oct 2020 01:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSPA+Y9m0r+Xll4pdPX1WJ9WcfCC9JjxKMyFp5mxsN5pZdyB6E9kf23UWBomC00ymQhHc5 X-Received: by 2002:a17:907:b19:: with SMTP id h25mr962802ejl.368.1603442016495; Fri, 23 Oct 2020 01:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603442016; cv=none; d=google.com; s=arc-20160816; b=b5W+edI7S2mDOiHeN//W4sJfLPMMaUx+VVAW5iD3Y9a4VJn082rmA589ChOFJ9nsrW IhqKj5lsIMa/Etl5DIiFZwE/EtMNj7zIFaI4/RLhlPSXEJUQwhW1MruA43C/iYzs0txc wzsn4Ht6FiAxTHJ8lPLRTwrf+hy+ruzP2HnBTlgzUAp4TcsixZSaMnZ3IFBshYynf7R8 dQX+7k1skkcIx+u17v8DjWvsKGImuoiUfncJ2GmMTFesKnu4S9zxCT4WnTCRPiECgOlT zHFq4v43vo/tRr5fUp+aAZPLUePLWipJesIwDhf5dXSEI7d++m2fDLJNmjALWzKHaruU oGrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=UUURhzuOb1hrnkEYPPgvn6tPvqrbbQd7dICkkAVJfS0=; b=KPPmbc8pilAzPej2q4MpvJV1CIIQeD+ZWSEeEpwKKAMzMe6FbHctMa1NkoK26SGpts ksiiDLO5VNqbdxq7ZTnUykE6J+PIT8X5GICrdVnCDmZv3hEmtpIw1ZwKmdL2oGeer8bd EsbueJi3RTFHEjBcYRW/pKO3m3Y3icNJNF3fgbyK5kiEuo/UzFhTIAr6kZas/YjUqe7a 539uyCatdfGNpJiaPxo7qSGAWytVZ4IDK7TqjMk4tawDo6RxFmRacHgvuY1YJK3PW42V Q7zHJuMhEpKNlF452d7+uGUNOvozIM8Y9YEIVkYUgW8q7weoKyp8R9pFB21FSCzdIvhW Z8bg== 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 l12si346721edk.163.2020.10.23.01.33.13; Fri, 23 Oct 2020 01:33:36 -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 S460633AbgJWI3w (ORCPT + 99 others); Fri, 23 Oct 2020 04:29:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:38466 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S460475AbgJWI3v (ORCPT ); Fri, 23 Oct 2020 04:29:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5491AABF4; Fri, 23 Oct 2020 08:29:50 +0000 (UTC) Subject: Re: [PATCH] gpu/drm/mgag200:remove break after return To: Bernard Cc: Dave Airlie , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com References: From: Thomas Zimmermann Message-ID: <44e91fc5-275e-0cd3-b6cd-acc14621a9fd@suse.de> Date: Fri, 23 Oct 2020 10:29:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 23.10.20 09:48, 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? The enum mga_type {} has values (G200_ER, G200_WB, etc) that are known to the compiler. If one of those values does not show up in the switch statement, the compiler warns. Adding default would silence this warning. In principle, mdev->type could contain any value that fits into an int. But assigning anything that is not listed in enum mga_type {} is considered an error as well. Best regards Thomas > > BR//Bernard > >> Best regards >> Thomas >> >>> break; >>> } >>> >>> >> >> -- >> Thomas Zimmermann >> Graphics Driver Developer >> SUSE Software Solutions Germany GmbH >> Maxfeldstr. 5, 90409 Nürnberg, Germany >> (HRB 36809, AG Nürnberg) >> Geschäftsführer: Felix Imendörffer > > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer