[libvirt] [PATCH 3/9] nodeinfo: Add coverity[dead_error_begin] and [returned_null] tags

Eric Blake eblake at redhat.com
Tue Jan 22 16:32:26 UTC 2013


On 01/22/2013 07:40 AM, John Ferlan wrote:
> The use of switch statements inside a bounded for loop resulted in some
> false positives regarding the "default:" label which cannot be reached
> since each of the other case statements use the possible for loop values.
> A [dead_error_begin] was added before the default label.
> 
> Commit id ebdbe25a adjusted the algorithm and the caller guarantees that
> the 'params' will have a '_' in the name being searched. Add the [returned_null]
> tag to the two instances.
> ---
>  src/nodeinfo.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/nodeinfo.c b/src/nodeinfo.c
> index 477104f..a05159c 100644
> --- a/src/nodeinfo.c
> +++ b/src/nodeinfo.c
> @@ -1124,6 +1124,7 @@ nodeSetMemoryParameterValue(virTypedParameterPtr param)
>      int ret = -1;
>      int rc = -1;
>  
> +    /* coverity[returned_null] */
>      char *field = strchr(param->field, '_');

Another possibility is to use:

char *field = strchr(param->field, '_');
sa_assert(field);

which would have the advantage of working with clang in addition to
Coverity, if clang also turns out to have the same false positive.

-- 
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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130122/5ec1e8c4/attachment-0001.sig>


More information about the libvir-list mailing list