Page MenuHomePhabricator

util: Replace non-threadsafe strerror
ClosedPublic

Authored by PiRK on May 23 2024, 10:48.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC66e9e23fe2f8: util: Replace non-threadsafe strerror
Summary

Some uses of non-threadsafe strerror have snuck into the code since
they were removed in #4152. Add a wrapper SysErrorString for
thread-safe strerror alternatives and replace all uses of strerror
with this.

Add strerror to the locale-dependence linter to catch its use.
Add an exemption for strerror.cpp (the only allowed use).

Also fix a bug in the regexp so that _r and _s variants are detected
again.

This is a partial backport of core#24933
https://github.com/bitcoin/bitcoin/pull/24933/commits/46971c6dbfbc39ebbc74ab1ed8c00edc12859373
https://github.com/bitcoin/bitcoin/pull/24933/commits/e3a06a3c6cbb288ac89a2725cf71ae8adaebf35c
Depends on D16208 and D16212

Test Plan

ninja all check-all

Check that the linter catches occurences of strerror

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.May 23 2024, 10:48
Fabien requested changes to this revision.May 23 2024, 13:52
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/init.cpp
180 ↗(On Diff #47923)

remove

src/util/syserror.cpp
22 ↗(On Diff #47923)

We are not defining this, it the branch will never be true. This is something that should be fixed before this diff imo

This revision now requires changes to proceed.May 23 2024, 13:52
PiRK edited the summary of this revision. (Show Details)

undo accidental comment change, rebase on D16212 (add as a dependency)

This revision is now accepted and ready to land.May 23 2024, 17:10