Flow through the error handling path for most errors (#8226)

Properly throw errors for invalid replication stream and support https://github.com/redis/redis/pull/8217
This commit is contained in:
Madelyn Olson 2020-12-23 19:06:25 -08:00 committed by GitHub
parent 2427481e49
commit 4ef25c45bb
21 changed files with 103 additions and 103 deletions

View File

@ -2224,7 +2224,7 @@ void addReplyCommandCategories(client *c, struct redisCommand *cmd) {
void authCommand(client *c) {
/* Only two or three argument forms are allowed. */
if (c->argc > 3) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -611,7 +611,7 @@ void bitopCommand(client *c) {
else if((opname[0] == 'n' || opname[0] == 'N') && !strcasecmp(opname,"not"))
op = BITOP_NOT;
else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -813,7 +813,7 @@ void bitcountCommand(client *c) {
end = strlen-1;
} else {
/* Syntax error. */
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -878,7 +878,7 @@ void bitposCommand(client *c) {
end = strlen-1;
} else {
/* Syntax error. */
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -970,7 +970,7 @@ void bitfieldGeneric(client *c, int flags) {
}
continue;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
zfree(ops);
return;
}

View File

@ -200,9 +200,9 @@ void disconnectAllBlockedClients(void) {
client *c = listNodeValue(ln);
if (c->flags & CLIENT_BLOCKED) {
addReplySds(c,sdsnew(
addReplyError(c,
"-UNBLOCKED force unblock from blocking operation, "
"instance state changed (master -> replica?)\r\n"));
"instance state changed (master -> replica?)");
unblockClient(c);
c->flags |= CLIENT_CLOSE_AFTER_REPLY;
}

View File

@ -4820,7 +4820,7 @@ NULL
takeover = 1;
force = 1; /* Takeover also implies force. */
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -4911,7 +4911,7 @@ NULL
} else if (!strcasecmp(c->argv[2]->ptr,"soft")) {
hard = 0;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -5049,7 +5049,7 @@ void restoreCommand(client *c) {
}
j++; /* Consume additional arg. */
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -5057,7 +5057,7 @@ void restoreCommand(client *c) {
/* Make sure this key does not already exist here... */
robj *key = c->argv[1];
if (!replace && lookupKeyWrite(c->db,key) != NULL) {
addReply(c,shared.busykeyerr);
addReplyErrorObject(c,shared.busykeyerr);
return;
}
@ -5170,8 +5170,7 @@ migrateCachedSocket* migrateGetSocket(client *c, robj *host, robj *port, long ti
conn = server.tls_cluster ? connCreateTLS() : connCreateSocket();
if (connBlockingConnect(conn, c->argv[1]->ptr, atoi(c->argv[2]->ptr), timeout)
!= C_OK) {
addReplySds(c,
sdsnew("-IOERR error or timeout connecting to the client\r\n"));
addReplyError(c,"-IOERR error or timeout connecting to the client");
connClose(conn);
sdsfree(name);
return NULL;
@ -5259,14 +5258,14 @@ void migrateCommand(client *c) {
replace = 1;
} else if (!strcasecmp(c->argv[j]->ptr,"auth")) {
if (!moreargs) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
j++;
password = c->argv[j]->ptr;
} else if (!strcasecmp(c->argv[j]->ptr,"auth2")) {
if (moreargs < 2) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
username = c->argv[++j]->ptr;
@ -5282,7 +5281,7 @@ void migrateCommand(client *c) {
num_keys = c->argc - j - 1;
break; /* All the remaining args are keys. */
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -5837,23 +5836,23 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
* be set to the hash slot that caused the redirection. */
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code) {
if (error_code == CLUSTER_REDIR_CROSS_SLOT) {
addReplySds(c,sdsnew("-CROSSSLOT Keys in request don't hash to the same slot\r\n"));
addReplyError(c,"-CROSSSLOT Keys in request don't hash to the same slot");
} else if (error_code == CLUSTER_REDIR_UNSTABLE) {
/* The request spawns multiple keys in the same slot,
* but the slot is not "stable" currently as there is
* a migration or import in progress. */
addReplySds(c,sdsnew("-TRYAGAIN Multiple keys request during rehashing of slot\r\n"));
addReplyError(c,"-TRYAGAIN Multiple keys request during rehashing of slot");
} else if (error_code == CLUSTER_REDIR_DOWN_STATE) {
addReplySds(c,sdsnew("-CLUSTERDOWN The cluster is down\r\n"));
addReplyError(c,"-CLUSTERDOWN The cluster is down");
} else if (error_code == CLUSTER_REDIR_DOWN_RO_STATE) {
addReplySds(c,sdsnew("-CLUSTERDOWN The cluster is down and only accepts read commands\r\n"));
addReplyError(c,"-CLUSTERDOWN The cluster is down and only accepts read commands");
} else if (error_code == CLUSTER_REDIR_DOWN_UNBOUND) {
addReplySds(c,sdsnew("-CLUSTERDOWN Hash slot not served\r\n"));
addReplyError(c,"-CLUSTERDOWN Hash slot not served");
} else if (error_code == CLUSTER_REDIR_MOVED ||
error_code == CLUSTER_REDIR_ASK)
{
addReplySds(c,sdscatprintf(sdsempty(),
"-%s %d %s:%d\r\n",
addReplyErrorSds(c,sdscatprintf(sdsempty(),
"-%s %d %s:%d",
(error_code == CLUSTER_REDIR_ASK) ? "ASK" : "MOVED",
hashslot,n->ip,n->port));
} else {

View File

@ -593,7 +593,7 @@ int getFlushCommandFlags(client *c, int *flags) {
/* Parse the optional ASYNC option. */
if (c->argc > 1) {
if (c->argc > 2 || strcasecmp(c->argv[1]->ptr,"async")) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return C_ERR;
}
*flags = EMPTYDB_ASYNC;
@ -842,7 +842,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
}
if (count < 1) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
goto cleanup;
}
@ -861,7 +861,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
typename = c->argv[i+1]->ptr;
i+= 2;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
goto cleanup;
}
}
@ -1050,7 +1050,7 @@ void shutdownCommand(client *c) {
int flags = 0;
if (c->argc > 2) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
} else if (c->argc == 2) {
if (!strcasecmp(c->argv[1]->ptr,"nosave")) {
@ -1058,7 +1058,7 @@ void shutdownCommand(client *c) {
} else if (!strcasecmp(c->argv[1]->ptr,"save")) {
flags |= SHUTDOWN_SAVE;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -1144,7 +1144,7 @@ void moveCommand(client *c) {
/* If the user is moving using as target the same
* DB as the source DB it is probably an error. */
if (src == dst) {
addReply(c,shared.sameobjecterr);
addReplyErrorObject(c,shared.sameobjecterr);
return;
}
@ -1224,7 +1224,7 @@ void copyCommand(client *c) {
robj *key = c->argv[1];
robj *newkey = c->argv[2];
if (src == dst && (sdscmp(key->ptr, newkey->ptr) == 0)) {
addReply(c,shared.sameobjecterr);
addReplyErrorObject(c,shared.sameobjecterr);
return;
}

View File

@ -474,7 +474,7 @@ NULL
rdbSaveInfo rsi, *rsiptr;
rsiptr = rdbPopulateSaveInfo(&rsi);
if (rdbSave(server.rdb_filename,rsiptr) != C_OK) {
addReply(c,shared.err);
addReplyErrorObject(c,shared.err);
return;
}
}
@ -500,7 +500,7 @@ NULL
int ret = loadAppendOnlyFile(server.aof_filename);
unprotectClient(c);
if (ret != C_OK) {
addReply(c,shared.err);
addReplyErrorObject(c,shared.err);
return;
}
server.dirty = 0; /* Prevent AOF / replication */
@ -512,7 +512,7 @@ NULL
char *strenc;
if ((de = dictFind(c->db->dict,c->argv[2]->ptr)) == NULL) {
addReply(c,shared.nokeyerr);
addReplyErrorObject(c,shared.nokeyerr);
return;
}
val = dictGetVal(de);
@ -564,7 +564,7 @@ NULL
sds key;
if ((de = dictFind(c->db->dict,c->argv[2]->ptr)) == NULL) {
addReply(c,shared.nokeyerr);
addReplyErrorObject(c,shared.nokeyerr);
return;
}
val = dictGetVal(de);

View File

@ -100,8 +100,8 @@ int extractLongLatOrReply(client *c, robj **argv, double *xy) {
}
if (xy[0] < GEO_LONG_MIN || xy[0] > GEO_LONG_MAX ||
xy[1] < GEO_LAT_MIN || xy[1] > GEO_LAT_MAX) {
addReplySds(c, sdscatprintf(sdsempty(),
"-ERR invalid longitude,latitude pair %f,%f\r\n",xy[0],xy[1]));
addReplyErrorFormat(c,
"-ERR invalid longitude,latitude pair %f,%f\r\n",xy[0],xy[1]);
return C_ERR;
}
return C_OK;
@ -902,7 +902,7 @@ void geodistCommand(client *c) {
to_meter = extractUnitOrReply(c,c->argv[4]);
if (to_meter < 0) return;
} else if (c->argc > 5) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -205,7 +205,7 @@ struct hllhdr {
#define HLL_RAW 255 /* Only used internally, never exposed. */
#define HLL_MAX_ENCODING 1
static char *invalid_hll_err = "-INVALIDOBJ Corrupted HLL object detected\r\n";
static char *invalid_hll_err = "-INVALIDOBJ Corrupted HLL object detected";
/* =========================== Low level bit macros ========================= */
@ -1171,9 +1171,8 @@ int isHLLObjectOrReply(client *c, robj *o) {
return C_OK;
invalid:
addReplySds(c,
sdsnew("-WRONGTYPE Key is not a valid "
"HyperLogLog string value.\r\n"));
addReplyError(c,"-WRONGTYPE Key is not a valid "
"HyperLogLog string value.");
return C_ERR;
}
@ -1203,7 +1202,7 @@ void pfaddCommand(client *c) {
updated++;
break;
case -1:
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
}
@ -1245,7 +1244,7 @@ void pfcountCommand(client *c) {
/* Merge with this HLL with our 'max' HLL by setting max[i]
* to MAX(max[i],hll[i]). */
if (hllMerge(registers,o) == C_ERR) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
}
@ -1285,7 +1284,7 @@ void pfcountCommand(client *c) {
/* Recompute it and update the cached value. */
card = hllCount(hdr,&invalid);
if (invalid) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
hdr->card[0] = card & 0xff;
@ -1332,7 +1331,7 @@ void pfmergeCommand(client *c) {
/* Merge with this HLL with our 'max' HLL by setting max[i]
* to MAX(max[i],hll[i]). */
if (hllMerge(max,o) == C_ERR) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
}
@ -1355,7 +1354,7 @@ void pfmergeCommand(client *c) {
/* Convert the destination object to dense representation if at least
* one of the inputs was dense. */
if (use_dense && hllSparseToDense(o) == C_ERR) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
@ -1512,7 +1511,7 @@ void pfdebugCommand(client *c) {
if (hdr->encoding == HLL_SPARSE) {
if (hllSparseToDense(o) == C_ERR) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
server.dirty++; /* Force propagation on encoding change. */
@ -1577,7 +1576,7 @@ void pfdebugCommand(client *c) {
if (hdr->encoding == HLL_SPARSE) {
if (hllSparseToDense(o) == C_ERR) {
addReplySds(c,sdsnew(invalid_hll_err));
addReplyError(c,invalid_hll_err);
return;
}
conv = 1;

View File

@ -2427,7 +2427,7 @@ NULL
}
}
} else if (c->argc != 2) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2446,7 +2446,7 @@ NULL
if (!(c->flags & CLIENT_REPLY_OFF))
c->flags |= CLIENT_REPLY_SKIP_NEXT;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
} else if (!strcasecmp(c->argv[1]->ptr,"kill")) {
@ -2502,17 +2502,17 @@ NULL
} else if (!strcasecmp(c->argv[i+1]->ptr,"no")) {
skipme = 0;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
i += 2;
}
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2649,7 +2649,7 @@ NULL
prefix[numprefix++] = c->argv[j];
} else {
zfree(prefix);
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -2711,7 +2711,7 @@ NULL
disableTracking(c);
} else {
zfree(prefix);
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
zfree(prefix);
@ -2740,7 +2740,7 @@ NULL
return;
}
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -404,7 +404,7 @@ robj *resetRefCount(robj *obj) {
int checkType(client *c, robj *o, int type) {
/* A NULL is considered an empty key */
if (o && o->type != type) {
addReply(c,shared.wrongtypeerr);
addReplyErrorObject(c,shared.wrongtypeerr);
return 1;
}
return 0;
@ -1321,13 +1321,13 @@ NULL
if (getLongLongFromObjectOrReply(c,c->argv[j+1],&samples,NULL)
== C_ERR) return;
if (samples < 0) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
if (samples == 0) samples = LLONG_MAX;
j++; /* skip option argument. */
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}

View File

@ -2852,7 +2852,7 @@ void saveCommand(client *c) {
if (rdbSave(server.rdb_filename,rsiptr) == C_OK) {
addReply(c,shared.ok);
} else {
addReply(c,shared.err);
addReplyErrorObject(c,shared.err);
}
}
@ -2866,7 +2866,7 @@ void bgsaveCommand(client *c) {
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"schedule")) {
schedule = 1;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -2889,7 +2889,7 @@ void bgsaveCommand(client *c) {
} else if (rdbSaveBackground(server.rdb_filename,rsiptr) == C_OK) {
addReplyStatus(c,"Background saving started");
} else {
addReply(c,shared.err);
addReplyErrorObject(c,shared.err);
}
}

View File

@ -715,7 +715,7 @@ void syncCommand(client *c) {
/* Refuse SYNC requests if we are a slave but the link with our master
* is not ok... */
if (server.masterhost && server.repl_state != REPL_STATE_CONNECTED) {
addReplySds(c,sdsnew("-NOMASTERLINK Can't SYNC while not connected with my master\r\n"));
addReplyError(c,"-NOMASTERLINK Can't SYNC while not connected with my master");
return;
}
@ -866,7 +866,7 @@ void replconfCommand(client *c) {
if ((c->argc % 2) == 0) {
/* Number of arguments must be odd to make sure that every
* option has a corresponding value. */
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -368,7 +368,7 @@ void luaReplyToRedisReply(client *c, lua_State *lua) {
if (t == LUA_TSTRING) {
sds err = sdsnew(lua_tostring(lua,-1));
sdsmapchars(err,"\r\n"," ",2);
addReplySds(c,sdscatprintf(sdsempty(),"-%s\r\n",err));
addReplyErrorSds(c,sdscatprintf(sdsempty(),"-%s",err));
sdsfree(err);
lua_pop(lua,2);
return;
@ -1740,11 +1740,11 @@ NULL
forceCommandPropagation(c,PROPAGATE_REPL|PROPAGATE_AOF);
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"kill")) {
if (server.lua_caller == NULL) {
addReplySds(c,sdsnew("-NOTBUSY No scripts in execution right now.\r\n"));
addReplyError(c,"-NOTBUSY No scripts in execution right now.");
} else if (server.lua_caller->flags & CLIENT_MASTER) {
addReplySds(c,sdsnew("-UNKILLABLE The busy script was sent by a master instance in the context of replication and cannot be killed.\r\n"));
addReplyError(c,"-UNKILLABLE The busy script was sent by a master instance in the context of replication and cannot be killed.");
} else if (server.lua_write_dirty) {
addReplySds(c,sdsnew("-UNKILLABLE Sorry the script already executed write commands against the dataset. You can either wait the script termination or kill the server in a hard way using the SHUTDOWN NOSAVE command.\r\n"));
addReplyError(c,"-UNKILLABLE Sorry the script already executed write commands against the dataset. You can either wait the script termination or kill the server in a hard way using the SHUTDOWN NOSAVE command.");
} else {
server.lua_kill = 1;
addReply(c,shared.ok);

View File

@ -3446,7 +3446,7 @@ numargserr:
/* SENTINEL INFO [section] */
void sentinelInfoCommand(client *c) {
if (c->argc > 2) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -2380,9 +2380,9 @@ void afterSleep(struct aeEventLoop *eventLoop) {
void createSharedObjects(void) {
int j;
/* Shared command responses */
shared.crlf = createObject(OBJ_STRING,sdsnew("\r\n"));
shared.ok = createObject(OBJ_STRING,sdsnew("+OK\r\n"));
shared.err = createObject(OBJ_STRING,sdsnew("-ERR\r\n"));
shared.emptybulk = createObject(OBJ_STRING,sdsnew("$0\r\n\r\n"));
shared.czero = createObject(OBJ_STRING,sdsnew(":0\r\n"));
shared.cone = createObject(OBJ_STRING,sdsnew(":1\r\n"));
@ -2390,8 +2390,14 @@ void createSharedObjects(void) {
shared.pong = createObject(OBJ_STRING,sdsnew("+PONG\r\n"));
shared.queued = createObject(OBJ_STRING,sdsnew("+QUEUED\r\n"));
shared.emptyscan = createObject(OBJ_STRING,sdsnew("*2\r\n$1\r\n0\r\n*0\r\n"));
shared.space = createObject(OBJ_STRING,sdsnew(" "));
shared.colon = createObject(OBJ_STRING,sdsnew(":"));
shared.plus = createObject(OBJ_STRING,sdsnew("+"));
/* Shared command error responses */
shared.wrongtypeerr = createObject(OBJ_STRING,sdsnew(
"-WRONGTYPE Operation against a key holding the wrong kind of value\r\n"));
shared.err = createObject(OBJ_STRING,sdsnew("-ERR\r\n"));
shared.nokeyerr = createObject(OBJ_STRING,sdsnew(
"-ERR no such key\r\n"));
shared.syntaxerr = createObject(OBJ_STRING,sdsnew(
@ -2422,9 +2428,6 @@ void createSharedObjects(void) {
"-NOREPLICAS Not enough good replicas to write.\r\n"));
shared.busykeyerr = createObject(OBJ_STRING,sdsnew(
"-BUSYKEY Target key name already exists.\r\n"));
shared.space = createObject(OBJ_STRING,sdsnew(" "));
shared.colon = createObject(OBJ_STRING,sdsnew(":"));
shared.plus = createObject(OBJ_STRING,sdsnew("+"));
/* The shared NULL depends on the protocol version. */
shared.null[0] = NULL;
@ -4956,7 +4959,7 @@ void infoCommand(client *c) {
char *section = c->argc == 2 ? c->argv[1]->ptr : "default";
if (c->argc > 2) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
sds info = genRedisInfoString(section);

View File

@ -256,7 +256,7 @@ void sortCommand(client *c) {
getop++;
j++;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
syntax_error++;
break;
}
@ -279,7 +279,7 @@ void sortCommand(client *c) {
sortval->type != OBJ_ZSET)
{
listRelease(operations);
addReply(c,shared.wrongtypeerr);
addReplyErrorObject(c,shared.wrongtypeerr);
return;
}

View File

@ -294,7 +294,7 @@ void linsertCommand(client *c) {
} else if (strcasecmp(c->argv[2]->ptr,"before") == 0) {
where = LIST_HEAD;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -373,7 +373,7 @@ void lsetCommand(client *c) {
int replaced = quicklistReplaceAtIndex(ql, index,
value->ptr, sdslen(value->ptr));
if (!replaced) {
addReply(c,shared.outofrangeerr);
addReplyErrorObject(c,shared.outofrangeerr);
} else {
addReply(c,shared.ok);
signalModifiedKey(c,c->db,c->argv[1]);
@ -566,7 +566,7 @@ void lposCommand(client *c) {
return;
}
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -698,7 +698,7 @@ int getListPositionFromObjectOrReply(client *c, robj *arg, int *position) {
} else if (strcasecmp(arg->ptr,"left") == 0) {
*position = LIST_HEAD;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return C_ERR;
}
return C_OK;

View File

@ -605,7 +605,7 @@ void spopCommand(client *c) {
spopWithCountCommand(c);
return;
} else if (c->argc > 3) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -801,7 +801,7 @@ void srandmemberCommand(client *c) {
srandmemberWithCountCommand(c);
return;
} else if (c->argc > 3) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}

View File

@ -1534,7 +1534,7 @@ void xrangeGenericCommand(client *c, int rev) {
if (count < 0) count = 0;
j++; /* Consume additional arg. */
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -1643,14 +1643,14 @@ void xreadCommand(client *c) {
}
noack = 1;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
/* STREAMS option is mandatory. */
if (streams_arg == 0) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2076,8 +2076,7 @@ NULL
notifyKeyspaceEvent(NOTIFY_STREAM,"xgroup-create",
c->argv[2],c->db->id);
} else {
addReplySds(c,
sdsnew("-BUSYGROUP Consumer Group name already exists\r\n"));
addReplyError(c,"-BUSYGROUP Consumer Group name already exists");
}
} else if (!strcasecmp(opt,"SETID") && c->argc == 5) {
streamID id;
@ -2237,7 +2236,7 @@ void xpendingCommand(client *c) {
/* Start and stop, and the consumer, can be omitted. Also the IDLE modifier. */
if (c->argc != 3 && (c->argc < 6 || c->argc > 9)) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2251,7 +2250,7 @@ void xpendingCommand(client *c) {
return;
if (c->argc < 8) {
/* If IDLE was provided we must have at least 'start end count' */
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
/* Search for rest of arguments after 'IDLE <idle>' */
@ -2758,7 +2757,7 @@ void xtrimCommand(client *c) {
i++;
maxlen_arg_idx = i;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}

View File

@ -153,7 +153,7 @@ void setCommand(client *c) {
expire = next;
j++;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -528,7 +528,7 @@ void stralgoCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"lcs")) {
stralgoLCS(c);
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
}
}
@ -589,7 +589,7 @@ void stralgoLCS(client *c) {
b = objb->ptr;
j += 2;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
goto cleanup;
}
}

View File

@ -1701,7 +1701,7 @@ void zaddGenericCommand(client *c, int flags) {
* we expect any number of score-element pairs. */
elements = c->argc-scoreidx;
if (elements % 2 || !elements) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
elements /= 2; /* Now this holds the number of score-element pairs. */
@ -2525,7 +2525,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
/* test if the expected number of keys would overflow */
if (setnum > (c->argc-(numkeysIndex+1))) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2536,7 +2536,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
if (obj != NULL) {
if (obj->type != OBJ_ZSET && obj->type != OBJ_SET) {
zfree(src);
addReply(c,shared.wrongtypeerr);
addReplyErrorObject(c,shared.wrongtypeerr);
return;
}
@ -2582,7 +2582,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
aggregate = REDIS_AGGR_MAX;
} else {
zfree(src);
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
j++; remaining--;
@ -2594,7 +2594,7 @@ void zunionInterDiffGenericCommand(client *c, robj *dstkey, int numkeysIndex, in
withscores = 1;
} else {
zfree(src);
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -2793,7 +2793,7 @@ void zrangeGenericCommand(client *c, int reverse) {
if (c->argc == 5 && !strcasecmp(c->argv[4]->ptr,"withscores")) {
withscores = 1;
} else if (c->argc >= 5) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
@ -2938,7 +2938,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
}
pos += 3; remaining -= 3;
} else {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -3289,7 +3289,7 @@ void genericZrangebylexCommand(client *c, int reverse) {
pos += 3; remaining -= 3;
} else {
zslFreeLexRange(&range);
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
}
@ -3632,7 +3632,7 @@ void genericZpopCommand(client *c, robj **keyv, int keyc, int where, int emitkey
/* ZPOPMIN key [<count>] */
void zpopminCommand(client *c) {
if (c->argc > 3) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
genericZpopCommand(c,&c->argv[1],1,ZSET_MIN,0,
@ -3642,7 +3642,7 @@ void zpopminCommand(client *c) {
/* ZMAXPOP key [<count>] */
void zpopmaxCommand(client *c) {
if (c->argc > 3) {
addReply(c,shared.syntaxerr);
addReplyErrorObject(c,shared.syntaxerr);
return;
}
genericZpopCommand(c,&c->argv[1],1,ZSET_MAX,0,