2022-01-24 04:33:26

by Iwashima, Kuniyuki

[permalink] [raw]
Subject: [PATCH] openrisc/boot: Remove unnecessary initialisation in memcpy().

'd' and 's' are initialised later with 'dest_w' and 'src_w', so we need not
initialise them before that.

Signed-off-by: Kuniyuki Iwashima <[email protected]>
---
arch/openrisc/lib/memcpy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/openrisc/lib/memcpy.c b/arch/openrisc/lib/memcpy.c
index fe2177628..e2af9b510 100644
--- a/arch/openrisc/lib/memcpy.c
+++ b/arch/openrisc/lib/memcpy.c
@@ -101,7 +101,7 @@ void *memcpy(void *dest, __const void *src, __kernel_size_t n)
*/
void *memcpy(void *dest, __const void *src, __kernel_size_t n)
{
- unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
+ unsigned char *d, *s;
uint32_t *dest_w = (uint32_t *)dest, *src_w = (uint32_t *)src;

/* If both source and dest are word aligned copy words */
--
2.30.2


2022-01-24 14:31:24

by Stafford Horne

[permalink] [raw]
Subject: Re: [PATCH] openrisc/boot: Remove unnecessary initialisation in memcpy().

On Sun, Jan 23, 2022 at 11:01:00AM +0900, Kuniyuki Iwashima wrote:
> 'd' and 's' are initialised later with 'dest_w' and 'src_w', so we need not
> initialise them before that.
>
> Signed-off-by: Kuniyuki Iwashima <[email protected]>

This looks fine to me. I will queue this for the next release.

Just curious why are you working on OpenRISC?

-Stafford

> ---
> arch/openrisc/lib/memcpy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/openrisc/lib/memcpy.c b/arch/openrisc/lib/memcpy.c
> index fe2177628..e2af9b510 100644
> --- a/arch/openrisc/lib/memcpy.c
> +++ b/arch/openrisc/lib/memcpy.c
> @@ -101,7 +101,7 @@ void *memcpy(void *dest, __const void *src, __kernel_size_t n)
> */
> void *memcpy(void *dest, __const void *src, __kernel_size_t n)
> {
> - unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
> + unsigned char *d, *s;
> uint32_t *dest_w = (uint32_t *)dest, *src_w = (uint32_t *)src;
>
> /* If both source and dest are word aligned copy words */
> --
> 2.30.2
>

2022-01-24 15:03:37

by Iwashima, Kuniyuki

[permalink] [raw]
Subject: Re: [PATCH] openrisc/boot: Remove unnecessary initialisation in memcpy().

From: Stafford Horne <[email protected]>
Date: Mon, 24 Jan 2022 08:27:54 +0900
> On Sun, Jan 23, 2022 at 11:01:00AM +0900, Kuniyuki Iwashima wrote:
> > 'd' and 's' are initialised later with 'dest_w' and 'src_w', so we need not
> > initialise them before that.
> >
> > Signed-off-by: Kuniyuki Iwashima <[email protected]>
>
> This looks fine to me. I will queue this for the next release.

Thank you.


>
> Just curious why are you working on OpenRISC?

While reading memcpy() variants, I found a nit to fix in x86 boot-time
memcpy() [0]. While I'm at it, I just started reading all arch ones ;)

[0]: https://lore.kernel.org/lkml/[email protected]/


>
> -Stafford
>
> > ---
> > arch/openrisc/lib/memcpy.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/openrisc/lib/memcpy.c b/arch/openrisc/lib/memcpy.c
> > index fe2177628..e2af9b510 100644
> > --- a/arch/openrisc/lib/memcpy.c
> > +++ b/arch/openrisc/lib/memcpy.c
> > @@ -101,7 +101,7 @@ void *memcpy(void *dest, __const void *src, __kernel_size_t n)
> > */
> > void *memcpy(void *dest, __const void *src, __kernel_size_t n)
> > {
> > - unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
> > + unsigned char *d, *s;
> > uint32_t *dest_w = (uint32_t *)dest, *src_w = (uint32_t *)src;
> >
> > /* If both source and dest are word aligned copy words */
> > --
> > 2.30.2

2022-01-24 15:04:18

by Stafford Horne

[permalink] [raw]
Subject: Re: [PATCH] openrisc/boot: Remove unnecessary initialisation in memcpy().

On Mon, Jan 24, 2022 at 09:02:49AM +0900, Kuniyuki Iwashima wrote:
> From: Stafford Horne <[email protected]>
> Date: Mon, 24 Jan 2022 08:27:54 +0900
> > On Sun, Jan 23, 2022 at 11:01:00AM +0900, Kuniyuki Iwashima wrote:
> > > 'd' and 's' are initialised later with 'dest_w' and 'src_w', so we need not
> > > initialise them before that.
> > >
> > > Signed-off-by: Kuniyuki Iwashima <[email protected]>
> >
> > This looks fine to me. I will queue this for the next release.
>
> Thank you.
>
>
> >
> > Just curious why are you working on OpenRISC?
>
> While reading memcpy() variants, I found a nit to fix in x86 boot-time
> memcpy() [0]. While I'm at it, I just started reading all arch ones ;)
>
> [0]: https://lore.kernel.org/lkml/[email protected]/

Got it.

Thanks again!