Eric Blake wrote: > On 05/17/2010 11:40 AM, Jim Meyering wrote: >> Eric Blake wrote: >>> On 05/17/2010 11:22 AM, Jim Meyering wrote: >>>> This addresses another coverity-spotted "flaw". >>>> However, since "cgroup" is never NULL after that initial "if" stmt, >>>> the only penalty is that the useless cleanup test would make a reviewer >>>> try to figure out how cgroup could be NULL there. >>> >>> ACK. >> >> Thanks. >> >>>> cleanup: >>>> - if (cgroup) >>>> - virCgroupFree(&cgroup); >>>> + virCgroupFree(&cgroup); > > Hmm, on re-reading this, why is virCgroupFree taking a pointer to a > virCgroupPtr, then blindly dereferencing it throughout the cleanup? It > almost seems like we have the wrong signature, and should be using: > > virCgroupFree(virCgroupPtr group) > > instead of > > virCgroupFree(virCgroupPtr *group) > > and adjust all callers. Almost. virCgroupPtr takes an address of a pointer so it can set the caller's pointer to NULL (via its VIR_FREE use). Otherwise, in order to retain existing semantics, some callers would have to change from this: virCgroupFree(&p); to this: virCgroupFree(p); p = NULL; >> This makes the useless-if-before-free test in maint.mk spot >> uses of virCgroupFree just like it does for free and the other >> listed functions. >> * cfg.mk (useless_free_options): Add virCgroupFree. >> Prompted by suggestion from Eric Blake. > > ACK, given the current semantics of virCgroupFree. Thanks. -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list