summaryrefslogtreecommitdiff
path: root/src/t_set.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_set.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_set.c')
-rw-r--r--src/t_set.c9
1 files changed, 3 insertions, 6 deletions
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) {