From f921f716e9f6fde60ba5884defc704da04fa4d8a Mon Sep 17 00:00:00 2001 From: Jacob Murphy Date: Fri, 8 Nov 2024 00:53:45 +0000 Subject: [PATCH] Use sizeof instead of setting last byte manually Signed-off-by: Jacob Murphy --- src/replication.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/replication.c b/src/replication.c index 69e28d44ab..48e98ab8e7 100644 --- a/src/replication.c +++ b/src/replication.c @@ -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; @@ -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;