Re: [PATCH v2 08/11] driver core: fw_devlink: Make cycle detection more robust

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 27, 2023 at 11:34:28PM -0800, Saravana Kannan wrote:
> On Fri, Jan 27, 2023 at 1:43 AM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Thu, Jan 26, 2023 at 04:11:35PM -0800, Saravana Kannan wrote:

...

> Lol, you are the king of nit picks :)

Not always, only when it comes with something else.

...

> > > + * Return true if one or more cycles were found. Otherwise, return false.
> >
> > Return:
> 
> I'm following the rest of the function docs in this file.

Okay, it makes sense. We will need to address them all.

> > (you may run `kernel-doc -v ...` to see all warnings)
> 
> Hmmm I ran it on the patch file and it didn't give me anything useful.
> Running it on the whole file is just a lot of lines to dig through.

The function description missing Return section. Something like this
I can get from the kernel doc without it.

...

> > > +static bool __fw_devlink_relax_cycles(struct device *con,
> > > +                              struct fwnode_handle *sup_handle)
> > > +{
> > > +     struct fwnode_link *link;
> > > +     struct device_link *dev_link;
> >
> > > +     struct device *sup_dev = NULL, *par_dev = NULL;
> >
> > You can put it the first line since it's long enough.
> 
> Wait, is that a style guideline to have the longer lines first?

No, but it's easier to read.

> > But why do you need sup_dev assignment?
> 
> Defensive programming I suppose. I can see this function being
> refactored in the future where a goto out; is inserted before sup_dev
> is assigned. And then the put_device(sup_dev) at "out" will end up
> operating on some junk value and causing memory corruption.

We don't need to be defensive here. Moreover, it's harder and easy to make
a mistake with predefined values (it's actually better NOT to define anything
qr at least define as closest to its user as possible, so you want miss the
compiler warnings as I believe you run your compiler with `make W=1 ...`, and
if not, I highly recommend to get this habit).

...

> > > +     sup_dev = get_dev_from_fwnode(sup_handle);
> > > +
> >
> > I would put it closer to the condition:
> >
> > > +     /* Termination condition. */
> > > +     if (sup_dev == con) {
> >
> >         /* Get supplier device and check for termination condition */
> >         sup_dev = get_dev_from_fwnode(sup_handle);
> >         if (sup_dev == con) {
> 
> I put it the way it is because sup_dev is used for more than just
> checking for termination condition.

Yes, but still it's better to see what you are actually checking.

> > > +             ret = true;
> > > +             goto out;
> > > +     }

...

> > > +             if (__fw_devlink_relax_cycles(con,
> > > +                                           dev_link->supplier->fwnode)) {
> >
> > Keep it on one line.
> 
> It'll make it > 80. Is this some recent change about allowing > 80
> cols? I'm leaving it as is for now.

Is it a problem? Do you have any tool that complains about it?

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux