]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/errno.cc
update sources to v12.1.0
[ceph.git] / ceph / src / common / errno.cc
CommitLineData
7c673cae
FG
1#include "common/errno.h"
2#include "acconfig.h"
3
4#include <sstream>
7c673cae
FG
5#include <string.h>
6
7std::string cpp_strerror(int err)
8{
9 char buf[128];
10 char *errmsg;
11
12 if (err < 0)
13 err = -err;
14 std::ostringstream oss;
15 buf[0] = '\0';
16
17 // strerror_r returns char * on Linux, and does not always fill buf
18#ifdef STRERROR_R_CHAR_P
19 errmsg = strerror_r(err, buf, sizeof(buf));
20#else
21 strerror_r(err, buf, sizeof(buf));
22 errmsg = buf;
23#endif
24
25 oss << "(" << err << ") " << errmsg;
26
27 return oss.str();
28}