[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 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


Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]