From 208a2f67efec244af2de53c1870ab74fee3b0581 Mon Sep 17 00:00:00 2001 From: LiiNen Date: Mon, 1 Apr 2024 23:56:14 +0900 Subject: [PATCH] Move line end = totlen - 1, after totlen declared --- src/bitops.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bitops.c b/src/bitops.c index fa21f08172..035840287f 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -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]); @@ -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; @@ -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]); @@ -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;