Re: [PATCH virt-viewer] Silence coverity warning about dead code

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

 



On 12/4/18 2:42 PM, Jonathon Jongsma wrote:
> For some reason, coverity was complaining that the definition of
> cred_type_to_str was dead code, even though it wasn't. Changing the
> storage to static silences the warning. Since that's a benficial change
> anyway, let's change it. At the same time, make the pointer constant as
> well and move it outside of the loop since it doesn't need to be inside
> the loop.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  src/virt-viewer.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 5c321db..86d0c75 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -1002,12 +1002,13 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
>          }
>      }
>  
> +    static const char * const cred_type_to_str[] = {
> +        [VIR_CRED_USERNAME] = "Identity to act as",
> +        [VIR_CRED_AUTHNAME] = "Identify to authorize as",
> +        [VIR_CRED_PASSPHRASE] = "Passphrase secret",
> +    };
> +
>      for (i = 0 ; i < ncred ; i++) {
> -        const char *cred_type_to_str[] = {
> -            [VIR_CRED_USERNAME] = "Identity to act as",
> -            [VIR_CRED_AUTHNAME] = "Identify to authorize as",
> -            [VIR_CRED_PASSPHRASE] = "Passphrase secret",
> -        };
>          switch (cred[i].type) {
>          case VIR_CRED_AUTHNAME:
>          case VIR_CRED_USERNAME:
> 
Acked-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx>

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko@xxxxxxxxxx

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux