Fix SENTINEL DEBUG with wrong arguments (#10258)

There are two issues in SENTINEL DEBUG:
1. The error message should mention SENTINEL DEBUG
2. Add missing reuturn in args parse.

```
redis> sentinel debug INFO-PERIOD aaa
(error) ERR Invalid argument 'aaa' for SENTINEL SET 'INFO-PERIOD'

redis> sentinel debug a b c d
(error) ERR Unknown option or number of arguments for SENTINEL SET 'a'
redis> ping
(error) ERR Unknown option or number of arguments for SENTINEL SET 'b'
```

Introduced in #9291. Also do some cleanups in the code.
This commit is contained in:
gms 2022-02-09 00:45:47 +08:00 committed by GitHub
parent 34c288fe11
commit 0990dec3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3454,7 +3454,6 @@ void addReplySentinelRedisInstance(client *c, sentinelRedisInstance *ri) {
}
void sentinelSetDebugConfigParameters(client *c){
int j;
int badarg = 0; /* Bad argument position for error reporting. */
char *option;
@ -3584,24 +3583,22 @@ void sentinelSetDebugConfigParameters(client *c){
} else {
addReplyErrorFormat(c,"Unknown option or number of arguments for "
"SENTINEL SET '%s'", option);
"SENTINEL DEBUG '%s'", option);
return;
}
}
addReply(c,shared.ok);
return;
badfmt: /* Bad format errors */
addReplyErrorFormat(c,"Invalid argument '%s' for SENTINEL SET '%s'",
addReplyErrorFormat(c,"Invalid argument '%s' for SENTINEL DEBUG '%s'",
(char*)c->argv[badarg]->ptr,option);
return;
}
void addReplySentinelDebugInfo(client *c) {
void *mbl;
int fields = 0;