Fix 31 ClangTidy-Readability/Naming findings in core/fxcrt/.
These fixes are automatically created by various analysis tools, but
have been manually triggered to be applied. See go/code-findings-fixes.
* function 'fxcrt::ByteString::FormatFloat' has a definition with
different parameter names
* function 'fxcrt::ByteString::Format' has a definition with different
parameter names
* function 'fxcrt::ByteString::FormatV' has a definition with different
parameter names
* function 'fxcrt::ByteString::ByteString' has a definition with
different parameter names (4 times)
* function 'fxcrt::ByteString::operator=' has a definition with
different parameter names
* function 'fxcrt::ByteString::operator+=' has a definition with
different parameter names
* function 'fxcrt::ByteString::Insert' has a definition with different
parameter names
* function 'fxcrt::ByteString::GetBuffer' has a definition with
different parameter names
* function 'fxcrt::ByteString::ReleaseBuffer' has a definition with
different parameter names
* function 'fxcrt::ByteString::Find' has a definition with different
parameter names
* function 'fxcrt::ByteString::Replace' has a definition with different
parameter names
* function 'fxcrt::ByteString::Concat' has a definition with different
parameter names
* function 'FXSYS_IntToTwoHexChars' has a definition with different
parameter names
* function 'FXSYS_IntToFourHexChars' has a definition with different
parameter names
* function 'FloatToString' has a definition with different parameter
names
* function 'FXSYS_wcsicmp' has a definition with different parameter
names
* function 'FXSYS_round' has a definition with different parameter names
* function 'fxcrt::WideString::Format' has a definition with different
parameter names
* function 'fxcrt::WideString::WideString' has a definition with
different parameter names
* function 'fxcrt::WideString::Compare' has a definition with different
parameter names
* function 'fxcrt::WideString::CompareNoCase' has a definition with
different parameter names
* function 'fxcrt::WideString::Insert' has a definition with different
parameter names
* function 'fxcrt::WideString::GetBuffer' has a definition with
different parameter names
* function 'fxcrt::WideString::ReleaseBuffer' has a definition with
different parameter names
* function 'fxcrt::WideString::Find' has a definition with different
parameter names
* function 'fxcrt::WideString::ReallocBeforeWrite' has a definition
with different parameter names
* function 'fxcrt::WideString::AllocBeforeWrite' has a definition with
different parameter names
* function 'fxcrt::WideString::Concat' has a definition with different
parameter names
PiperOrigin-RevId: 254763038
Change-Id: Ic08dc9cca6916b34ac1257663546db81f75e2a05
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/56833
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 21e2aea..824ec85 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -74,9 +74,9 @@
}
// static
-ByteString ByteString::FormatFloat(float d) {
+ByteString ByteString::FormatFloat(float f) {
char buf[32];
- return ByteString(buf, FloatToString(d, buf));
+ return ByteString(buf, FloatToString(f, buf));
}
// static
@@ -142,10 +142,10 @@
ByteString::ByteString(const char* ptr)
: ByteString(ptr, ptr ? strlen(ptr) : 0) {}
-ByteString::ByteString(ByteStringView stringSrc) {
- if (!stringSrc.IsEmpty())
- m_pData.Reset(StringData::Create(stringSrc.unterminated_c_str(),
- stringSrc.GetLength()));
+ByteString::ByteString(ByteStringView bstrc) {
+ if (!bstrc.IsEmpty())
+ m_pData.Reset(StringData::Create(bstrc.unterminated_c_str(),
+ bstrc.GetLength()));
}
ByteString::ByteString(ByteStringView str1, ByteStringView str2) {
@@ -198,11 +198,11 @@
return *this;
}
-const ByteString& ByteString::operator=(ByteStringView stringSrc) {
- if (stringSrc.IsEmpty())
+const ByteString& ByteString::operator=(ByteStringView bstrc) {
+ if (bstrc.IsEmpty())
clear();
else
- AssignCopy(stringSrc.unterminated_c_str(), stringSrc.GetLength());
+ AssignCopy(bstrc.unterminated_c_str(), bstrc.GetLength());
return *this;
}
@@ -518,16 +518,16 @@
m_pData->m_String[index] = c;
}
-size_t ByteString::Insert(size_t location, char ch) {
+size_t ByteString::Insert(size_t index, char ch) {
const size_t cur_length = GetLength();
- if (!IsValidLength(location))
+ if (!IsValidLength(index))
return cur_length;
const size_t new_length = cur_length + 1;
ReallocBeforeWrite(new_length);
- memmove(m_pData->m_String + location + 1, m_pData->m_String + location,
- new_length - location);
- m_pData->m_String[location] = ch;
+ memmove(m_pData->m_String + index + 1, m_pData->m_String + index,
+ new_length - index);
+ m_pData->m_String[index] = ch;
m_pData->m_nDataLength = new_length;
return new_length;
}
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index f221d25..72d629a 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -37,8 +37,8 @@
static ByteString FormatInteger(int i) WARN_UNUSED_RESULT;
static ByteString FormatFloat(float f) WARN_UNUSED_RESULT;
- static ByteString Format(const char* lpszFormat, ...) WARN_UNUSED_RESULT;
- static ByteString FormatV(const char* lpszFormat,
+ static ByteString Format(const char* pFormat, ...) WARN_UNUSED_RESULT;
+ static ByteString FormatV(const char* pFormat,
va_list argList) WARN_UNUSED_RESULT;
ByteString();
@@ -55,11 +55,11 @@
// NOLINTNEXTLINE(runtime/explicit)
ByteString(wchar_t) = delete;
- ByteString(const char* ptr, size_t len);
- ByteString(const uint8_t* ptr, size_t len);
+ ByteString(const char* pStr, size_t len);
+ ByteString(const uint8_t* pStr, size_t len);
explicit ByteString(ByteStringView bstrc);
- ByteString(ByteStringView bstrc1, ByteStringView bstrc2);
+ ByteString(ByteStringView str1, ByteStringView str2);
ByteString(const std::initializer_list<ByteStringView>& list);
explicit ByteString(const std::ostringstream& outStream);
@@ -139,7 +139,7 @@
const ByteString& operator+=(char ch);
const ByteString& operator+=(const char* str);
const ByteString& operator+=(const ByteString& str);
- const ByteString& operator+=(ByteStringView bstrc);
+ const ByteString& operator+=(ByteStringView str);
CharType operator[](const size_t index) const {
CHECK(IsValidIndex(index));
@@ -160,14 +160,14 @@
// Note: any modification of the string (including ReleaseBuffer()) may
// invalidate the span, which must not outlive its buffer.
- pdfium::span<char> GetBuffer(size_t len);
- void ReleaseBuffer(size_t len);
+ pdfium::span<char> GetBuffer(size_t nMinBufLength);
+ void ReleaseBuffer(size_t nNewLength);
ByteString Mid(size_t first, size_t count) const;
ByteString Left(size_t count) const;
ByteString Right(size_t count) const;
- Optional<size_t> Find(ByteStringView lpszSub, size_t start = 0) const;
+ Optional<size_t> Find(ByteStringView subStr, size_t start = 0) const;
Optional<size_t> Find(char ch, size_t start = 0) const;
Optional<size_t> ReverseFind(char ch) const;
@@ -194,7 +194,7 @@
void TrimRight(char target);
void TrimRight(ByteStringView targets);
- size_t Replace(ByteStringView lpszOld, ByteStringView lpszNew);
+ size_t Replace(ByteStringView pOld, ByteStringView pNew);
size_t Remove(char ch);
uint32_t GetID() const { return AsStringView().GetID(); }
@@ -206,7 +206,7 @@
void AllocBeforeWrite(size_t nNewLen);
void AllocCopy(ByteString& dest, size_t nCopyLen, size_t nCopyIndex) const;
void AssignCopy(const char* pSrcData, size_t nSrcLen);
- void Concat(const char* lpszSrcData, size_t nSrcLen);
+ void Concat(const char* pSrcData, size_t nSrcLen);
intptr_t ReferenceCountForTesting() const;
RetainPtr<StringData> m_pData;
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index 621737e..28b23cf 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -106,8 +106,8 @@
return FXSYS_IsDecimalDigit(c) ? c - L'0' : 0;
}
-void FXSYS_IntToTwoHexChars(uint8_t c, char* buf);
-void FXSYS_IntToFourHexChars(uint16_t c, char* buf);
+void FXSYS_IntToTwoHexChars(uint8_t n, char* buf);
+void FXSYS_IntToFourHexChars(uint16_t n, char* buf);
size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf);
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp
index cb7465e..e41757e 100644
--- a/core/fxcrt/fx_string.cpp
+++ b/core/fxcrt/fx_string.cpp
@@ -89,25 +89,25 @@
return StringToFloat(FX_UTF8Encode(wsStr).c_str());
}
-size_t FloatToString(float d, char* buf) {
+size_t FloatToString(float f, char* buf) {
buf[0] = '0';
buf[1] = '\0';
- if (d == 0.0f) {
+ if (f == 0.0f) {
return 1;
}
bool bNegative = false;
- if (d < 0) {
+ if (f < 0) {
bNegative = true;
- d = -d;
+ f = -f;
}
int scale = 1;
- int scaled = FXSYS_round(d);
+ int scaled = FXSYS_round(f);
while (scaled < 100000) {
if (scale == 1000000) {
break;
}
scale *= 10;
- scaled = FXSYS_round(d * scale);
+ scaled = FXSYS_round(f * scale);
}
if (scaled == 0) {
return 1;
diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp
index abe833d..eabf8f4 100644
--- a/core/fxcrt/fx_system.cpp
+++ b/core/fxcrt/fx_system.cpp
@@ -84,14 +84,14 @@
} // namespace
-int FXSYS_round(float d) {
- if (std::isnan(d))
+int FXSYS_round(float f) {
+ if (std::isnan(f))
return 0;
- if (d < static_cast<float>(std::numeric_limits<int>::min()))
+ if (f < static_cast<float>(std::numeric_limits<int>::min()))
return std::numeric_limits<int>::min();
- if (d > static_cast<float>(std::numeric_limits<int>::max()))
+ if (f > static_cast<float>(std::numeric_limits<int>::max()))
return std::numeric_limits<int>::max();
- return static_cast<int>(round(d));
+ return static_cast<int>(round(f));
}
int32_t FXSYS_atoi(const char* str) {
@@ -181,26 +181,26 @@
return s;
}
-int FXSYS_stricmp(const char* dst, const char* src) {
+int FXSYS_stricmp(const char* str1, const char* str2) {
int f;
int l;
do {
- f = toupper(*dst);
- l = toupper(*src);
- ++dst;
- ++src;
+ f = toupper(*str1);
+ l = toupper(*str2);
+ ++str1;
+ ++str2;
} while (f && f == l);
return f - l;
}
-int FXSYS_wcsicmp(const wchar_t* dst, const wchar_t* src) {
+int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2) {
wchar_t f;
wchar_t l;
do {
- f = FXSYS_towupper(*dst);
- l = FXSYS_towupper(*src);
- ++dst;
- ++src;
+ f = FXSYS_towupper(*str1);
+ l = FXSYS_towupper(*str2);
+ ++str1;
+ ++str2;
} while (f && f == l);
return f - l;
}
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index 246f6c9..6b113c0 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -160,7 +160,7 @@
int buflen);
char* FXSYS_strlwr(char* str);
char* FXSYS_strupr(char* str);
-int FXSYS_stricmp(const char*, const char*);
+int FXSYS_stricmp(const char* str1, const char* str2);
int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2);
wchar_t* FXSYS_wcslwr(wchar_t* str);
wchar_t* FXSYS_wcsupr(wchar_t* str);
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 76d596c..a00ce2d 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -738,16 +738,16 @@
dest.m_pData.Swap(pNewData);
}
-size_t WideString::Insert(size_t location, wchar_t ch) {
+size_t WideString::Insert(size_t index, wchar_t ch) {
const size_t cur_length = GetLength();
- if (!IsValidLength(location))
+ if (!IsValidLength(index))
return cur_length;
const size_t new_length = cur_length + 1;
ReallocBeforeWrite(new_length);
- wmemmove(m_pData->m_String + location + 1, m_pData->m_String + location,
- new_length - location);
- m_pData->m_String[location] = ch;
+ wmemmove(m_pData->m_String + index + 1, m_pData->m_String + index,
+ new_length - index);
+ m_pData->m_String[index] = ch;
m_pData->m_nDataLength = new_length;
return new_length;
}
@@ -941,10 +941,10 @@
m_pData->m_String[index] = c;
}
-int WideString::Compare(const wchar_t* lpsz) const {
+int WideString::Compare(const wchar_t* str) const {
if (m_pData)
- return lpsz ? wcscmp(m_pData->m_String, lpsz) : 1;
- return (!lpsz || lpsz[0] == 0) ? 0 : -1;
+ return str ? wcscmp(m_pData->m_String, str) : 1;
+ return (!str || str[0] == 0) ? 0 : -1;
}
int WideString::Compare(const WideString& str) const {
@@ -964,10 +964,10 @@
return this_len < that_len ? -1 : 1;
}
-int WideString::CompareNoCase(const wchar_t* lpsz) const {
+int WideString::CompareNoCase(const wchar_t* str) const {
if (m_pData)
- return lpsz ? FXSYS_wcsicmp(m_pData->m_String, lpsz) : 1;
- return (!lpsz || lpsz[0] == 0) ? 0 : -1;
+ return str ? FXSYS_wcsicmp(m_pData->m_String, str) : 1;
+ return (!str || str[0] == 0) ? 0 : -1;
}
size_t WideString::WStringLength(const unsigned short* str) {
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index e962de3..ec121ba 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -35,7 +35,7 @@
using const_iterator = const CharType*;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- static WideString Format(const wchar_t* lpszFormat, ...) WARN_UNUSED_RESULT;
+ static WideString Format(const wchar_t* pFormat, ...) WARN_UNUSED_RESULT;
static WideString FormatV(const wchar_t* lpszFormat,
va_list argList) WARN_UNUSED_RESULT;
@@ -53,7 +53,7 @@
// NOLINTNEXTLINE(runtime/explicit)
WideString(char) = delete;
- WideString(const wchar_t* ptr, size_t len);
+ WideString(const wchar_t* pStr, size_t len);
explicit WideString(WideStringView str);
WideString(WideStringView str1, WideStringView str2);
@@ -175,12 +175,12 @@
// Note: any modification of the string (including ReleaseBuffer()) may
// invalidate the span, which must not outlive its buffer.
- pdfium::span<wchar_t> GetBuffer(size_t len);
- void ReleaseBuffer(size_t len);
+ pdfium::span<wchar_t> GetBuffer(size_t nMinBufLength);
+ void ReleaseBuffer(size_t nNewLength);
int GetInteger() const;
- Optional<size_t> Find(WideStringView pSub, size_t start = 0) const;
+ Optional<size_t> Find(WideStringView subStr, size_t start = 0) const;
Optional<size_t> Find(wchar_t ch, size_t start = 0) const;
bool Contains(WideStringView lpszSub, size_t start = 0) const {
@@ -215,11 +215,11 @@
protected:
using StringData = StringDataTemplate<wchar_t>;
- void ReallocBeforeWrite(size_t nLen);
- void AllocBeforeWrite(size_t nLen);
+ void ReallocBeforeWrite(size_t nNewLength);
+ void AllocBeforeWrite(size_t nNewLength);
void AllocCopy(WideString& dest, size_t nCopyLen, size_t nCopyIndex) const;
void AssignCopy(const wchar_t* pSrcData, size_t nSrcLen);
- void Concat(const wchar_t* lpszSrcData, size_t nSrcLen);
+ void Concat(const wchar_t* pSrcData, size_t nSrcLen);
intptr_t ReferenceCountForTesting() const;
RetainPtr<StringData> m_pData;