Merge "Remove unused String8::setPathName." am: 40a0664b84 am: 5f7d548dc6 am: 941b1a61b0 am: 5c5854a383

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1765465

Change-Id: Ia505c88c596169a47e07c5f8fb869c0de68b42c2
This commit is contained in:
Elliott Hughes 2021-07-14 22:15:41 +00:00 committed by Automerger Merge Worker
commit 5814506607
3 changed files with 7 additions and 26 deletions

View file

@ -431,24 +431,17 @@ void String8::toLower()
// ---------------------------------------------------------------------------
// Path functions
void String8::setPathName(const char* name)
{
setPathName(name, strlen(name));
}
void String8::setPathName(const char* name, size_t len)
{
char* buf = lockBuffer(len);
static void setPathName(String8& s, const char* name) {
size_t len = strlen(name);
char* buf = s.lockBuffer(len);
memcpy(buf, name, len);
// remove trailing path separator, if present
if (len > 0 && buf[len-1] == OS_PATH_SEPARATOR)
len--;
if (len > 0 && buf[len - 1] == OS_PATH_SEPARATOR) len--;
buf[len] = '\0';
unlockBuffer(len);
s.unlockBuffer(len);
}
String8 String8::getPathLeaf(void) const
@ -561,7 +554,7 @@ String8& String8::appendPath(const char* name)
size_t len = length();
if (len == 0) {
// no existing filename, just use the new one
setPathName(name);
setPathName(*this, name);
return *this;
}
@ -581,7 +574,7 @@ String8& String8::appendPath(const char* name)
return *this;
} else {
setPathName(name);
setPathName(*this, name);
return *this;
}
}

View file

@ -89,10 +89,6 @@ std::vector<std::function<void(FuzzedDataProvider*, android::String8*, android::
str1->walkPath(path_out_str.get());
path_out_str->clear();
},
[](FuzzedDataProvider* dataProvider, android::String8* str1,
android::String8*) -> void {
str1->setPathName(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
},
[](FuzzedDataProvider* dataProvider, android::String8* str1,
android::String8*) -> void {
str1->appendPath(dataProvider->ConsumeBytesWithTerminator<char>(5).data());

View file

@ -136,14 +136,6 @@ public:
* These methods operate on the string as if it were a path name.
*/
/*
* Set the filename field to a specific value.
*
* Normalizes the filename, removing a trailing '/' if present.
*/
void setPathName(const char* name);
void setPathName(const char* name, size_t numChars);
/*
* Get just the filename component.
*