[libvirt] [PATCH 3/4] utils: Remove ATTRIBUTE_NONNULL(1) from virCommandSetSendBuffer

John Ferlan jferlan at redhat.com
Fri Jul 26 14:20:16 UTC 2019



On 7/26/19 9:42 AM, Stefan Berger wrote:
> Remove the ATTRIBUTE_NONNULL(1) from virCommandSetSendBuffer()
> prototype since we are checking for '!cmd'.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.ibm.com>
> ---
>  src/util/vircommand.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Coverity will complain that virCommandSetSendBuffer has:

    size_t i = virCommandGetNumSendBuffers(cmd);

    if (!cmd || cmd->has_error)
        return -1;

Since @cmd is dereffed in virCommandGetNumSendBuffers

Just move the initialization to after the return -1; and things will be
good.

John

> diff --git a/src/util/vircommand.h b/src/util/vircommand.h
> index c2abc7b2c3..74574e3fb1 100644
> --- a/src/util/vircommand.h
> +++ b/src/util/vircommand.h
> @@ -149,7 +149,7 @@ void virCommandSetWorkingDirectory(virCommandPtr cmd,
>  int virCommandSetSendBuffer(virCommandPtr cmd,
>                              int fd,
>                              unsigned char *buffer, size_t buflen)
> -    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
> +    ATTRIBUTE_NONNULL(3);
>  
>  void virCommandSetInputBuffer(virCommandPtr cmd,
>                                const char *inbuf) ATTRIBUTE_NONNULL(2);
> 




More information about the libvir-list mailing list