Use ErrnoNumberAsString from libbase
Calling strerror_r is tricky, as glibc provides the GNU version
if _GNU_SOURCE is set, and musl libc only provides the posix version.
Handle the complexity once in libbase and reuse it here.
Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: Id7b600d0cdd5804c75612c4d253637a281d3f0ff
diff --git a/common/utils.cc b/common/utils.cc
index 002e6a0..aa6c6b3 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -38,6 +38,7 @@
#include <utility>
#include <vector>
+#include <android-base/strings.h>
#include <base/callback.h>
#include <base/files/file_path.h>
#include <base/files/file_util.h>
@@ -489,12 +490,6 @@
return partition_name;
}
-string ErrnoNumberAsString(int err) {
- char buf[100];
- buf[0] = '\0';
- return strerror_r(err, buf, sizeof(buf));
-}
-
bool FileExists(const char* path) {
struct stat stbuf;
return 0 == lstat(path, &stbuf);