summaryrefslogtreecommitdiff
path: root/src/hyperloglog.c
diff options
context:
space:
mode:
authorMadelyn Olson <34459052+madolson@users.noreply.github.com>2020-12-23 19:06:25 -0800
committerGitHub <noreply@github.com>2020-12-23 19:06:25 -0800
commitefaf09ee4b6437c69c467acdb0c62a510207e993 (patch)
treeb8eb22c7360cb9db2959b5cb3f26813698c3a3e7 /src/hyperloglog.c
parent55abd1c6d078e0d30ee01a819f069fa7737c3dc2 (diff)
downloadredis-efaf09ee4b6437c69c467acdb0c62a510207e993.tar.gz
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
Diffstat (limited to 'src/hyperloglog.c')
-rw-r--r--src/hyperloglog.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 648c26a02..75a04227c 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -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;