Message ID | 20230117151632.393836-1-james.morse@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1817721wrn; Tue, 17 Jan 2023 07:25:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXsPa9lAKgFdzfd7y/kg3Zm3ouvCPlkPBYAe2rfMsFvrhgRCTcyDErI7l2yy7hEf/8cYsfre X-Received: by 2002:a17:90a:b00e:b0:227:22a4:6174 with SMTP id x14-20020a17090ab00e00b0022722a46174mr3744461pjq.17.1673969138875; Tue, 17 Jan 2023 07:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673969138; cv=none; d=google.com; s=arc-20160816; b=HMOnJ0KaFiurmv5HwfV31khZPAGe8hJXDdHTxflnoFur7IGMk8W6Mu2LOGfz2G6Lqq wmw7Pk7Z5DuXAk2YH/bVwC32fhFk7zjVaL7suDebq+nSn8f6DOPNsDZiHviNKZLnEOu5 ULxD254ubeVmEFSh9UeBBourxSbpwBfRyJ3aNNcsptnNbJzJWbLqWamtlpyvfN7Jq4d5 xHbOZMaBG8wryv0sjfxsw0IWK6YzMuR/PrlaqBsa0oI/DgtEv10xdsKI7NuqHX/AZG82 4c1xi/dSbK14vGRm2S4ANzkGR4ZoAh8GLmBmiQWaCkjPrt3NMk+eyffVHH5vB6PrAUAu UxYg== 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; bh=bZE72bQbCdjzD4uvVhq2NRAlfFol59kn/mO7Ym26I80=; b=ZFVFDJ80WplX0dELkt9hW/v263LQtfLmjsmQHchPCUZhoVUXlUDzcT4uotPFr4FGuL HA/hD2WtSD0f/H9BGBy5tUWyoQ8yFSVe8tmdI2K525lKrFVeKArg5ZYv2zOfDitpu7ar gvEljbCvnZPPhcemVTCdzJhi2PFsQep6geEPa4O6qEjEXvV2NcJ+MzhHT0E/ZB5mE2kj f8BZ1wdahfGQ/3uEj+pFBIFBSmATGYNTj7pv+fA8jAyau7rnCfO3Mzc65ZXBUssTsTl4 kTHjTW/Za1HLZCj1nMZwBXIEu8rNaVo00mNrL+BoQ+p2GYu6cQUGku/VL4TpMCrt81TC 8+lw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx8-20020a17090b4b0800b002271de285easi26993170pjb.139.2023.01.17.07.25.23; Tue, 17 Jan 2023 07:25:38 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbjAQPQ5 (ORCPT <rfc822;pfffrao@gmail.com> + 99 others); Tue, 17 Jan 2023 10:16:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjAQPQx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Jan 2023 10:16:53 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64B7139CC1; Tue, 17 Jan 2023 07:16:52 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5C9B11FB; Tue, 17 Jan 2023 07:17:34 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 31C783F67D; Tue, 17 Jan 2023 07:16:51 -0800 (PST) From: James Morse <james.morse@arm.com> To: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sergei Trofimovich <slyich@gmail.com>, matoro <matoro_mailinglist_kernel@matoro.tk>, =?utf-8?q?=C3=89meric_Maschin?= =?utf-8?q?o?= <emeric.maschino@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, James Morse <james.morse@arm.com> Subject: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration Date: Tue, 17 Jan 2023 15:16:32 +0000 Message-Id: <20230117151632.393836-1-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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?1755283863848740953?= X-GMAIL-MSGID: =?utf-8?q?1755283863848740953?= |
Series |
ia64: Fix build error due to switch case label appearing next to declaration
|
|
Commit Message
James Morse
Jan. 17, 2023, 3:16 p.m. UTC
Since commit aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to
report ITC frequency"), gcc 10.1.0 fails to build ia64 with the gnomic:
| ../arch/ia64/kernel/sys_ia64.c: In function 'ia64_clock_getres':
| ../arch/ia64/kernel/sys_ia64.c:189:3: error: a label can only be part of a statement and a declaration is not a statement
| 189 | s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq);
This line appears immediately after a case label in a switch.
Move the declarations out of the case, to the top of the function.
Fixes: aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to report ITC frequency")
Signed-off-by: James Morse <james.morse@arm.com>
---
Found when build testing another series.
I've only build tested this.
arch/ia64/kernel/sys_ia64.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
Hi James! On 1/17/23 16:16, James Morse wrote: > Since commit aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to > report ITC frequency"), gcc 10.1.0 fails to build ia64 with the gnomic: > | ../arch/ia64/kernel/sys_ia64.c: In function 'ia64_clock_getres': > | ../arch/ia64/kernel/sys_ia64.c:189:3: error: a label can only be part of a statement and a declaration is not a statement > | 189 | s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > > This line appears immediately after a case label in a switch. > > Move the declarations out of the case, to the top of the function. > > Fixes: aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to report ITC frequency") > Signed-off-by: James Morse <james.morse@arm.com> > --- > Found when build testing another series. > I've only build tested this. > > arch/ia64/kernel/sys_ia64.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c > index f6a502e8f02c..6e948d015332 100644 > --- a/arch/ia64/kernel/sys_ia64.c > +++ b/arch/ia64/kernel/sys_ia64.c > @@ -170,6 +170,9 @@ ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, u > asmlinkage long > ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user *tp) > { > + struct timespec64 rtn_tp; > + s64 tick_ns; > + > /* > * ia64's clock_gettime() syscall is implemented as a vdso call > * fsys_clock_gettime(). Currently it handles only > @@ -185,8 +188,8 @@ ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user * > switch (which_clock) { > case CLOCK_REALTIME: > case CLOCK_MONOTONIC: > - s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > - struct timespec64 rtn_tp = ns_to_timespec64(tick_ns); > + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > + rtn_tp = ns_to_timespec64(tick_ns); > return put_timespec64(&rtn_tp, tp); > } > Thanks for the patch. I just gave it a try and it didn't make any difference for me. The kernel builds fine in both cases (with CONFIG_WERROR disabled) on 6e50979a9c87. I can boot-test the patch later tonight with my RX2600 at home. Adrian
On Tue, 17 Jan 2023 15:16:32 +0000 James Morse <james.morse@arm.com> wrote: > Since commit aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to > report ITC frequency"), gcc 10.1.0 fails to build ia64 with the gnomic: > | ../arch/ia64/kernel/sys_ia64.c: In function 'ia64_clock_getres': > | ../arch/ia64/kernel/sys_ia64.c:189:3: error: a label can only be part of a statement and a declaration is not a statement > | 189 | s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > > This line appears immediately after a case label in a switch. > > Move the declarations out of the case, to the top of the function. > > Fixes: aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to report ITC frequency") > Signed-off-by: James Morse <james.morse@arm.com> Out of curiosity what compiler version behaves like that? I think I and matoro build-/run-tested it on gcc-12 and maybe gcc-11. Thank you! Reviewed-by: Sergei Trofimovich <slyich@gmail.com> > --- > Found when build testing another series. > I've only build tested this. > > arch/ia64/kernel/sys_ia64.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c > index f6a502e8f02c..6e948d015332 100644 > --- a/arch/ia64/kernel/sys_ia64.c > +++ b/arch/ia64/kernel/sys_ia64.c > @@ -170,6 +170,9 @@ ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, u > asmlinkage long > ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user *tp) > { > + struct timespec64 rtn_tp; > + s64 tick_ns; > + > /* > * ia64's clock_gettime() syscall is implemented as a vdso call > * fsys_clock_gettime(). Currently it handles only > @@ -185,8 +188,8 @@ ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user * > switch (which_clock) { > case CLOCK_REALTIME: > case CLOCK_MONOTONIC: > - s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > - struct timespec64 rtn_tp = ns_to_timespec64(tick_ns); > + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > + rtn_tp = ns_to_timespec64(tick_ns); > return put_timespec64(&rtn_tp, tp); > } > > -- > 2.30.2 >
On Tue, 17 Jan 2023 15:16:32 +0000 James Morse <james.morse@arm.com> wrote: > Since commit aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to > report ITC frequency"), gcc 10.1.0 fails to build ia64 with the gnomic: > | ../arch/ia64/kernel/sys_ia64.c: In function 'ia64_clock_getres': > | ../arch/ia64/kernel/sys_ia64.c:189:3: error: a label can only be part of a statement and a declaration is not a statement > | 189 | s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > > ... > > @@ -185,8 +188,8 @@ ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user * > switch (which_clock) { > case CLOCK_REALTIME: > case CLOCK_MONOTONIC: > - s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > - struct timespec64 rtn_tp = ns_to_timespec64(tick_ns); > + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); > + rtn_tp = ns_to_timespec64(tick_ns); > return put_timespec64(&rtn_tp, tp); > } > Huh, how did that sneak through. We usually use an extra set of braces for this. Thanks, I'll add cc:stable to this.
Hi Sergei, On 17/01/2023 19:31, Sergei Trofimovich wrote: > On Tue, 17 Jan 2023 15:16:32 +0000 > James Morse <james.morse@arm.com> wrote: > >> Since commit aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to >> report ITC frequency"), gcc 10.1.0 fails to build ia64 with the gnomic: >> | ../arch/ia64/kernel/sys_ia64.c: In function 'ia64_clock_getres': >> | ../arch/ia64/kernel/sys_ia64.c:189:3: error: a label can only be part of a statement and a declaration is not a statement >> | 189 | s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); >> >> This line appears immediately after a case label in a switch. >> >> Move the declarations out of the case, to the top of the function. >> >> Fixes: aa06a9bd8533 ("ia64: fix clock_getres(CLOCK_MONOTONIC) to report ITC frequency") >> Signed-off-by: James Morse <james.morse@arm.com> > Out of curiosity what compiler version behaves like that? I think I and > matoro build-/run-tested it on gcc-12 and maybe gcc-11. | # ia64-linux-gcc --version | ia64-linux-gcc (GCC) 10.1.0 | Copyright (C) 2020 Free Software Foundation, Inc. | This is free software; see the source for copying conditions. There is NO | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The toolchain originally came from https://mirrors.edge.kernel.org/pub/tools/crosstool/ The really odd thing I'm doing is cross compiling for ia64 on arm64 ... but I wouldn't have thought the toolchain configuration was any different. > Thank you! > > Reviewed-by: Sergei Trofimovich <slyich@gmail.com> Thanks, James
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c index f6a502e8f02c..6e948d015332 100644 --- a/arch/ia64/kernel/sys_ia64.c +++ b/arch/ia64/kernel/sys_ia64.c @@ -170,6 +170,9 @@ ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, u asmlinkage long ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user *tp) { + struct timespec64 rtn_tp; + s64 tick_ns; + /* * ia64's clock_gettime() syscall is implemented as a vdso call * fsys_clock_gettime(). Currently it handles only @@ -185,8 +188,8 @@ ia64_clock_getres(const clockid_t which_clock, struct __kernel_timespec __user * switch (which_clock) { case CLOCK_REALTIME: case CLOCK_MONOTONIC: - s64 tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); - struct timespec64 rtn_tp = ns_to_timespec64(tick_ns); + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, local_cpu_data->itc_freq); + rtn_tp = ns_to_timespec64(tick_ns); return put_timespec64(&rtn_tp, tp); }