On Thu, Sep 03, 2020 at 06:35:34PM +0300, Andy Shevchenko wrote:
> On Thu, Sep 3, 2020 at 6:23 PM Willem de Bruijn
> <willemdebruijn.ker...@gmail.com> wrote:
> > On Wed, Sep 2, 2020 at 5:37 PM Vadym Kochan <vadym.koc...@plvision.eu> 
> > wrote:
> 
> ...
> 
> > > +static int prestera_is_valid_mac_addr(struct prestera_port *port, u8 
> > > *addr)
> > > +{
> > > +       if (!is_valid_ether_addr(addr))
> > > +               return -EADDRNOTAVAIL;
> > > +
> > > +       if (memcmp(port->sw->base_mac, addr, ETH_ALEN - 1))
> >
> > Why ETH_ALEN - 1?
> 
> We even have a lot of helpers specifically for ethernet MACs.
> Starting from [1] till almost the end of the file. Here [2] can be
> used (or its unaligned counterpart).
> 
> [1]: 
> https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L67
> [2]: 
> https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L67
> 
> > > +               return -EINVAL;
> > > +
> > > +       return 0;
> > > +}
> 
> > > +       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
> >
> > Is addr_len ever not ETH_ALEN for this device?
> 
> And if it is ETH_ALEN, here is [3].
> [3]: 
> https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L287

Thanks Andy, I missed this one to replace with ether_addr_copy().

> 
> -- 
> With Best Regards,
> Andy Shevchenko

Reply via email to