#36038 util: remove usage of `strerror_s/r`

full analysis

https://github.com/bitcoin/bitcoin/pull/36038 · fanquake · +7/-67 in 8 files, 2 commits · labels: Utils/log/libs

Goal

  • Simplify operating system error code formatting across platforms
  • Remove custom platform branching and build configuration checks

Replaces platform-specific strerror_r, strerror_s, and Win32 FormatMessageA error string logic in SysErrorString with standard C++ std::system_category().message(err). It also drops Win32ErrorString by routing callers to SysErrorString, and removes the STRERROR_R_CHAR_P CMake introspection check and the corresponding linter exception.

Problem: The node previously maintained custom multi-platform branching (POSIX vs. GNU strerror_r, Windows strerror_s, and Win32 FormatMessageA) to safely format OS error codes, requiring dedicated CMake configuration probes.

Category: Utilities (logging, arguments, libraries) (#62 of 66)

P4 · cleanup

  • P4 because it is an internal cleanup with no performance, stability, or user-visible impact
  • Simplifies cross-platform error string handling while keeping behavior effectively unchanged

P4 because it is an internal code simplification with no stated performance, stability, or user-facing impact. It collapses platform-specific formatting branches into std::system_category().message, but leaves SysErrorString behavior effectively unchanged.

Membership: Directly refactors error formatting utilities in src/util/syserror.{cpp,h} and consolidates Win32 error formatting.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0

Reviewability: Ready

  • Ready for review: passes CI and has no unresolved questions

Branch is rebased, passes CI, and has no unresolved questions.

Author status: active

Resolved concerns:

  • Comment indentation style in syserror.h was addressed per a nit from maflcko.

Agreement: Crickets

  • No substantive reviews or concept comments yet
  • Resolved a documentation formatting nit (maflcko)

No substantive reviews or concept comments yet; one styling nit resolved (maflcko).

The only comment is a documentation formatting nit from maflcko that was addressed, and nits do not count as overall reviews.

  • maflcko left a formatting nit on syserror.h doxygen comments, which fanquake resolved in a subsequent push.

Review verdicts (DrahtBot): 0

Files

1 lines under test/bench/ci.

  • src/util/syserror.cpp +2/-40
  • cmake/introspection.cmake +0/-12
  • src/util/syserror.h +2/-8
  • cmake/bitcoin-build-config.h.in +0/-3
  • src/util/fs.cpp +1/-1
  • src/util/fs_helpers.cpp +1/-1
  • src/util/sock.cpp +1/-1
  • test/lint/lint-locale-dependence.py +0/-1

Card

PR #36038 simplifies system error formatting by replacing custom platform-specific wrappers around strerror_r, strerror_s, and Win32 FormatMessageA with std::system_category().message(err). This consolidates Win32ErrorString into SysErrorString and removes an obsolete CMake introspection probe. It is a minor internal utility cleanup with no behavioral or performance impact. The PR is ready for review with clean CI, but has not received substantive reviews yet.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:22, confidence high, input hash c782c397fb5c794f