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

Check for correct return value after call to 'pthread_*' #2808

Open
wants to merge 1 commit into
base: 2.9
Choose a base branch
from

Conversation

havardAasen
Copy link
Contributor

According to man pages, calls to 'pthread_*' can return 'a nonzero value'. This means it can be both negative and positive, we have to check for both.

This commit includes the diff supplied in #2656 and also fixes the same mistake in other files.
Fixes: #2656

@cepelinas9000
Copy link

'pthread_*' functions do not set errno variable.

The error handling is incorrect, reading manuals (for example https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html) there where no mentioning settings errno. But there is macro which sets manually:

// in https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html example
#define handle_error_en(en, msg) \
               do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)

@havardAasen
Copy link
Contributor Author

Right, my bad. I'll update the patch, thanks.

According to man pages, calls to 'pthread_*' can return 'a nonzero value'.
This means it can be both negative and positive, we have to check for
both.
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.

None yet

2 participants