From f2db379fa3f6e0c0d81350fd0f29febea95df469 Mon Sep 17 00:00:00 2001 From: Madelyn Olson <34459052+madolson@users.noreply.github.com> Date: Tue, 11 Aug 2020 20:04:54 -0700 Subject: Replace usage of wrongtypeerr with helper (#7633) * Replace usage of wrongtypeerr with helper --- src/t_set.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/t_set.c') diff --git a/src/t_set.c b/src/t_set.c index f474c2b56..9166e2b9a 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -266,14 +266,11 @@ void saddCommand(client *c) { int j, added = 0; set = lookupKeyWrite(c->db,c->argv[1]); + if (checkType(c,set,OBJ_SET)) return; + if (set == NULL) { set = setTypeCreate(c->argv[2]->ptr); dbAdd(c->db,c->argv[1],set); - } else { - if (set->type != OBJ_SET) { - addReply(c,shared.wrongtypeerr); - return; - } } for (j = 2; j < c->argc; j++) { @@ -330,7 +327,7 @@ void smoveCommand(client *c) { /* If the source key has the wrong type, or the destination key * is set and has the wrong type, return with an error. */ if (checkType(c,srcset,OBJ_SET) || - (dstset && checkType(c,dstset,OBJ_SET))) return; + checkType(c,dstset,OBJ_SET)) return; /* If srcset and dstset are equal, SMOVE is a no-op */ if (srcset == dstset) { -- cgit v1.2.1