Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve BLOSC_ERROR_NULL macro #268

Open
oscargm98 opened this issue Mar 16, 2021 · 1 comment
Open

Improve BLOSC_ERROR_NULL macro #268

oscargm98 opened this issue Mar 16, 2021 · 1 comment

Comments

@oscargm98
Copy link
Contributor

  • It would be interesting to modify the BLOSC_ERROR_NULL macro so that it gives more descriptive error messages in this way:
    #define BLOSC_ERROR_NULL(pointer, rc)
    do {
    if (pointer == NULL) {
    BLOSC_TRACE_ERROR("Pointer %s is NULL", #pointer "");
    return rc;
    }
    } while (0)

It will actually print out the name of the pointer and should keep strings to a minimum.

  • This pattern also exists a lot in the code:
    if (rc < 0) {
    return rc;
    }

So adding a helper for that might be nice too.
And possibly rename BLOSC_ERROR_NULL to match.

#define BLOSC_RETURN_NOTOK(rc)
do {
if (rc < 0) {
return rc;
}
} while (0)

#define BLOSC_ERROR_NULL(pointer, rc)
do {
if (pointer == NULL) {
BLOSC_TRACE_ERROR("Pointer %s is NULL", #pointer "");
return rc;
}
} while (0)

@nmoinvaz nmoinvaz changed the title Improve BLOSC_ERROR_NULL macro (proposed by Nathan Moinvaziri) Improve BLOSC_ERROR_NULL macro Mar 30, 2021
@DimitriPapadopoulos
Copy link
Contributor

BLOSC_ERROR_NULL might be called on variables with the same name, for example:

  BLOSC_ERROR_NULL(context, NULL);

Perhaps, file name (__FILE__) and line (__LINE__) would be more useful

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

No branches or pull requests

2 participants