[virt-tools-list] [PATCH virt-viewer] Silence coverity warning about dead code
Jonathon Jongsma
jjongsma at redhat.com
Tue Dec 4 16:42:51 UTC 2018
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 at redhat.com>
---
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:
--
2.17.2
More information about the virt-tools-list
mailing list