summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/string_view_template.h2
-rw-r--r--samples/pdfium_test.cc10
-rw-r--r--third_party/base/allocator/partition_allocator/partition_alloc.h25
-rw-r--r--third_party/base/numerics/safe_math_impl.h16
4 files changed, 26 insertions, 27 deletions
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 12b422e090..fa33858a68 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -150,7 +150,7 @@ class StringViewTemplate {
}
pdfium::Optional<size_t> Find(CharType ch) const {
- const UnsignedType* found = reinterpret_cast<const UnsignedType*>(FXSYS_chr(
+ const auto* found = reinterpret_cast<const UnsignedType*>(FXSYS_chr(
reinterpret_cast<const CharType*>(m_Ptr.Get()), ch, m_Length));
return found ? pdfium::Optional<size_t>(found - m_Ptr.Get())
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index bc0ad86297..97090cfadf 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -154,7 +154,7 @@ std::string WritePpm(const char* pdf_name,
int stride,
int width,
int height) {
- const char* buffer = reinterpret_cast<const char*>(buffer_void);
+ const auto* buffer = reinterpret_cast<const char*>(buffer_void);
if (!CheckDimensions(stride, width, height))
return "";
@@ -451,7 +451,7 @@ std::string WritePng(const char* pdf_name,
return "";
std::vector<unsigned char> png_encoding;
- const unsigned char* buffer = static_cast<const unsigned char*>(buffer_void);
+ const auto* buffer = static_cast<const unsigned char*>(buffer_void);
if (!image_diff_png::EncodeBGRAPNG(
buffer, width, height, stride, false, &png_encoding)) {
fprintf(stderr, "Failed to convert bitmap to PNG\n");
@@ -644,7 +644,7 @@ int ExampleAppResponse(IPDF_JSPLATFORM*,
GetPlatformWString(label).c_str(), is_password, length);
// UTF-16, always LE regardless of platform.
- uint8_t* ptr = static_cast<uint8_t*>(response);
+ auto* ptr = static_cast<uint8_t*>(response);
ptr[0] = 'N';
ptr[1] = 0;
ptr[2] = 'o';
@@ -1249,8 +1249,8 @@ bool RenderPage(const std::string& name,
if (!options.scale_factor_as_string.empty())
std::stringstream(options.scale_factor_as_string) >> scale;
- int width = static_cast<int>(FPDF_GetPageWidth(page) * scale);
- int height = static_cast<int>(FPDF_GetPageHeight(page) * scale);
+ auto width = static_cast<int>(FPDF_GetPageWidth(page) * scale);
+ auto height = static_cast<int>(FPDF_GetPageHeight(page) * scale);
int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
FPDFBitmap_Create(width, height, alpha));
diff --git a/third_party/base/allocator/partition_allocator/partition_alloc.h b/third_party/base/allocator/partition_allocator/partition_alloc.h
index 285f2af5a4..04ae17014a 100644
--- a/third_party/base/allocator/partition_allocator/partition_alloc.h
+++ b/third_party/base/allocator/partition_allocator/partition_alloc.h
@@ -534,7 +534,7 @@ ALWAYS_INLINE void* PartitionCookieFreePointerAdjust(void* ptr) {
ALWAYS_INLINE void PartitionCookieWriteValue(void* ptr) {
#if DCHECK_IS_ON()
- unsigned char* cookie_ptr = reinterpret_cast<unsigned char*>(ptr);
+ auto* cookie_ptr = reinterpret_cast<unsigned char*>(ptr);
for (size_t i = 0; i < kCookieSize; ++i, ++cookie_ptr)
*cookie_ptr = kCookieValue[i];
#endif
@@ -542,14 +542,14 @@ ALWAYS_INLINE void PartitionCookieWriteValue(void* ptr) {
ALWAYS_INLINE void PartitionCookieCheckValue(void* ptr) {
#if DCHECK_IS_ON()
- unsigned char* cookie_ptr = reinterpret_cast<unsigned char*>(ptr);
+ auto* cookie_ptr = reinterpret_cast<unsigned char*>(ptr);
for (size_t i = 0; i < kCookieSize; ++i, ++cookie_ptr)
DCHECK(*cookie_ptr == kCookieValue[i]);
#endif
}
ALWAYS_INLINE char* PartitionSuperPageToMetadataArea(char* ptr) {
- uintptr_t pointer_as_uint = reinterpret_cast<uintptr_t>(ptr);
+ auto pointer_as_uint = reinterpret_cast<uintptr_t>(ptr);
DCHECK(!(pointer_as_uint & kSuperPageOffsetMask));
// The metadata area is exactly one system page (the guard page) into the
// super page.
@@ -557,8 +557,8 @@ ALWAYS_INLINE char* PartitionSuperPageToMetadataArea(char* ptr) {
}
ALWAYS_INLINE PartitionPage* PartitionPointerToPageNoAlignmentCheck(void* ptr) {
- uintptr_t pointer_as_uint = reinterpret_cast<uintptr_t>(ptr);
- char* super_page_ptr =
+ auto pointer_as_uint = reinterpret_cast<uintptr_t>(ptr);
+ auto* super_page_ptr =
reinterpret_cast<char*>(pointer_as_uint & kSuperPageBaseMask);
uintptr_t partition_page_index =
(pointer_as_uint & kSuperPageOffsetMask) >> kPartitionPageShift;
@@ -566,7 +566,7 @@ ALWAYS_INLINE PartitionPage* PartitionPointerToPageNoAlignmentCheck(void* ptr) {
// the last index is invalid because it is a guard page.
DCHECK(partition_page_index);
DCHECK(partition_page_index < kNumPartitionPagesPerSuperPage - 1);
- PartitionPage* page = reinterpret_cast<PartitionPage*>(
+ auto* page = reinterpret_cast<PartitionPage*>(
PartitionSuperPageToMetadataArea(super_page_ptr) +
(partition_page_index << kPageMetadataShift));
// Partition pages in the same slot span can share the same page object.
@@ -578,7 +578,7 @@ ALWAYS_INLINE PartitionPage* PartitionPointerToPageNoAlignmentCheck(void* ptr) {
}
ALWAYS_INLINE void* PartitionPageToPointer(const PartitionPage* page) {
- uintptr_t pointer_as_uint = reinterpret_cast<uintptr_t>(page);
+ auto pointer_as_uint = reinterpret_cast<uintptr_t>(page);
uintptr_t super_page_offset = (pointer_as_uint & kSuperPageOffsetMask);
DCHECK(super_page_offset > kSystemPageSize);
DCHECK(super_page_offset < kSystemPageSize + (kNumPartitionPagesPerSuperPage *
@@ -590,7 +590,7 @@ ALWAYS_INLINE void* PartitionPageToPointer(const PartitionPage* page) {
DCHECK(partition_page_index);
DCHECK(partition_page_index < kNumPartitionPagesPerSuperPage - 1);
uintptr_t super_page_base = (pointer_as_uint & kSuperPageBaseMask);
- void* ret = reinterpret_cast<void*>(
+ auto* ret = reinterpret_cast<void*>(
super_page_base + (partition_page_index << kPartitionPageShift));
return ret;
}
@@ -641,9 +641,8 @@ ALWAYS_INLINE size_t PartitionPageGetRawSize(PartitionPage* page) {
}
ALWAYS_INLINE PartitionRootBase* PartitionPageToRoot(PartitionPage* page) {
- PartitionSuperPageExtentEntry* extent_entry =
- reinterpret_cast<PartitionSuperPageExtentEntry*>(
- reinterpret_cast<uintptr_t>(page) & kSystemPageBaseMask);
+ auto* extent_entry = reinterpret_cast<PartitionSuperPageExtentEntry*>(
+ reinterpret_cast<uintptr_t>(page) & kSystemPageBaseMask);
return extent_entry->root;
}
@@ -687,7 +686,7 @@ ALWAYS_INLINE void* PartitionBucketAlloc(PartitionRootBase* root,
slot_size = raw_size;
}
size_t no_cookie_size = PartitionCookieSizeAdjustSubtract(slot_size);
- char* char_ret = static_cast<char*>(ret);
+ auto* char_ret = static_cast<char*>(ret);
// The value given to the application is actually just after the cookie.
ret = char_ret + kCookieSize;
memset(ret, kUninitializedByte, no_cookie_size);
@@ -737,7 +736,7 @@ ALWAYS_INLINE void PartitionFreeWithPage(void* ptr, PartitionPage* page) {
CHECK(ptr != freelist_head); // Catches an immediate double free.
// Look for double free one level deeper in debug.
DCHECK(!freelist_head || ptr != PartitionFreelistMask(freelist_head->next));
- PartitionFreelistEntry* entry = static_cast<PartitionFreelistEntry*>(ptr);
+ auto* entry = static_cast<PartitionFreelistEntry*>(ptr);
entry->next = PartitionFreelistMask(freelist_head);
page->freelist_head = entry;
--page->num_allocated_slots;
diff --git a/third_party/base/numerics/safe_math_impl.h b/third_party/base/numerics/safe_math_impl.h
index 5ad79ce192..4bcc67188c 100644
--- a/third_party/base/numerics/safe_math_impl.h
+++ b/third_party/base/numerics/safe_math_impl.h
@@ -59,9 +59,9 @@ bool CheckedAddImpl(T x, T y, T* result) {
// it using the unsigned type of the same size.
using UnsignedDst = typename std::make_unsigned<T>::type;
using SignedDst = typename std::make_signed<T>::type;
- UnsignedDst ux = static_cast<UnsignedDst>(x);
- UnsignedDst uy = static_cast<UnsignedDst>(y);
- UnsignedDst uresult = static_cast<UnsignedDst>(ux + uy);
+ auto ux = static_cast<UnsignedDst>(x);
+ auto uy = static_cast<UnsignedDst>(y);
+ auto uresult = static_cast<UnsignedDst>(ux + uy);
*result = static_cast<T>(uresult);
// Addition is valid if the sign of (x + y) is equal to either that of x or
// that of y.
@@ -110,9 +110,9 @@ bool CheckedSubImpl(T x, T y, T* result) {
// it using the unsigned type of the same size.
using UnsignedDst = typename std::make_unsigned<T>::type;
using SignedDst = typename std::make_signed<T>::type;
- UnsignedDst ux = static_cast<UnsignedDst>(x);
- UnsignedDst uy = static_cast<UnsignedDst>(y);
- UnsignedDst uresult = static_cast<UnsignedDst>(ux - uy);
+ auto ux = static_cast<UnsignedDst>(x);
+ auto uy = static_cast<UnsignedDst>(y);
+ auto uresult = static_cast<UnsignedDst>(ux - uy);
*result = static_cast<T>(uresult);
// Subtraction is valid if either x and y have same sign, or (x-y) and x have
// the same sign.
@@ -163,7 +163,7 @@ bool CheckedMulImpl(T x, T y, T* result) {
using SignedDst = typename std::make_signed<T>::type;
const UnsignedDst ux = SafeUnsignedAbs(x);
const UnsignedDst uy = SafeUnsignedAbs(y);
- UnsignedDst uresult = static_cast<UnsignedDst>(ux * uy);
+ auto uresult = static_cast<UnsignedDst>(ux * uy);
const bool is_negative =
std::is_signed<T>::value && static_cast<SignedDst>(x ^ y) < 0;
*result = is_negative ? 0 - uresult : uresult;
@@ -308,7 +308,7 @@ struct CheckedLshOp<T,
static bool Do(T x, U shift, V* result) {
using ShiftType = typename std::make_unsigned<T>::type;
static const ShiftType kBitWidth = IntegerBitsPlusSign<T>::value;
- const ShiftType real_shift = static_cast<ShiftType>(shift);
+ const auto real_shift = static_cast<ShiftType>(shift);
// Signed shift is not legal on negative values.
if (!IsValueNegative(x) && real_shift < kBitWidth) {
// Just use a multiplication because it's easy.