ceph/src/common/errno.cc
Jos Collin 95fc248c40 common: Remove redundant includes
Fixes: http://tracker.ceph.com/issues/19883 (Partially)

Signed-off-by: Jos Collin <jcollin@redhat.com>
2017-05-24 06:53:40 +05:30

29 lines
504 B
C++

#include "common/errno.h"
#include "acconfig.h"
#include <sstream>
#include <string.h>
std::string cpp_strerror(int err)
{
char buf[128];
char *errmsg;
if (err < 0)
err = -err;
std::ostringstream oss;
buf[0] = '\0';
// strerror_r returns char * on Linux, and does not always fill buf
#ifdef STRERROR_R_CHAR_P
errmsg = strerror_r(err, buf, sizeof(buf));
#else
strerror_r(err, buf, sizeof(buf));
errmsg = buf;
#endif
oss << "(" << err << ") " << errmsg;
return oss.str();
}