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

Summary: correct error checks for pthread functions
Product: SDL Reporter: Andreas Wiese <aw-libsdl>
Component: threadAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus, sezeroz
Version: HG 2.1   
Hardware: All   
OS: Linux   
Attachments: fix pthread return checks

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.