[libvirt] [PATCH 3/3] sheepdog: Add Coverity filter

Eric Blake eblake at redhat.com
Tue Mar 5 17:14:38 UTC 2013


On 03/05/2013 05:43 AM, John Ferlan wrote:
> Add a Coverity dead_error_condition tag since it's not possible for next
> to be NULL at that point and thus exit the while loop.  If next were NULL
> the condition to set it would have done the return -1.
> ---
>  src/storage/storage_backend_sheepdog.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
> index 218284d..7b564bd 100644
> --- a/src/storage/storage_backend_sheepdog.c
> +++ b/src/storage/storage_backend_sheepdog.c
> @@ -85,6 +85,8 @@ virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
>          pool->available = pool->capacity - pool->allocation;
>          return 0;
>  
> +         /* coverity[dead_error_condition] - since we return -1 above we'll
> +          *                                  never get to return -1 below */
>      } while ((p = next));

Instead of adding this fancy comment, why not just change the earlier
'return -1;' lines into 'break;'.  Then the end of the function would be
reachable, we'd no longer have dead code, we don't need a
coverity-specific comment, and other code analyzers will not need
similar tricks at a later date.

-- 
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/20130305/b931483b/attachment-0001.sig>


More information about the libvir-list mailing list