Skip to content

Commit

Permalink
fixup: add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv committed Sep 12, 2024
1 parent c31398d commit 692410c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,12 @@ static void valkeyClusterSetError(valkeyClusterContext *cc, int type,
const char *str) {
cc->err = type;

/* Copy error string when possible. */
assert(str != NULL);
if (str != NULL && str != cc->errstr) {
size_t len = strlen(str);
len = len < (sizeof(cc->errstr) - 1) ? len : (sizeof(cc->errstr) - 1);
memcpy(cc->errstr, str, len);
cc->errstr[len] = '\0';
} else if (str == NULL) { /* No known usecase. Clear previous errstr. */
cc->errstr[0] = '\0';
}
}

Expand Down Expand Up @@ -2778,14 +2776,12 @@ static void valkeyClusterAsyncSetError(valkeyClusterAsyncContext *acc, int type,
valkeyClusterSetError(acc->cc, type, str); /* Keep error flags identical. */
acc->err = type;

/* Copy error string when possible. */
assert(str != NULL);
if (str != NULL && str != acc->errstr) {
size_t len = strlen(str);
len = len < (sizeof(acc->errstr) - 1) ? len : (sizeof(acc->errstr) - 1);
memcpy(acc->errstr, str, len);
acc->errstr[len] = '\0';
} else if (str == NULL) { /* No known usecase. Clear previous errstr. */
acc->errstr[0] = '\0';
}
}

Expand Down

0 comments on commit 692410c

Please sign in to comment.