summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-03-23 11:28:09 +0100
committerantirez <antirez@gmail.com>2020-03-23 11:28:09 +0100
commit38514e3c8dd9ad6c0b788c25afa7db38aa26f5c3 (patch)
tree6205587dfefd88eda46e2f02dd1837f90138137a
parent493a7f9823dae5303208be2de778942815df24ba (diff)
downloadredis-38514e3c8dd9ad6c0b788c25afa7db38aa26f5c3.tar.gz
Minor changes to BITFIELD_RO PR #6951.
-rw-r--r--src/bitops.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bitops.c b/src/bitops.c
index ffb330013..d4e82c937 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -902,8 +902,8 @@ void bitposCommand(client *c) {
* OVERFLOW [WRAP|SAT|FAIL]
*/
-#define BITFIELD_COMMON (1<<0)
-#define BITFIELD_READONLY (1<<1)
+#define BITFIELD_FLAG_NONE 0
+#define BITFIELD_FLAG_READONLY (1<<0)
struct bitfieldOp {
uint64_t offset; /* Bitfield offset. */
@@ -914,6 +914,9 @@ struct bitfieldOp {
int sign; /* True if signed, otherwise unsigned op. */
};
+/* This implements both the BITFIELD command and the BITFIELD_RO command
+ * when flags is set to BITFIELD_FLAG_READONLY: in this case only the
+ * GET subcommand is allowed, other subcommands will return an error. */
void bitfieldGeneric(client *c, int flags) {
robj *o;
size_t bitoffset;
@@ -1002,9 +1005,9 @@ void bitfieldGeneric(client *c, int flags) {
return;
}
} else {
- if (flags & BITFIELD_READONLY) {
+ if (flags & BITFIELD_FLAG_READONLY) {
zfree(ops);
- addReplyError(c, "bitfield_ro only support get subcommand");
+ addReplyError(c, "BITFIELD_RO only support the GET subcommand");
return;
}
@@ -1140,9 +1143,9 @@ void bitfieldGeneric(client *c, int flags) {
}
void bitfieldCommand(client *c) {
- bitfieldGeneric(c, BITFIELD_COMMON);
+ bitfieldGeneric(c, BITFIELD_FLAG_NONE);
}
void bitfieldroCommand(client *c) {
- bitfieldGeneric(c, BITFIELD_READONLY);
+ bitfieldGeneric(c, BITFIELD_FLAG_READONLY);
}