[...]
>> +char *
>> +qemuBuildShmemDevStr(virDomainDefPtr def,
>> + virDomainShmemDefPtr shmem,
>> + virQEMUCapsPtr qemuCaps)
>> +{
>> + virBuffer buf = VIR_BUFFER_INITIALIZER;
>> +
>> + virBufferAsprintf(&buf, "%s",
>> virDomainShmemModelTypeToString(shmem->model));
>> + virBufferAsprintf(&buf, ",id=%s", shmem->info.alias);
>> +
>> + if (shmem->server.enabled)
>> + virBufferAsprintf(&buf, ",chardev=char%s",
shmem->info.alias);
>> + else
>> + virBufferAsprintf(&buf, ",memdev=shmmem-%s",
>> shmem->info.alias);
>> +
>> + if (shmem->msi.vectors)
>> + virBufferAsprintf(&buf, ",vectors=%u",
shmem->msi.vectors);
>> + if (shmem->msi.ioeventfd) {
>> + virBufferAsprintf(&buf, ",ioeventfd=%s",
>> +
>> virTristateSwitchTypeToString(shmem->msi.ioeventfd));
>> + }
>> +
>> + if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps)
>> < 0) {
>> + virBufferFreeAndReset(&buf);
>> + return NULL;
>> + }
>> +
>> + if (virBufferCheckError(&buf) < 0)
>
> Still would need to FreeAndReset - I'd be OK if it were an || to the
> previous if, although I know that causes agita for others.
>
Well, not really. The content gets free()'d whenever the buf->error is
set, so it is already cleared if there was an error.
That's not how I read/see other callers of virBufferCheckError and I see
no free in virBufferCheckErrorInternal
John
[...]