On Wed, 16 Sep 2020 at 07:28, P J P <ppan...@redhat.com> wrote:
> ===
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index de0fae10ab..0ccb991410 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -253,6 +253,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int
> irq_num, int change)
>      PCIBus *bus;
>      for (;;) {
>          bus = pci_get_bus(pci_dev);
> +        assert(bus);
>          irq_num = bus->map_irq(pci_dev, irq_num);
>          if (bus->set_irq)
>              break;
> ===
>
> This should be okay for now?

Generally we don't bother to assert() that pointers that shouldn't be NULL
really are NULL immediately before dereferencing them, because the
dereference provides an equally easy-to-debug crash to the assert,
and so the assert doesn't provide anything extra.
assert()ing that a pointer is non-NULL is more useful if it is done in a
place that identifies the problem at an earlier and easier-to-debug point
in execution rather than at a later point which is distantly removed from
the place where the bogus pointer was introduced.

thanks
-- PMM

Reply via email to