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

Fix unused variable warning #7393

wants to merge 1 commit into from

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

@danielgustafsson danielgustafsson Jul 14, 2021

👍, 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

@bagder bagder Jul 16, 2021

Seems reasonable to me!

Copy link
Contributor Author

@modbw modbw Jul 16, 2021

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

@jay jay Jul 16, 2021

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

@danielgustafsson danielgustafsson Jul 16, 2021

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

Copy link
Contributor Author

@modbw modbw Jul 21, 2021

I have updated the pull request with the suggested changes

@jay jay added the tidy-up label Jul 21, 2021
Update mbedtls_threadlock.c
@modbw modbw force-pushed the fix-unused-warning branch from 3ea62d6 to 60d655e Jul 21, 2021
jay
jay approved these changes Jul 21, 2021
@bagder bagder closed this in 65c1b8e Aug 8, 2021
@bagder
Copy link
Member

@bagder 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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants