summaryrefslogtreecommitdiff
path: root/src/t_list.c
diff options
context:
space:
mode:
authorMadelyn Olson <34459052+madolson@users.noreply.github.com>2020-08-11 20:04:54 -0700
committerGitHub <noreply@github.com>2020-08-11 20:04:54 -0700
commitf2db379fa3f6e0c0d81350fd0f29febea95df469 (patch)
tree07a32accac0b537fd5cef4c3788c7595483953ad /src/t_list.c
parentddcbb628a18cbd6febc6c31e71de1a140239e8b4 (diff)
downloadredis-f2db379fa3f6e0c0d81350fd0f29febea95df469.tar.gz
Replace usage of wrongtypeerr with helper (#7633)
* Replace usage of wrongtypeerr with helper
Diffstat (limited to 'src/t_list.c')
-rw-r--r--src/t_list.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/t_list.c b/src/t_list.c
index 2c339888d..7737da771 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -198,8 +198,7 @@ void pushGenericCommand(client *c, int where) {
int j, pushed = 0;
robj *lobj = lookupKeyWrite(c->db,c->argv[1]);
- if (lobj && lobj->type != OBJ_LIST) {
- addReply(c,shared.wrongtypeerr);
+ if (checkType(c,lobj,OBJ_LIST)) {
return;
}
@@ -691,7 +690,7 @@ void rpoplpushCommand(client *c) {
robj *dobj = lookupKeyWrite(c->db,c->argv[2]);
robj *touchedkey = c->argv[1];
- if (dobj && checkType(c,dobj,OBJ_LIST)) return;
+ if (checkType(c,dobj,OBJ_LIST)) return;
value = listTypePop(sobj,LIST_TAIL);
/* We saved touched key, and protect it, since rpoplpushHandlePush
* may change the client command argument vector (it does not
@@ -803,8 +802,7 @@ void blockingPopGenericCommand(client *c, int where) {
for (j = 1; j < c->argc-1; j++) {
o = lookupKeyWrite(c->db,c->argv[j]);
if (o != NULL) {
- if (o->type != OBJ_LIST) {
- addReply(c,shared.wrongtypeerr);
+ if (checkType(c,o,OBJ_LIST)) {
return;
} else {
if (listTypeLength(o) != 0) {
@@ -863,6 +861,7 @@ void brpoplpushCommand(client *c) {
!= C_OK) return;
robj *key = lookupKeyWrite(c->db, c->argv[1]);
+ if (checkType(c,key,OBJ_LIST)) return;
if (key == NULL) {
if (c->flags & CLIENT_MULTI) {
@@ -874,13 +873,9 @@ void brpoplpushCommand(client *c) {
blockForKeys(c,BLOCKED_LIST,c->argv + 1,1,timeout,c->argv[2],NULL);
}
} else {
- if (key->type != OBJ_LIST) {
- addReply(c, shared.wrongtypeerr);
- } else {
- /* The list exists and has elements, so
- * the regular rpoplpushCommand is executed. */
- serverAssertWithInfo(c,key,listTypeLength(key) > 0);
- rpoplpushCommand(c);
- }
+ /* The list exists and has elements, so
+ * the regular rpoplpushCommand is executed. */
+ serverAssertWithInfo(c,key,listTypeLength(key) > 0);
+ rpoplpushCommand(c);
}
}