[libvirt] [PATCH 5/8] virsh: Resolve Coverity DEADCODE

Peter Krempa pkrempa at redhat.com
Mon Sep 15 07:39:32 UTC 2014


On 09/13/14 15:27, John Ferlan wrote:
> Coverity complains that on the first pass through the for loop that
> 'params' cannot be true, thus the ternary setting to "&" cannot be
> done - which is I believe true - thus this really is a deadcode
> situation.
> 
> It doesn't complain on the following comparison for "spice" - of course
> because we've set params = true now. I believe that's correct since we're
> putting together the line and the first "param" sets the "?" while the rest
> use "&".
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  tools/virsh-domain.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index f80741c..a040e27 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -9824,6 +9824,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
>  
>          /* TLS Port */
>          if (tls_port) {
> +            /* coverity[dead_error_condition] */
>              virBufferAsprintf(&buf,
>                                "%stls-port=%d",
>                                params ? "&" : "?",

Since the for loop reaches the point at most once, this is really
doesn't have the chance to be executed with params equal to true. This
was probably done to have it consistent.

> 

We might as well drop the params and hardcode the "?".

ACK to both approaches.

Peter


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


More information about the libvir-list mailing list