Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a compilation warning in command.c relating to kpos shadowing
Browse files Browse the repository at this point in the history
When building with the gcc -Wshadow option, a warning is generated
in redis_parse_cmd() because the second and third declarations of
the same-named kpos variable share scope.  It's benign but it'd be
great to have clean compilation when using this option.
natoscott committed Feb 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 9858f64 commit de7010f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions command.c
Original file line number Diff line number Diff line change
@@ -234,6 +234,7 @@ void redis_parse_cmd(struct cmd *r) {
char *arg0 = NULL, *arg1 = NULL; /* The first two args */
uint32_t arg0_len = 0, arg1_len = 0; /* Lengths of arg0 and arg1 */
cmddef *info = NULL; /* Command info, when found */
struct keypos *kpos;

/* Check that the command line is multi-bulk. */
if (*p++ != '*')
@@ -306,7 +307,7 @@ void redis_parse_cmd(struct cmd *r) {
/* Keyword found. Now the first key is the next arg. */
if ((p = redis_parse_bulk(p, end, &arg, &arglen)) == NULL)
goto error;
struct keypos *kpos = hiarray_push(r->keys);
kpos = hiarray_push(r->keys);
if (kpos == NULL)
goto oom;
kpos->start = arg;
@@ -353,7 +354,7 @@ void redis_parse_cmd(struct cmd *r) {
goto error;
}

struct keypos *kpos = hiarray_push(r->keys);
kpos = hiarray_push(r->keys);
if (kpos == NULL)
goto oom;
kpos->start = arg;
@@ -370,7 +371,7 @@ void redis_parse_cmd(struct cmd *r) {
goto error;
if (redis_argkvx(r) && i % 2 == 0)
continue; /* not a key */
struct keypos *kpos = hiarray_push(r->keys);
kpos = hiarray_push(r->keys);
if (kpos == NULL)
goto oom;
kpos->start = arg;

0 comments on commit de7010f

Please sign in to comment.