From 326487f83e720e7a8902ce66d8f2521b9cdb0031 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Tue, 8 Dec 2020 04:15:39 -0500 Subject: [PATCH] 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. --- src/t_set.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/t_set.c b/src/t_set.c index b2da14cd5..7c71dfc2f 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -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 */