Re: [PATCH] sparc: time: Use pointer from memcpy() call for assignment in setup_sparc64_timer()
From: Geert Uytterhoeven
Date: Fri Oct 31 2025 - 06:08:53 EST
Hi Markus,
On Fri, 31 Oct 2025 at 09:46, Markus Elfring <Markus.Elfring@xxxxxx> wrote:
> …>> +++ b/arch/sparc/kernel/time_64.c
> >> @@ -760,9 +760,7 @@ void setup_sparc64_timer(void)
> >> : /* no outputs */
> >> : "r" (pstate));
> >>
> >> - sevt = this_cpu_ptr(&sparc64_events);
> >> -
> >> - memcpy(sevt, &sparc64_clockevent, sizeof(*sevt));
> >> + sevt = memcpy(this_cpu_ptr(&sparc64_events), &sparc64_clockevent, sizeof(*sevt));
> >
> > IMHO this makes the code harder to read:
> > - Only 0.15% of the memcpy() calls in the kernel use the
> > memcpy() chaining feature,
It is also less clear the passed size matches the destination pointer.
> I obviously propose to refactor this implementation detail.
Oh no...
<other-bad-ideas>
The above function could be shortened by writing
(sevt = memcpy(this_cpu_ptr(&sparc64_events), &sparc64_clockevent,
sizeof(*sevt)))->cpumask = cpumask_of(smp_processor_id());
And after introducing a variant of clockevents_register_device() that
takes the cpumask as a parameter:
clockevents_register_device_with_cpumask(memcpy(this_cpu_ptr(&sparc64_events),
&sparc64_clockevent, sizeof(*sevt)), cpumask_of(smp_processor_id()));
</other-bad-ideas>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds