On 06.09.2017 23:00, Eric Blake wrote: > On 09/05/2017 04:36 AM, Thomas Huth wrote: >> On 01.09.2017 20:03, Eric Blake wrote: >>> When initializing a QPCIBus, track which QTestState the bus is >>> associated with (so that a later patch can then explicitly use >>> that test state for all communication on the bus, rather than >>> blindly relying on global_qtest). Update the initialization >>> functions to take another parameter, and update all callers to >>> pass in state (for now, most callers get away with passing the >>> current global_qtest as the current state, although this required >>> fixing the order of initialization to ensure qtest_start() is >>> called before qpci_init*() in rtl8139-test, and provided an >>> opportunity to pass in the allocator in e1000e-test). >>> >>> Signed-off-by: Eric Blake <ebl...@redhat.com> >>> --- >> [...] >>> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c >>> index 6226546c28..c95428e1cb 100644 >>> --- a/tests/libqos/libqos.c >>> +++ b/tests/libqos/libqos.c >>> @@ -26,8 +26,8 @@ QOSState *qtest_vboot(QOSOps *ops, const char >>> *cmdline_fmt, va_list ap) >>> if (ops->init_allocator) { >>> qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS); >>> } >>> - if (ops->qpci_init && qs->alloc) { >>> - qs->pcibus = ops->qpci_init(qs->alloc); >>> + if (ops->qpci_init) { >> >> Why did you remove the check for qs->alloc? >> >>> + qs->pcibus = ops->qpci_init(qs->qts, qs->alloc); > > Because we want to ensure qpci_init() is called to set qs->qts > (presumably, whether or not qs->alloc is set). Furthermore, only two > files declare a 'static QOSOps' structure in the first place > (libqos-pc.c and libqos-spapr.c); where both files set both the > .init_allocator and .qpci_init callbacks; a little bit of auditing shows > that the .init_allocator() never returns NULL (although that requires > browsing yet more files for malloc-{pc,spapr}.c).
OK, thanks for the explanation! ... but maybe we should g_assert(gs->alloc) somewhere instead? ... just an idea, I'm also fine if you leave it away. Thomas
signature.asc
Description: OpenPGP digital signature