Skip to content

Commit

Permalink
fix build on 32bit systems
Browse files Browse the repository at this point in the history
Code had an assert that tests if sizeof(long) == sizeof(long long),
which obviously fails on 32-bit architectures.
I believe the assert is incorrect on any architecture, considering
the following code is actually putting a long long in an _int_.

I replaced it with code that checks if the value fits in an int.

Signed-off-by: Tibault Damman <tibault.damman@basalte.be>
  • Loading branch information
DarthBo authored and JohnSully committed Mar 8, 2024
1 parent d94fdda commit 011fdb4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2608,8 +2608,11 @@ bool readSnapshotBulkPayload(connection *conn, redisMaster *mi, rdbSaveInfo &rsi
if (mi->parseState->depth() != 0)
return false;

static_assert(sizeof(long) == sizeof(long long),"");
rsi.repl_stream_db = mi->parseState->getMetaDataLongLong("repl-stream-db");
long long repl_stream_db = mi->parseState->getMetaDataLongLong("repl-stream-db");
if (repl_stream_db < INT_MIN || repl_stream_db > INT_MAX) {
throw "Invalid repl_stream_db value";
}
rsi.repl_stream_db = static_cast<int>(repl_stream_db);
rsi.repl_offset = mi->parseState->getMetaDataLongLong("repl-offset");
sds str = mi->parseState->getMetaDataStr("repl-id");
if (sdslen(str) == CONFIG_RUN_ID_SIZE) {
Expand Down

0 comments on commit 011fdb4

Please sign in to comment.