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

Fix unused variable warning #7393

Closed
wants to merge 1 commit into from
Closed

Conversation

modbw
Copy link
Contributor

@modbw modbw commented Jul 14, 2021

Variable ret is only used in case of USE_THREADS_POSIX. Other cases will issue a warning about unused variable.

#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
int ret;
ret = pthread_mutex_init(&mutex_buf[i], NULL);
Copy link
Member

Choose a reason for hiding this comment

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

👍, nice catch. It does beg the question though, shouldn't we just shorten it to:

if (pthread_mutex_init(&mutex_buf[i], NULL))
  return 0;

..to increase readability?

Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency it would then be nice to eliminate all the ret variables in the file as none of them is used besides for checking call result. Should I update the pull request?

Copy link
Member

Choose a reason for hiding this comment

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

For consistency it would then be nice to eliminate all the ret variables in the file as none of them is used besides for checking call result. Should I update the pull request?

ok

Copy link
Member

Choose a reason for hiding this comment

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

That would be great, let's see what that changeset would look like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the pull request with the suggested changes

@jay jay added the tidy-up label Jul 21, 2021
Update mbedtls_threadlock.c
@bagder bagder closed this in 65c1b8e Aug 8, 2021
@bagder
Copy link
Member

bagder commented Aug 8, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants