use getPositiveLongFromObjectOrReply for positive check of args (#8750)

just a cleanup
This commit is contained in:
Wen Hui 2021-04-07 03:28:53 -04:00 committed by GitHub
parent 4c14e8668c
commit d96f47cf06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -592,20 +592,14 @@ void lposCommand(client *c) {
}
} else if (!strcasecmp(opt,"COUNT") && moreargs) {
j++;
if (getLongFromObjectOrReply(c, c->argv[j], &count, NULL) != C_OK)
if (getPositiveLongFromObjectOrReply(c, c->argv[j], &count,
"COUNT can't be negative") != C_OK)
return;
if (count < 0) {
addReplyError(c,"COUNT can't be negative");
return;
}
} else if (!strcasecmp(opt,"MAXLEN") && moreargs) {
j++;
if (getLongFromObjectOrReply(c, c->argv[j], &maxlen, NULL) != C_OK)
if (getPositiveLongFromObjectOrReply(c, c->argv[j], &maxlen,
"MAXLEN can't be negative") != C_OK)
return;
if (maxlen < 0) {
addReplyError(c,"MAXLEN can't be negative");
return;
}
} else {
addReplyErrorObject(c,shared.syntaxerr);
return;