From c846cd27f912e50a252872d5dfae8ebaa4f823c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Tue, 13 Aug 2024 12:39:51 +0200 Subject: [PATCH] Correcting -Wwrite-strings warnings in cluster tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Svensson --- tests/clusterclient.c | 2 +- tests/ct_async_glib.c | 4 ++-- tests/ct_connection.c | 4 ++-- tests/ct_out_of_memory_handling.c | 12 ++++++------ tests/ct_pipeline.c | 2 +- tests/ct_specific_nodes.c | 14 +++++++------- tests/ut_parse_cmd.c | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/clusterclient.c b/tests/clusterclient.c index 15029095..8e51740b 100644 --- a/tests/clusterclient.c +++ b/tests/clusterclient.c @@ -43,7 +43,7 @@ void printReply(const valkeyReply *reply) { void eventCallback(const valkeyClusterContext *cc, int event, void *privdata) { (void)cc; (void)privdata; - char *e = NULL; + const char *e; switch (event) { case VALKEYCLUSTER_EVENT_SLOTMAP_UPDATED: e = "slotmap-updated"; diff --git a/tests/ct_async_glib.c b/tests/ct_async_glib.c index fb1609f4..88bbdb47 100644 --- a/tests/ct_async_glib.c +++ b/tests/ct_async_glib.c @@ -53,10 +53,10 @@ int main(int argc, char **argv) { valkeyClusterAsyncSetConnectCallback(acc, connectCallback); valkeyClusterAsyncSetDisconnectCallback(acc, disconnectCallback); - status = valkeyClusterAsyncCommand(acc, setCallback, "id", "SET key value"); + status = valkeyClusterAsyncCommand(acc, setCallback, (char*)"id", "SET key value"); ASSERT_MSG(status == VALKEY_OK, acc->errstr); - status = valkeyClusterAsyncCommand(acc, getCallback, "id", "GET key"); + status = valkeyClusterAsyncCommand(acc, getCallback, (char*)"id", "GET key"); ASSERT_MSG(status == VALKEY_OK, acc->errstr); g_main_loop_run(mainloop); diff --git a/tests/ct_connection.c b/tests/ct_connection.c index feefdc29..f108b3c7 100644 --- a/tests/ct_connection.c +++ b/tests/ct_connection.c @@ -306,10 +306,10 @@ void test_command_timeout_set_while_connected(void) { //------------------------------------------------------------------------------ typedef struct ExpectedResult { int type; - char *str; + const char *str; bool disconnect; bool noreply; - char *errstr; + const char *errstr; } ExpectedResult; // Callback for Valkey connects and disconnects diff --git a/tests/ct_out_of_memory_handling.c b/tests/ct_out_of_memory_handling.c index 64e5618f..e6ef09dc 100644 --- a/tests/ct_out_of_memory_handling.c +++ b/tests/ct_out_of_memory_handling.c @@ -202,7 +202,7 @@ void test_alloc_failure_handling(void) { valkeyReply *reply; const char *cmd = "SET key value"; - valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, "key"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, (char*)"key"); assert(node); // OOM failing commands @@ -265,7 +265,7 @@ void test_alloc_failure_handling(void) { valkeyReply *reply; const char *cmd = "SET foo one"; - valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, "foo"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, (char*)"foo"); assert(node); // OOM failing appends @@ -313,8 +313,8 @@ void test_alloc_failure_handling(void) { prepare_allocation_test(cc, 1000); /* Get the source information for the migration. */ - unsigned int slot = valkeyClusterGetSlotByKey("foo"); - valkeyClusterNode *srcNode = valkeyClusterGetNodeByKey(cc, "foo"); + unsigned int slot = valkeyClusterGetSlotByKey((char*)"foo"); + valkeyClusterNode *srcNode = valkeyClusterGetNodeByKey(cc, (char*)"foo"); int srcPort = srcNode->port; /* Get a destination node to migrate the slot to. */ @@ -371,7 +371,7 @@ void test_alloc_failure_handling(void) { * allowing a high number of allocations. */ prepare_allocation_test(cc, 1000); /* Fetch the nodes again, in case the slotmap has been reloaded. */ - srcNode = valkeyClusterGetNodeByKey(cc, "foo"); + srcNode = valkeyClusterGetNodeByKey(cc, (char*)"foo"); dstNode = getNodeByPort(cc, dstPort); reply = valkeyClusterCommandToNode( cc, srcNode, "CLUSTER SETSLOT %d NODE %s", slot, replyDstId->str); @@ -442,7 +442,7 @@ void test_alloc_failure_handling(void) { typedef struct ExpectedResult { int type; - char *str; + const char *str; bool disconnect; } ExpectedResult; diff --git a/tests/ct_pipeline.c b/tests/ct_pipeline.c index ca86fdf7..da3299ea 100644 --- a/tests/ct_pipeline.c +++ b/tests/ct_pipeline.c @@ -63,7 +63,7 @@ void test_pipeline(void) { typedef struct ExpectedResult { int type; - char *str; + const char *str; bool disconnect; } ExpectedResult; diff --git a/tests/ct_specific_nodes.c b/tests/ct_specific_nodes.c index b30c0e85..c5c43b23 100644 --- a/tests/ct_specific_nodes.c +++ b/tests/ct_specific_nodes.c @@ -45,7 +45,7 @@ void test_command_to_all_nodes(valkeyClusterContext *cc) { void test_transaction(valkeyClusterContext *cc) { - valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, "foo"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, (char*)"foo"); assert(node); valkeyReply *reply; @@ -73,7 +73,7 @@ void test_streams(valkeyClusterContext *cc) { char *id; /* Get the node that handles given stream */ - valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, "mystream"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, (char*)"mystream"); assert(node); /* Preparation: remove old stream/key */ @@ -82,7 +82,7 @@ void test_streams(valkeyClusterContext *cc) { freeReplyObject(reply); /* Query wrong node */ - valkeyClusterNode *wrongNode = valkeyClusterGetNodeByKey(cc, "otherstream"); + valkeyClusterNode *wrongNode = valkeyClusterGetNodeByKey(cc, (char*)"otherstream"); assert(node != wrongNode); reply = valkeyClusterCommandToNode(cc, wrongNode, "XLEN mystream"); CHECK_REPLY_ERROR(cc, reply, "MOVED"); @@ -235,7 +235,7 @@ void test_pipeline_transaction(valkeyClusterContext *cc) { int status; valkeyReply *reply; - valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, "foo"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(cc, (char*)"foo"); assert(node); status = valkeyClusterAppendCommandToNode(cc, node, "MULTI"); @@ -274,11 +274,11 @@ void test_pipeline_transaction(valkeyClusterContext *cc) { //------------------------------------------------------------------------------ typedef struct ExpectedResult { int type; - char *str; + const char *str; size_t elements; bool disconnect; bool noreply; - char *errstr; + const char *errstr; } ExpectedResult; // Callback for Valkey connects and disconnects @@ -487,7 +487,7 @@ void test_async_transaction(void) { status = valkeyClusterLibeventAttach(acc, base); assert(status == VALKEY_OK); - valkeyClusterNode *node = valkeyClusterGetNodeByKey(acc->cc, "foo"); + valkeyClusterNode *node = valkeyClusterGetNodeByKey(acc->cc, (char*)"foo"); assert(node); ExpectedResult r1 = {.type = VALKEY_REPLY_STATUS, .str = "OK"}; diff --git a/tests/ut_parse_cmd.c b/tests/ut_parse_cmd.c index d9637dde..d95b92c7 100644 --- a/tests/ut_parse_cmd.c +++ b/tests/ut_parse_cmd.c @@ -10,7 +10,7 @@ #include /* Helper for the macro ASSERT_KEY below. */ -void check_key(char *key, struct cmd *command, char *file, int line) { +void check_key(const char *key, struct cmd *command, const char *file, int line) { if (command->result != CMD_PARSE_OK) { fprintf(stderr, "%s:%d: Command parsing failed: %s\n", file, line, command->errstr);