Message ID | 20221027195238.1789586-1-nathan@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp427004wru; Thu, 27 Oct 2022 12:54:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PomQsYrowNigf1zy5q1Sfj2n7ITMeQh25OAbQ5PhcyaZ9btwGundoSdLmaMjKNpWpkW+P X-Received: by 2002:a05:6402:1d86:b0:457:e84:f0e with SMTP id dk6-20020a0564021d8600b004570e840f0emr46952744edb.241.1666900473390; Thu, 27 Oct 2022 12:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666900473; cv=none; d=google.com; s=arc-20160816; b=EZwxYUhDxnQdbsyG3sgC5cVtMCRNY2GtFKP0LZBxJk86yCiiHeloiQzTc16k1ad2t1 2W6FPVg3N+lyhxVuaATnCyEV5iHQz4g8/Tk39Icw4y4//rr1xhktakzeLQXwi9wBjC6f NF27y6qTkoNR9Pexd3yX9Q4uPsjPjaL1dRNBbt7pef/QuC2uxXzqbPBWQhgBWKxYCLcM YWrMl/FgMtSIaCaF156qQbPW22Wbuq0HMpFW3zcFonLVXo9NK2w+3Ui5ND+By0F3a3Uo D5/BItotq1tjzRD/UJvaIGqFbOF9JfuD89LCqgu8phJDyC5dkDzBiCoF/9o77rNxXqCp MmiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KRtI9GuQ6PTGVpNqeb+df3N+5lKMG/yG+eRcjuiQKMI=; b=0bE/p1KzN9XFPfilotl5gElUMeCNWFB+LP6HQsIsC4YPPGY2rhTTG1Z++d6eU5RlHX JS7i3oMMnG5sa/7A1c9w0rNg8jEi54jcqYj2UGJYU1hhbjMQHSfWX0Vv9N0VAg4rqpD5 NrLukDzwY/0ajKpmD2qJ/aiW7gbumDQ1wvwToq5Io/12QhsUHqVabps/LMz44q9tHJEV gJCqanSu9bBEQowf3hx8H1nRdDbUtLcjxRISIT0XQjT8xfTVIS0Bx/NVT7dz1+EhdiKb iyrdgEVkiJJp3xfVia+/2gVb98/+BwogSl/Ov8Ud/CvBkE8tFCytfdFqlk/A/q5rpCYZ G17g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="cVO/GHMP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020a05640251cc00b0045d5cf18d4bsi2669106edd.583.2022.10.27.12.54.09; Thu, 27 Oct 2022 12:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="cVO/GHMP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236688AbiJ0Tw7 (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Thu, 27 Oct 2022 15:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236017AbiJ0Tw5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Oct 2022 15:52:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C5E885A83; Thu, 27 Oct 2022 12:52:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AC730624C8; Thu, 27 Oct 2022 19:52:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DB6CC433D6; Thu, 27 Oct 2022 19:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666900376; bh=35cFf88kblVuwSgahftZiRQRYQbkqp7M3ibAvifLwnQ=; h=From:To:Cc:Subject:Date:From; b=cVO/GHMPGprH3caldUb141wNEv7znCzlhkzwQLKHBqih2wnXFR+D+D4eKDbHATdLz dmzTEtzhKzDBiwuSVaqPaLx4W3HZDODH1ekvGQww03b4+ZekZP8rwtzymg44UuGrbk k9BmDtzXMNTrFDsSC6MRQMCITRguw3Syjmr41rSesBwO+pmfRHjasHfZ6stfA3gXvT 6HSyNo+uWu692nnxZbv2iD4nCJ5cEKdADcZP7sVyh8ydAnvLdOonHcztKU7HGfoziK AUxnGf/++G+ioNTD1on1w7LF0ddmyYdoJNLlpOMAHGizjtEGmS3nOUkS8gBnM0S8Ji HOhhsfsmrbYzg== From: Nathan Chancellor <nathan@kernel.org> To: Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net> Cc: Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Quan Nguyen <quan@os.amperecomputing.com>, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor <nathan@kernel.org> Subject: [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible() Date: Thu, 27 Oct 2022 12:52:38 -0700 Message-Id: <20221027195238.1789586-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747871830973947856?= X-GMAIL-MSGID: =?utf-8?q?1747871830973947856?= |
Series |
[-next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible()
|
|
Commit Message
Nathan Chancellor
Oct. 27, 2022, 7:52 p.m. UTC
Clang warns:
drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
default:
^
drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
default:
^
break;
1 error generated.
Clang is a little more pedantic than GCC, which does not warn when
falling through to a case that is just break or return. Clang's version
is more in line with the kernel's own stance in deprecated.rst, which
states that all switch/case blocks must end in either break,
fallthrough, continue, goto, or return. Add the missing break to silence
the warning.
Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
Link: https://github.com/ClangBuiltLinux/linux/issues/1751
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/hwmon/smpro-hwmon.c | 1 +
1 file changed, 1 insertion(+)
base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
Comments
On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote: > Clang warns: > > drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] > default: > ^ > drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through > default: > ^ > break; > 1 error generated. > > Clang is a little more pedantic than GCC, which does not warn when > falling through to a case that is just break or return. Clang's version > is more in line with the kernel's own stance in deprecated.rst, which > states that all switch/case blocks must end in either break, > fallthrough, continue, goto, or return. Add the missing break to silence > the warning. > > Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver") > Link: https://github.com/ClangBuiltLinux/linux/issues/1751 > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > --- > drivers/hwmon/smpro-hwmon.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c > index ee54e21c2c12..667e88b6bae5 100644 > --- a/drivers/hwmon/smpro-hwmon.c > +++ b/drivers/hwmon/smpro-hwmon.c > @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, > return 0; > break; > } > + break; The alignment of the break; statement above is also bad, and a default: for switch (attr) is missing. Guenter > default: > break; > } > > base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182 > -- > 2.38.1 >
On Thu, Oct 27, 2022 at 02:00:16PM -0700, Guenter Roeck wrote: > On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote: > > Clang warns: > > > > drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] > > default: > > ^ > > drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through > > default: > > ^ > > break; > > 1 error generated. > > > > Clang is a little more pedantic than GCC, which does not warn when > > falling through to a case that is just break or return. Clang's version > > is more in line with the kernel's own stance in deprecated.rst, which > > states that all switch/case blocks must end in either break, > > fallthrough, continue, goto, or return. Add the missing break to silence > > the warning. > > > > Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver") > > Link: https://github.com/ClangBuiltLinux/linux/issues/1751 > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > --- > > drivers/hwmon/smpro-hwmon.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c > > index ee54e21c2c12..667e88b6bae5 100644 > > --- a/drivers/hwmon/smpro-hwmon.c > > +++ b/drivers/hwmon/smpro-hwmon.c > > @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, > > return 0; > > break; > > } > > + break; > > The alignment of the break; statement above is also bad, and a default: > for switch (attr) is missing. Would you prefer those fixed in the same patch or a separate one? > > default: > > break; > > } > > > > base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182 > > -- > > 2.38.1 > >
On Thu, Oct 27, 2022 at 02:03:56PM -0700, Nathan Chancellor wrote: > On Thu, Oct 27, 2022 at 02:00:16PM -0700, Guenter Roeck wrote: > > On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote: > > > Clang warns: > > > > > > drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] > > > default: > > > ^ > > > drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through > > > default: > > > ^ > > > break; > > > 1 error generated. > > > > > > Clang is a little more pedantic than GCC, which does not warn when > > > falling through to a case that is just break or return. Clang's version > > > is more in line with the kernel's own stance in deprecated.rst, which > > > states that all switch/case blocks must end in either break, > > > fallthrough, continue, goto, or return. Add the missing break to silence > > > the warning. > > > > > > Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver") > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1751 > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > > --- > > > drivers/hwmon/smpro-hwmon.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c > > > index ee54e21c2c12..667e88b6bae5 100644 > > > --- a/drivers/hwmon/smpro-hwmon.c > > > +++ b/drivers/hwmon/smpro-hwmon.c > > > @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, > > > return 0; > > > break; > > > } > > > + break; > > > > The alignment of the break; statement above is also bad, and a default: > > for switch (attr) is missing. > > Would you prefer those fixed in the same patch or a separate one? > Same patch, please. The resulting code is ultimately the same. Thanks, Guenter > > > default: > > > break; > > > } > > > > > > base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182 > > > -- > > > 2.38.1 > > >
diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c index ee54e21c2c12..667e88b6bae5 100644 --- a/drivers/hwmon/smpro-hwmon.c +++ b/drivers/hwmon/smpro-hwmon.c @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, return 0; break; } + break; default: break; }