Skip to content

Commit

Permalink
Move line end = totlen - 1, after totlen declared
Browse files Browse the repository at this point in the history
Signed-off-by: LiiNen <kjeonghoon065@gmail.com>
  • Loading branch information
LiiNen committed Apr 1, 2024
1 parent 8d20b4b commit 92f61df
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/bitops.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,6 @@ void bitcountCommand(client *c) {
if (getLongLongFromObjectOrReply(c,c->argv[3],&end,NULL) != C_OK)
return;
}
else if (c->argc < 4) {
end = totlen-1;
}

/* Lookup, check for type. */
o = lookupKeyRead(c->db, c->argv[1]);
Expand All @@ -831,13 +828,14 @@ void bitcountCommand(client *c) {
/* Make sure we will not overflow */
serverAssert(totlen <= LLONG_MAX >> 3);

if (c->argc < 4) end = totlen-1;

/* Convert negative indexes */
if (start < 0 && end < 0 && start > end) {
addReply(c,shared.czero);
return;
}
if (isbit) totlen <<= 3;
/* Convert negative indexes */
if (start < 0) start = totlen+start;
if (end < 0) end = totlen+end;
if (start < 0) start = 0;
Expand Down Expand Up @@ -928,9 +926,6 @@ void bitposCommand(client *c) {
return;
end_given = 1;
}
else if (c->argc < 5) {
end = totlen-1;
}

/* Lookup, check for type. */
o = lookupKeyRead(c->db, c->argv[1]);
Expand All @@ -941,6 +936,8 @@ void bitposCommand(client *c) {
long long totlen = strlen;
serverAssert(totlen <= LLONG_MAX >> 3);

if (c->argc < 5) end = totlen-1;

if (isbit) totlen <<= 3;
/* Convert negative indexes */
if (start < 0) start = totlen+start;
Expand Down

0 comments on commit 92f61df

Please sign in to comment.