* [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
@ 2023-01-17 15:16 James Morse
2023-01-17 15:44 ` John Paul Adrian Glaubitz
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: James Morse @ 2023-01-17 15:16 UTC (permalink / raw)
To: linux-ia64, linux-kernel
Cc: Sergei Trofimovich, matoro, Émeric Maschino, Andrew Morton,
James Morse
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);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
2023-01-17 15:16 [PATCH] ia64: Fix build error due to switch case label appearing next to declaration James Morse
@ 2023-01-17 15:44 ` John Paul Adrian Glaubitz
2023-01-17 19:31 ` Sergei Trofimovich
2023-01-18 0:02 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-01-17 15:44 UTC (permalink / raw)
To: James Morse, linux-ia64, linux-kernel
Cc: Sergei Trofimovich, matoro, Émeric Maschino, Andrew Morton
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
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
2023-01-17 15:16 [PATCH] ia64: Fix build error due to switch case label appearing next to declaration James Morse
2023-01-17 15:44 ` John Paul Adrian Glaubitz
@ 2023-01-17 19:31 ` Sergei Trofimovich
2023-01-18 11:44 ` James Morse
2023-01-18 0:02 ` Andrew Morton
2 siblings, 1 reply; 5+ messages in thread
From: Sergei Trofimovich @ 2023-01-17 19:31 UTC (permalink / raw)
To: James Morse
Cc: linux-ia64, linux-kernel, matoro, Émeric Maschino,
Andrew Morton
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
>
--
Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
2023-01-17 15:16 [PATCH] ia64: Fix build error due to switch case label appearing next to declaration James Morse
2023-01-17 15:44 ` John Paul Adrian Glaubitz
2023-01-17 19:31 ` Sergei Trofimovich
@ 2023-01-18 0:02 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2023-01-18 0:02 UTC (permalink / raw)
To: James Morse
Cc: linux-ia64, linux-kernel, Sergei Trofimovich, matoro,
Émeric Maschino
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
2023-01-17 19:31 ` Sergei Trofimovich
@ 2023-01-18 11:44 ` James Morse
0 siblings, 0 replies; 5+ messages in thread
From: James Morse @ 2023-01-18 11:44 UTC (permalink / raw)
To: Sergei Trofimovich
Cc: linux-ia64, linux-kernel, matoro, Émeric Maschino,
Andrew Morton
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-18 12:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 15:16 [PATCH] ia64: Fix build error due to switch case label appearing next to declaration James Morse
2023-01-17 15:44 ` John Paul Adrian Glaubitz
2023-01-17 19:31 ` Sergei Trofimovich
2023-01-18 11:44 ` James Morse
2023-01-18 0:02 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox