Fix const-ness of strrchr callers.
This causes build failures in google3 where they use GCC. glibc only
provides const-correct overloads for string functions for GCC >= 4.4,
but clang -- which is what we use -- pretends to be GCC 4.2.
Change-Id: I2a054823ea6201ebcea46d5e77b80a975eefc622
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index cd3c7bc..6fa6c2e 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -72,16 +72,17 @@
return result;
}
-int mkdirs(const char *path)
-{
+int mkdirs(const std::string& path) {
+ // TODO: rewrite this function and merge it with the *other* mkdirs in adb.
+ std::unique_ptr<char> path_rw(strdup(path.c_str()));
int ret;
- char *x = (char *)path + 1;
+ char* x = path_rw.get() + 1;
for(;;) {
- x = adb_dirstart(x);
+ x = const_cast<char*>(adb_dirstart(x));
if(x == 0) return 0;
*x = 0;
- ret = adb_mkdir(path, 0775);
+ ret = adb_mkdir(path_rw.get(), 0775);
*x = OS_PATH_SEPARATOR;
if((ret < 0) && (errno != EEXIST)) {
return ret;