[libvirt] [PATCH 2/7] util: Resolve Coverity FORWARD_NULL

Peter Krempa pkrempa at redhat.com
Wed Jul 1 14:50:29 UTC 2015


On Wed, Jul 01, 2015 at 10:03:46 -0400, John Ferlan wrote:
> Convert virPCIDriverFile to return the buffer allocated (or not) and make the
> appropriate check in the caller.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/util/virpci.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index ad08570..5d86c89 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -215,14 +215,13 @@ virPCIDriverDir(char **buffer, const char *driver)
>  }
>  
>  
> -static int
> -virPCIDriverFile(char **buffer, const char *driver, const char *file)
> +static char *
> +virPCIDriverFile(const char *driver, const char *file)
>  {
> -    VIR_FREE(*buffer);
> +    char *buffer = NULL;

Shouldn't be necessary to init this, sice virAsprintf sets it to NULL on
failure.

>  
> -    if (virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file) < 0)
> -        return -1;
> -    return 0;
> +    ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s/%s", driver, file));
> +    return buffer;
>  }
>  

ACK,

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150701/e1eaf938/attachment-0001.sig>


More information about the libvir-list mailing list