From d03851e54999c11076468d61e85d343972a99942 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Mon, 19 Jul 2021 20:19:44 +0000 Subject: [PATCH] Revert "Revert "Remove unused String8::setPathName."" This reverts commit 70d9fb63e60392d1e3f59cc2967f3247a0645e6c. Reason for revert: Outstanding usage of this method removed internally Change-Id: Idcc00ec261aa1d97f11e47abdb08b10a37b5d20f Test: Local build; treehugger (which I'll manually confirm runs on the appropriate targets) --- libutils/String8.cpp | 21 +++++++-------------- libutils/String8_fuzz.cpp | 4 ---- libutils/include/utils/String8.h | 8 -------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/libutils/String8.cpp b/libutils/String8.cpp index 195e122c6..8511da9ce 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -429,24 +429,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 @@ -559,7 +552,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; } @@ -579,7 +572,7 @@ String8& String8::appendPath(const char* name) return *this; } else { - setPathName(name); + setPathName(*this, name); return *this; } } diff --git a/libutils/String8_fuzz.cpp b/libutils/String8_fuzz.cpp index a45d67514..faf49b66b 100644 --- a/libutils/String8_fuzz.cpp +++ b/libutils/String8_fuzz.cpp @@ -89,10 +89,6 @@ std::vectorwalkPath(path_out_str.get()); path_out_str->clear(); }, - [](FuzzedDataProvider* dataProvider, android::String8* str1, - android::String8*) -> void { - str1->setPathName(dataProvider->ConsumeBytesWithTerminator(5).data()); - }, [](FuzzedDataProvider* dataProvider, android::String8* str1, android::String8*) -> void { str1->appendPath(dataProvider->ConsumeBytesWithTerminator(5).data()); diff --git a/libutils/include/utils/String8.h b/libutils/include/utils/String8.h index cee5dc640..8b2dcf9a0 100644 --- a/libutils/include/utils/String8.h +++ b/libutils/include/utils/String8.h @@ -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. *