[libvirt] [PATCH 0/2] Couple of build fixes

Contradictory to my previous patch set [1], these are not pushed yet and thus require proper review. 1: https://www.redhat.com/archives/libvir-list/2016-July/msg01147.html Michal Privoznik (2): vshCmddefGetOption: Change type of opt_index vshReadlineParse: Drop some unused variables tools/vsh.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.8.4

This function tries to look up desired option for a given parsed command. Upon successful return it also stores option position into passed *opt_index. Now, this variable is type of int, even though it is never ever used to store negative value. Moreover, the variable is set from a local variable which is type of size_t. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tools/vsh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 9ac4f21..a7ce141 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -434,7 +434,7 @@ static vshCmdOptDef helpopt = { }; static const vshCmdOptDef * vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, - uint64_t *opts_seen, int *opt_index, char **optstr, + uint64_t *opts_seen, size_t *opt_index, char **optstr, bool report) { size_t i; @@ -1418,7 +1418,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) } else if (tkdata[0] == '-' && tkdata[1] == '-' && c_isalnum(tkdata[2])) { char *optstr = strchr(tkdata + 2, '='); - int opt_index = 0; + size_t opt_index = 0; if (optstr) { *optstr = '\0'; /* convert the '=' to '\0' */ @@ -2641,7 +2641,7 @@ vshReadlineParse(const char *text, int state) static char *ctext, *sanitized_text; static uint64_t const_opts_need_arg, const_opts_required, const_opts_seen; uint64_t opts_need_arg, opts_required, opts_seen; - unsigned int opt_index; + size_t opt_index; static bool cmd_exists, opts_filled, opt_exists; static bool non_bool_opt_exists, data_acomplete; -- 2.8.4

My compiler identified some variables that were set, but never actually used. For instance, opts_required, and data_acomplete. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tools/vsh.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index a7ce141..540c78c 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2640,10 +2640,10 @@ vshReadlineParse(const char *text, int state) char *res = NULL; static char *ctext, *sanitized_text; static uint64_t const_opts_need_arg, const_opts_required, const_opts_seen; - uint64_t opts_need_arg, opts_required, opts_seen; + uint64_t opts_need_arg, opts_seen; size_t opt_index; static bool cmd_exists, opts_filled, opt_exists; - static bool non_bool_opt_exists, data_acomplete; + static bool non_bool_opt_exists; if (!state) { parser.pos = rl_line_buffer; @@ -2687,7 +2687,6 @@ vshReadlineParse(const char *text, int state) cmd_exists = false; opts_filled = false; non_bool_opt_exists = false; - data_acomplete = false; const_opts_need_arg = 0; const_opts_required = 0; @@ -2713,7 +2712,6 @@ vshReadlineParse(const char *text, int state) c_isalnum(tkdata[2])) { /* Command retrieved successfully, move to options */ opts_need_arg = const_opts_need_arg; - opts_required = const_opts_required; opts_seen = const_opts_seen; optstr = strchr(tkdata + 2, '='); opt_index = 0; @@ -2749,7 +2747,6 @@ vshReadlineParse(const char *text, int state) tkdata = const_tkdata; if (STREQ(tkdata, sanitized_text)) { /* auto-complete non-bool option */ - data_acomplete = true; break; } } -- 2.8.4

On 27/07/16 18:05, Michal Privoznik wrote:
Contradictory to my previous patch set [1], these are not pushed yet and thus require proper review.
1: https://www.redhat.com/archives/libvir-list/2016-July/msg01147.html
Michal Privoznik (2): vshCmddefGetOption: Change type of opt_index vshReadlineParse: Drop some unused variables
tools/vsh.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
ACK series. Erik
participants (2)
-
Erik Skultety
-
Michal Privoznik