Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a compilation warning in command.c relating to kpos shadowing #201

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ char *redis_parse_bulk(char *p, char *end, char **str, uint32_t *len) {
return p;
}

static inline int push_keypos(struct cmd *r, char *arg, uint32_t arglen) {
struct keypos *kpos = hiarray_push(r->keys);
if (kpos == NULL)
return 0;
kpos->start = arg;
kpos->end = arg + arglen;
return 1;
}

/*
* Reference: http://redis.io/topics/protocol
*
Expand Down Expand Up @@ -306,11 +315,8 @@ 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);
if (kpos == NULL)
if (!push_keypos(r, arg, arglen))
goto oom;
kpos->start = arg;
kpos->end = arg + arglen;
goto done;
}
}
Expand Down Expand Up @@ -353,11 +359,8 @@ void redis_parse_cmd(struct cmd *r) {
goto error;
}

struct keypos *kpos = hiarray_push(r->keys);
if (kpos == NULL)
if (!push_keypos(r, arg, arglen))
goto oom;
kpos->start = arg;
kpos->end = arg + arglen;

/* Special commands where we want all keys (not only the first key). */
if (redis_argx(r) || redis_argkvx(r)) {
Expand All @@ -370,11 +373,8 @@ 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);
if (kpos == NULL)
if (!push_keypos(r, arg, arglen))
goto oom;
kpos->start = arg;
kpos->end = arg + arglen;
}
}

Expand Down
Loading