use getPositiveLongFromObjectOrReply for positive check in spop (#8146)

This is a cleanup commit that doesn't fix any bug, however it does change the error response text in case the user provided a negative number.
This commit is contained in:
Wen Hui 2020-12-08 04:15:39 -05:00 committed by GitHub
parent 6bb5503524
commit 09b7f6c2a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -457,13 +457,8 @@ void spopWithCountCommand(client *c) {
robj *set;
/* Get the count argument */
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
if (l >= 0) {
count = (unsigned long) l;
} else {
addReply(c,shared.outofrangeerr);
return;
}
if (getPositiveLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
count = (unsigned long) l;
/* Make sure a key with the name inputted exists, and that it's type is
* indeed a set. Otherwise, return nil */