Skip to content

Commit

Permalink
Correcting -Wwrite-strings warnings in cluster tests
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Aug 13, 2024
1 parent 72dfb21 commit c846cd2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/clusterclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions tests/ct_async_glib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/ct_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/ct_out_of_memory_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -442,7 +442,7 @@ void test_alloc_failure_handling(void) {

typedef struct ExpectedResult {
int type;
char *str;
const char *str;
bool disconnect;
} ExpectedResult;

Expand Down
2 changes: 1 addition & 1 deletion tests/ct_pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void test_pipeline(void) {

typedef struct ExpectedResult {
int type;
char *str;
const char *str;
bool disconnect;
} ExpectedResult;

Expand Down
14 changes: 7 additions & 7 deletions tests/ct_specific_nodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"};
Expand Down
2 changes: 1 addition & 1 deletion tests/ut_parse_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <string.h>

/* 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);
Expand Down

0 comments on commit c846cd2

Please sign in to comment.