Skip to content

Commit

Permalink
Use sizeof instead of setting last byte manually
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Murphy <[email protected]>
  • Loading branch information
murphyjacob4 committed Nov 8, 2024
1 parent 5ea9b52 commit f921f71
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -2697,8 +2697,7 @@ static int dualChannelReplHandleEndOffsetResponse(connection *conn, sds *err) {

/* Initiate repl_provisional_primary to act as this replica temp primary until RDB is loaded */
server.repl_provisional_primary.conn = server.repl_transfer_s;
memcpy(server.repl_provisional_primary.replid, primary_replid, CONFIG_RUN_ID_SIZE);
server.repl_provisional_primary.replid[CONFIG_RUN_ID_SIZE] = '\0';
memcpy(server.repl_provisional_primary.replid, primary_replid, sizeof(server.repl_provisional_primary.replid));
server.repl_provisional_primary.reploff = reploffset;
server.repl_provisional_primary.read_reploff = reploffset;
server.repl_provisional_primary.dbid = dbid;
Expand Down Expand Up @@ -4270,8 +4269,7 @@ void replicationResurrectProvisionalPrimary(void) {
/* Create a primary client, but do not initialize the read handler yet, as this replica still has a local buffer to
* drain. */
replicationCreatePrimaryClientWithHandler(server.repl_transfer_s, server.repl_provisional_primary.dbid, NULL);
memcpy(server.primary->replid, server.repl_provisional_primary.replid, CONFIG_RUN_ID_SIZE);
server.primary->replid[CONFIG_RUN_ID_SIZE] = '\0';
memcpy(server.primary->replid, server.repl_provisional_primary.replid, sizeof(server.repl_provisional_primary.replid));
server.primary->reploff = server.repl_provisional_primary.reploff;
server.primary->read_reploff = server.repl_provisional_primary.read_reploff;
server.primary_repl_offset = server.primary->reploff;
Expand Down

0 comments on commit f921f71

Please sign in to comment.