Re: [PATCH] maintenance: compare output of pthread functions for inequality with 0
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Dec 2, 2022, 20:55 UTC
- Message-ID
- <Y4pl5BzQnw0Fm+5S@tapette.crustytoothpaste.net>
- In-Reply-To
- <221202.86k039fz7x.gmgdl@evledraar.gmail.com>
On 2022-12-02 at 18:10:57, Ævar Arnfjörð Bjarmason wrote:
Show 12 quoted lines
> > But (and especially if you're interested) we really should follow-up > here and fix the "error()" etc. part of this. After this we have cases > in-tree where we on failure: > > * Call die_errno() (good) > * Call die(), error() etc., but with a manual strerror() argument, > these should just use the *_errno() helper. > * Don't report on the errno at all, e.g. in this case shown here. > > It seems to me that all of these should be using die_errno(), > error_errno() etc.
Actually, I don't think that's correct.
> Or maybe it's the other way around, and we should not rely on the global
> "errno", but always capture the return value, and give that to
> strerror() (or set "errno = ret", and call {die,error,warning}_errno()).Yeah, I think we need to do this. That's because unlike most other functions, the pthread functions _don't_ set errno, and instead return the error value. That's why on a typical Unix system, we would have never failed before this patch: because errno values are always positive.
-- brian m. carlson (he/him or they/them) Toronto, Ontario, CA