From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH] usb: renesas_usbhs: Use struct assignment instead of memcpy()
Date: Tue, 18 Jun 2019 08:42:48 +0000 [thread overview]
Message-ID: <OSBPR01MB3590AB7F4A5F1C68DE7B0C93D8EA0@OSBPR01MB3590.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20190618055915.GA5904@kroah.com>
Hi Greg,
> From: Greg KH, Sent: Tuesday, June 18, 2019 2:59 PM
>
> On Thu, Jun 13, 2019 at 08:18:48PM +0900, Yoshihiro Shimoda wrote:
> > To avoid the error-proneness of calls to sizeof() in the memcpy,
> > this patch uses struct assignment instead of memcpy.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> > This patch is based on Greg's linux-usb.git / usb-next branch.
> > Note that mod_host.c also has memcpy but we cannot use struct assignment
> > for it because the type of urb->setup_patcket is just "unsigned char *".
> >
> > drivers/usb/renesas_usbhs/common.c | 13 ++++---------
> > 1 file changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
> > index a501ea6..ebbe322 100644
> > --- a/drivers/usb/renesas_usbhs/common.c
> > +++ b/drivers/usb/renesas_usbhs/common.c
> > @@ -651,9 +651,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
> > return NULL;
> >
> > dparam = &info->driver_param;
> > - memcpy(dparam, &data->param, sizeof(data->param));
> > - memcpy(&info->platform_callback, data->platform_callback,
> > - sizeof(*data->platform_callback));
> > + *dparam = data->param;
> > + info->platform_callback = *data->platform_callback;
>
> How are the original calls here "error-prone"?
When I was developing the patch above [1], I had actually confused
about these arguments of memcpy...
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/drivers/usb/renesas_usbhs?h=usb-next&id=be21a02a5a5ec88b12ce535ead715d4bbb173a55
I think this is because object and pointer members are mixed in these structures.
So, as I mentioned on the following email [2], I should try to simplify the code
instead of this patch.
[2]
https://marc.info/?l=linux-usb&m=155748940717665&w=2
> So are you _sure_ you want this change?
I'm sorry, I would like to drop this patch.
Best regards,
Yoshihiro Shimoda
> thanks,
>
> greg k-h
prev parent reply other threads:[~2019-06-18 8:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 11:18 [PATCH] usb: renesas_usbhs: Use struct assignment instead of memcpy() Yoshihiro Shimoda
2019-06-17 8:40 ` Simon Horman
2019-06-18 5:59 ` Greg KH
2019-06-18 7:26 ` Geert Uytterhoeven
2019-06-18 8:42 ` Yoshihiro Shimoda [this message]
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=OSBPR01MB3590AB7F4A5F1C68DE7B0C93D8EA0@OSBPR01MB3590.jpnprd01.prod.outlook.com \
--to=yoshihiro.shimoda.uh@renesas.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).