[libvirt] [PATCH v2] pci: Use virPCIDeviceAddress in virPCIDevice

Laine Stump laine at laine.org
Tue Dec 15 17:27:52 UTC 2015


On 12/15/2015 05:48 AM, Andrea Bolognani wrote:
> On Tue, 2015-12-15 at 10:05 +0100, Andrea Bolognani wrote:
>> @@ -1661,25 +1661,14 @@ virPCIDeviceFree(virPCIDevicePtr dev)
>>     * @dev: device to get address from
>>     *
>>     * Take a PCI device on input and return its PCI address. The
>> - * caller must free the returned value when no longer needed.
>> + * returned object is owned by the device and must not be freed.
>>     *
>>     * Returns NULL on failure, the device address on success.
>>     */
> Not sending a v3 just for this, but if ACKed I'll also squash in
>
> - * Returns NULL on failure, the device address on success.
> + * Returns: a pointer to the address, which can never be NULL.
>
> to keep the documentation consistent with the actual behaviour.

Also, the places where this is called no longer need to check for NULL 
and goto cleanup. And beyond that, 2 of the three callers only use the 
returned value a single time, so the code could be shortened even 
further by just using "virPCIDeviceGetAddress(blah)" directly, instead 
of placing that return value into a local, and then calling using the 
local a single time later.

ACK for the whole patch as long as you remove the check for NULL from 
all the callers of virPCIDeviceGetAddress() (and optionally eliminate 
the temporary variable in the two cases where it is used only once).




More information about the libvir-list mailing list