[PATCH] usb: ehci: initialize ehci_data
Alexander Aring
alex.aring at gmail.com
Mon Mar 4 14:32:20 EST 2013
On Mon, Mar 04, 2013 at 08:28:35PM +0100, Sascha Hauer wrote:
> On Mon, Mar 04, 2013 at 08:25:49PM +0100, Alexander Aring wrote:
> > On Mon, Mar 04, 2013 at 08:16:17PM +0100, Sascha Hauer wrote:
> > > On Mon, Mar 04, 2013 at 08:05:29PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 17:00 Mon 04 Mar , Sascha Hauer wrote:
> > > > > Without it fields of ehci_data may be unitialized and the driver
> > > > > crashes.
> > > > >
> > > > > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > > > > ---
> > > > > drivers/usb/host/ehci-hcd.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> > > > > index 0c789e4..7c389aa 100644
> > > > > --- a/drivers/usb/host/ehci-hcd.c
> > > > > +++ b/drivers/usb/host/ehci-hcd.c
> > > > > @@ -892,7 +892,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data)
> > > > >
> > > > > static int ehci_probe(struct device_d *dev)
> > > > > {
> > > > > - struct ehci_data data;
> > > > > + struct ehci_data data = {};
> > > >
> > > > I'll prefer a memset
> > >
> > > Then you'll happy to hear that this is what the compiler makes from it
> > > anyway.
> > >
> > I think memset use a unnecessary function call. Is that right?
>
> No, the result will be the same. As said, gcc will call memset anyway,
> even when you implicitly initialize a struct with '= {}'.
>
Ok, thanks for this information.
Alex
More information about the barebox
mailing list