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

Always check the return values from the platform API #305

Open
erlingrj opened this issue Nov 10, 2023 · 1 comment
Open

Always check the return values from the platform API #305

erlingrj opened this issue Nov 10, 2023 · 1 comment
Labels
cleanup good first issue Good for newcomers help wanted Extra attention is needed

Comments

@erlingrj
Copy link
Collaborator

We have to go through our code base and make sure to always check the return values from the platform API.

lf_mutex_lock(env->mutex);

should be

if (lf_mutex_lock(env->mutex) != 0) {
  lf_print_error_and_exit("Failed to lock mutex"); 
};
@erlingrj erlingrj added good first issue Good for newcomers help wanted Extra attention is needed cleanup labels Nov 10, 2023
@erlingrj
Copy link
Collaborator Author

In the enclaves2 branch I have added a macro called LF_ASSERT which you can pass a condition and it will invoke print and terminate if it is false. So we can do LF_ASSERT(lf_mutex_lock(env->mutex) == 0, "Failed to lock mutex"));. The assertions are disabled if LF_NOASSERT is defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant