summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYang Bodong <bodong.ybd@alibaba-inc.com>2021-04-07 15:01:28 +0800
committerGitHub <noreply@github.com>2021-04-07 10:01:28 +0300
commit4c14e8668cdfa6a967fd3be6e0a159d1156b7ef6 (patch)
tree3e91ff494a9b44a920ee281ee229c1365a3213aa /src
parent4de1031d8a4d573b8930cde46a0d5c6ce4799f95 (diff)
downloadredis-4c14e8668cdfa6a967fd3be6e0a159d1156b7ef6.tar.gz
Fix out of range confusing error messages (XAUTOCLAIM, RPOP count) (#8746)
Fix out of range error messages to be clearer (avoid mentioning 9223372036854775807) * Fix XAUTOCLAIM COUNT option confusing error msg * Fix other RPOP and alike error message to mention positive
Diffstat (limited to 'src')
-rw-r--r--src/object.c6
-rw-r--r--src/t_stream.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/object.c b/src/object.c
index ce2f3dc14..b75e547b9 100644
--- a/src/object.c
+++ b/src/object.c
@@ -727,7 +727,11 @@ int getRangeLongFromObjectOrReply(client *c, robj *o, long min, long max, long *
}
int getPositiveLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg) {
- return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, msg);
+ if (msg) {
+ return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, msg);
+ } else {
+ return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, "value is out of range, must be positive");
+ }
}
int getIntFromObjectOrReply(client *c, robj *o, int *target, const char *msg) {
diff --git a/src/t_stream.c b/src/t_stream.c
index f175eed9a..c0283f3e9 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -3051,12 +3051,8 @@ void xautoclaimCommand(client *c) {
int moreargs = (c->argc-1) - j; /* Number of additional arguments. */
char *opt = c->argv[j]->ptr;
if (!strcasecmp(opt,"COUNT") && moreargs) {
- if (getPositiveLongFromObjectOrReply(c,c->argv[j+1],&count,NULL) != C_OK)
+ if (getRangeLongFromObjectOrReply(c,c->argv[j+1],1,LONG_MAX,&count,"COUNT must be > 0") != C_OK)
return;
- if (count == 0) {
- addReplyError(c,"COUNT must be > 0");
- return;
- }
j++;
} else if (!strcasecmp(opt,"JUSTID")) {
justid = 1;