On Mon, 13 Jul 2026 at 19:47, Daniel P. Berrangé <[email protected]> wrote: > > On Mon, Jul 13, 2026 at 07:15:34PM +0100, Peter Maydell wrote: > > On Mon, 13 Jul 2026 at 17:50, Richard Henderson > > <[email protected]> wrote: > > > > > > On 7/11/26 15:34, Alexander Graf wrote: > > > > +Object *object_new_child(Object *parent, const char *id, > > > > + const char *typename) > > > > +{ > > > > + Object *obj; > > > > + > > > > + g_assert(parent); > > > > + g_assert(id); > > > > > > Of course, typename can't be null either. > > > > These asserts are of the "not very useful" kind, as well -- > > if either of these are NULL we're going to crash pretty quickly, > > and then the debugger backtrace will point you at your programming > > error. Asserts are most useful when they turn non-obvious bugs > > into obvious bugs or turn "happens a long time later than when the > > problem is" bugs into "happens very close to when the problem is". > > bugs. > > For the 'id', we ought to call id_wellformed, and report an error > if it fails, which implies an "Error **errp" arg for this method > too.
That would be a programming error, which we should assert() on if we want to check it. Adding an Error* argument just for that would be forcing all the (many many) callsites to add extra error handling code for a can't-happen case. QOM error-handling boilerplate is bad enough already. -- PMM
