[PATCH] vsh: Fix warnings in command line completer

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

 



GCC complained that

vsh.c: In function 'vshReadlineOptionsGenerator':
vsh.c:2622:29: warning: unused variable 'opt' [-Wunused-variable]
         const vshCmdOptDef *opt = &cmd->opts[list_index];
                             ^
vsh.c: In function 'vshReadlineParse':
vsh.c:2830:44: warning: 'opt' may be used uninitialized in this function
[-Wmaybe-uninitialized]
             completed_list = opt->completer(autoCompleteOpaque,

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    I'm not very fond of the second hunk, but the completer is such
    a horrible piece of code I couldn't believe it was pushed. I just
    made the easiest fix and ran away from the code screaming.

 tools/vsh.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index cdd1cba..420eb79 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2619,7 +2619,6 @@ vshReadlineOptionsGenerator(const char *text, int state, const vshCmdDef *cmd_pa
         return NULL;
 
     while ((name = cmd->opts[list_index].name)) {
-        const vshCmdOptDef *opt = &cmd->opts[list_index];
         char *res;
 
         list_index++;
@@ -2648,7 +2647,7 @@ vshReadlineParse(const char *text, int state)
     static vshCommandParser parser, sanitizer;
     vshCommandToken tk;
     static const vshCmdDef *cmd;
-    const vshCmdOptDef *opt;
+    const vshCmdOptDef *opt = NULL;
     char *tkdata, *optstr, *const_tkdata, *completed_name;
     char *res = NULL;
     static char *ctext, *sanitized_text;
-- 
2.10.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]