Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
38514e3c
Commit
38514e3c
authored
Mar 23, 2020
by
antirez
Browse files
Minor changes to BITFIELD_RO PR #6951.
parent
493a7f98
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bitops.c
View file @
38514e3c
...
@@ -902,8 +902,8 @@ void bitposCommand(client *c) {
...
@@ -902,8 +902,8 @@ void bitposCommand(client *c) {
* OVERFLOW [WRAP|SAT|FAIL]
* OVERFLOW [WRAP|SAT|FAIL]
*/
*/
#define BITFIELD_
COMMON (1<<0)
#define BITFIELD_
FLAG_NONE 0
#define BITFIELD_READONLY (1<<
1
)
#define BITFIELD_
FLAG_
READONLY
(1<<
0
)
struct
bitfieldOp
{
struct
bitfieldOp
{
uint64_t
offset
;
/* Bitfield offset. */
uint64_t
offset
;
/* Bitfield offset. */
...
@@ -914,6 +914,9 @@ struct bitfieldOp {
...
@@ -914,6 +914,9 @@ struct bitfieldOp {
int
sign
;
/* True if signed, otherwise unsigned op. */
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
)
{
void
bitfieldGeneric
(
client
*
c
,
int
flags
)
{
robj
*
o
;
robj
*
o
;
size_t
bitoffset
;
size_t
bitoffset
;
...
@@ -1002,9 +1005,9 @@ void bitfieldGeneric(client *c, int flags) {
...
@@ -1002,9 +1005,9 @@ void bitfieldGeneric(client *c, int flags) {
return
;
return
;
}
}
}
else
{
}
else
{
if
(
flags
&
BITFIELD_READONLY
)
{
if
(
flags
&
BITFIELD_
FLAG_
READONLY
)
{
zfree
(
ops
);
zfree
(
ops
);
addReplyError
(
c
,
"
bitfield_ro
only support
get
subcommand"
);
addReplyError
(
c
,
"
BITFIELD_RO
only support
the GET
subcommand"
);
return
;
return
;
}
}
...
@@ -1140,9 +1143,9 @@ void bitfieldGeneric(client *c, int flags) {
...
@@ -1140,9 +1143,9 @@ void bitfieldGeneric(client *c, int flags) {
}
}
void
bitfieldCommand
(
client
*
c
)
{
void
bitfieldCommand
(
client
*
c
)
{
bitfieldGeneric
(
c
,
BITFIELD_
COMM
ON
);
bitfieldGeneric
(
c
,
BITFIELD_
FLAG_N
ON
E
);
}
}
void
bitfieldroCommand
(
client
*
c
)
{
void
bitfieldroCommand
(
client
*
c
)
{
bitfieldGeneric
(
c
,
BITFIELD_READONLY
);
bitfieldGeneric
(
c
,
BITFIELD_
FLAG_
READONLY
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment