Skip to content

Cleanup of internal cluster error functions#93

Merged
bjosv merged 1 commit intovalkey-io:mainfrom
bjosv:cluster-error-refactor
Sep 13, 2024
Merged

Cleanup of internal cluster error functions#93
bjosv merged 1 commit intovalkey-io:mainfrom
bjosv:cluster-error-refactor

Conversation

@bjosv
Copy link
Copy Markdown
Collaborator

@bjosv bjosv commented Sep 11, 2024

Add internal convenience functions to clear errors, and cleanup the internal SetError functions.
The error string for VALKEY_ERR_IO is set by the standalone API, so removing the handling for it in the cluster part.

@bjosv bjosv requested a review from zuiderkwast September 11, 2024 10:31
Comment thread src/cluster.c Outdated
Comment on lines +211 to +212
} else if (str == NULL) { /* No known usecase. Clear previous errstr. */
cc->errstr[0] = '\0';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is never called, we should probably do an assert instead, right?

assert(str != NULL);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have gone through a bit more, and it should be safe to assert.
Keeping the if-check part in case of NDEBUG, which is set by CMake in release builds.

The error string for VALKEY_ERR_IO is set by the standalone API,
so removing the special handling for it.

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
@bjosv bjosv force-pushed the cluster-error-refactor branch from 692410c to e7b0c0f Compare September 12, 2024 07:13
Comment thread src/cluster.c
Comment on lines +205 to +206
assert(str != NULL);
if (str != NULL && str != cc->errstr) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some redundant check there in if...

Suggested change
assert(str != NULL);
if (str != NULL && str != cc->errstr) {
assert(str != NULL);
if (str != cc->errstr) {

@bjosv bjosv merged commit fbbf80e into valkey-io:main Sep 13, 2024
@bjosv bjosv deleted the cluster-error-refactor branch September 13, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants