[libvirt] [PATCH 2/3] Coverity: Resolve a FORWARD_NULL
Eric Blake
eblake at redhat.com
Tue Mar 25 20:56:54 UTC 2014
On 03/25/2014 12:00 PM, John Ferlan wrote:
> Recent changes in the module seemed to have caused Coverity to reanalyze
> certain parts of the code. Previously the code was modified via commit
> id '11a11812' to resolve a different error (perhaps DEADCODE). Up through
> commit id '7b3f1f8c' there were no issues.
>
> The new error indicats the 'outbuf' was checked for NULL and then complains
> because of the dereference. Adding checks for non-NULL prior to the deref
> resulted in a DEADCODE message.
>
> So, resolve using an sa_assert() to keep Coverity quiet especially since
> it doesn't understand that outbuf will change as a result of a successful
> virCommandRun() call.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> tests/commandtest.c | 1 +
> 1 file changed, 1 insertion(+)
ACK
>
> diff --git a/tests/commandtest.c b/tests/commandtest.c
> index c5c3a9a..7d2161c 100644
> --- a/tests/commandtest.c
> +++ b/tests/commandtest.c
> @@ -690,6 +690,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED)
> goto cleanup;
> }
>
> + sa_assert(outbuf);
> if (*outbuf) {
> puts("output buffer is not an allocated empty string");
> goto cleanup;
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140325/1cf3aed7/attachment-0001.sig>
More information about the libvir-list
mailing list