MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / SysErrorString

Function SysErrorString

src/util/syserror.cpp:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#endif
19
20std::string SysErrorString(int err) {
21 char buf[1024];
22 /**
23 * Too bad there are three incompatible implementations of the
24 * thread-safe strerror.
25 */
26 const char *s = nullptr;
27#ifdef WIN32
28 if (strerror_s(buf, sizeof(buf), err) == 0) {
29 s = buf;
30 }
31#else
32#ifdef STRERROR_R_CHAR_P
33 /* GNU variant can return a pointer outside the passed buffer */
34 s = strerror_r(err, buf, sizeof(buf));
35#else
36 /* POSIX variant always returns message in buffer */
37 if (strerror_r(err, buf, sizeof(buf)) == 0) {
38 s = buf;
39 }
40#endif
41#endif
42 if (s != nullptr) {
43 return strprintf("%s (%d)", s, err);
44 } else {
45 return strprintf("Unknown error (%d)", err);
46 }
47}
48
49#if defined(WIN32)
50std::string Win32ErrorString(int err) {

Callers 7

CreatePidFileFunction · 0.85
AppInitFunction · 0.85
QueryDefaultGatewayImplFunction · 0.85
FileCommitFunction · 0.85
GetErrorReasonFunction · 0.85
NetworkErrorStringFunction · 0.85
ScheduleBatchPriorityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected