We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4039 - correct error checks for pthread functions
Summary: correct error checks for pthread functions
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: thread (show other bugs)
Version: HG 2.1
Hardware: All Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-11 07:16 UTC by Andreas Wiese
Modified: 2018-02-18 04:59 UTC (History)
2 users (show)

See Also:


Attachments
fix pthread return checks (2.33 KB, patch)
2018-01-11 07:16 UTC, Andreas Wiese
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Wiese 2018-01-11 07:16:16 UTC
Created attachment 3131 [details]
fix pthread return checks

The pthread threading implementation does some error checks wrong.  Nearly all pthread_*() functions returning int on success are defined to "return zero. Otherwise, an error number is returned to indicate the error", followed by a list of error conditions and their error values as "errno"s.  This does not say anything about the sign of the error codes and indeed, most libc implementations have positive errnos.  Thus correct error checking should not test for ret < 0, but for ret != 0, as otherwise the error check might be noneffective depending on used libc implementation.
Comment 1 Ryan C. Gordon 2018-02-18 04:59:07 UTC
This patch is now https://hg.libsdl.org/SDL/rev/ecddbd9fe6b5, thanks!

--ryan.