Re: [PATCH v6 04/12] PCI: Make pciehp_is_native() stricter

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

 



On Thu, May 24, 2018 at 09:31:07PM +0300, Mika Westerberg wrote:
> On Thu, May 24, 2018 at 01:08:37PM -0500, Bjorn Helgaas wrote:
> > Why do we even need to bother checking "bridge" for NULL?
> > 
> > I don't believe in gratuitously checking for NULL because it can hide
> > higher-level bugs, i.e., if this is called with a NULL pointer, that's
> > likely a bug in the caller, and if we silently return "false", we'll
> > never discover the caller's bug.
> 
> But it also makes caller's life easier because now you don't need to do
> this:
> 
>    if (bus->self && hotplug_is_native(bus->self))
> 
> because it is perfectly legal to call that function for host bridge. So
> you do this instead
> 
>    if (hotplug_is_native(bus->self))
> 
> and it is not hiding a bug IMHO.

True, it's not hiding a bug, but I think it is useful for readers of
acpiphp_add_context() to see the NULL check there and realize that
bus->self (or "pdev" in current upstream) is allowed to be NULL.  That
helps understand the way acpiphp works (well, I understand very little
of it, but every little clue helps).



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux