public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyich@gmail.com>
To: James Morse <james.morse@arm.com>
Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
	matoro <matoro_mailinglist_kernel@matoro.tk>,
	"Émeric Maschino" <emeric.maschino@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH] ia64: Fix build error due to switch case label appearing next to declaration
Date: Tue, 17 Jan 2023 19:31:09 +0000	[thread overview]
Message-ID: <20230117193109.5650fd6f@nz> (raw)
In-Reply-To: <20230117151632.393836-1-james.morse@arm.com>

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

  parent reply	other threads:[~2023-01-17 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-01-18 11:44   ` James Morse
2023-01-18  0:02 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230117193109.5650fd6f@nz \
    --to=slyich@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=emeric.maschino@gmail.com \
    --cc=james.morse@arm.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matoro_mailinglist_kernel@matoro.tk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox