diff options
author | Madelyn Olson <34459052+madolson@users.noreply.github.com> | 2020-08-11 20:04:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 20:04:54 -0700 |
commit | f2db379fa3f6e0c0d81350fd0f29febea95df469 (patch) | |
tree | 07a32accac0b537fd5cef4c3788c7595483953ad /src/t_string.c | |
parent | ddcbb628a18cbd6febc6c31e71de1a140239e8b4 (diff) | |
download | redis-f2db379fa3f6e0c0d81350fd0f29febea95df469.tar.gz |
Replace usage of wrongtypeerr with helper (#7633)
* Replace usage of wrongtypeerr with helper
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/t_string.c b/src/t_string.c index 4be758e65..93910e5a9 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -167,13 +167,12 @@ int getGenericCommand(client *c) { if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp])) == NULL) return C_OK; - if (o->type != OBJ_STRING) { - addReply(c,shared.wrongtypeerr); + if (checkType(c,o,OBJ_STRING)) { return C_ERR; - } else { - addReplyBulk(c,o); - return C_OK; } + + addReplyBulk(c,o); + return C_OK; } void getCommand(client *c) { @@ -348,7 +347,7 @@ void incrDecrCommand(client *c, long long incr) { robj *o, *new; o = lookupKeyWrite(c->db,c->argv[1]); - if (o != NULL && checkType(c,o,OBJ_STRING)) return; + if (checkType(c,o,OBJ_STRING)) return; if (getLongLongFromObjectOrReply(c,o,&value,NULL) != C_OK) return; oldvalue = value; @@ -408,7 +407,7 @@ void incrbyfloatCommand(client *c) { robj *o, *new, *aux1, *aux2; o = lookupKeyWrite(c->db,c->argv[1]); - if (o != NULL && checkType(c,o,OBJ_STRING)) return; + if (checkType(c,o,OBJ_STRING)) return; if (getLongDoubleFromObjectOrReply(c,o,&value,NULL) != C_OK || getLongDoubleFromObjectOrReply(c,c->argv[2],&incr,NULL) != C_OK) return; |