MCPcopy Create free account
hub / github.com/ByConity/ByConity / errnoToString

Function errnoToString

base/common/errnoToString.cpp:6–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6std::string errnoToString(int code, int the_errno)
7{
8 const size_t buf_size = 128;
9 char buf[buf_size];
10#ifndef _GNU_SOURCE
11 int rc = strerror_r(the_errno, buf, buf_size);
12#ifdef __APPLE__
13 if (rc != 0 && rc != EINVAL)
14#else
15 if (rc != 0)
16#endif
17 {
18 std::string tmp = std::to_string(code);
19 const char * code_str = tmp.c_str();
20 const char * unknown_message = "Unknown error ";
21 strcpy(buf, unknown_message);
22 strcpy(buf + strlen(unknown_message), code_str);
23 }
24 return fmt::format("errno: {}, strerror: {}", the_errno, buf);
25#else
26 (void)code;
27 return fmt::format("errno: {}, strerror: {}", the_errno, strerror_r(the_errno, buf, sizeof(buf)));
28#endif
29}

Callers 15

convertHistoryFileFunction · 0.85
ReplxxLineReaderMethod · 0.85
~ReplxxLineReaderMethod · 0.85
addToHistoryMethod · 0.85
executeMethod · 0.85
openEditorMethod · 0.85
setTerminalEchoFunction · 0.85
ReadlineLineReaderMethod · 0.85
mainMethod · 0.85
iterateDirectoryMethod · 0.85
enablePerfEventFunction · 0.85
disablePerfEventFunction · 0.85

Calls 1

to_stringFunction · 0.70

Tested by

no test coverage detected