Enable -Wshorten-64-to-32 warning for core/fxge
Fix a few remaining warnings in the process.
Change-Id: Iaa3e4cd29997a9d8611009c6c62663ed94a8de41
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/88470
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 8ccaf68..7dafd7d 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -10,6 +10,8 @@
visibility = [ ":*" ]
if (is_clang) {
cflags = [
+ "-Wshorten-64-to-32",
+
# http://code.google.com/p/pdfium/issues/detail?id=188
"-Wno-switch",
]
diff --git a/core/fxge/cfx_face.cpp b/core/fxge/cfx_face.cpp
index 1946843..d838a4b 100644
--- a/core/fxge/cfx_face.cpp
+++ b/core/fxge/cfx_face.cpp
@@ -5,6 +5,7 @@
#include "core/fxge/cfx_face.h"
#include "third_party/base/check.h"
+#include "third_party/base/numerics/safe_conversions.h"
// static
RetainPtr<CFX_Face> CFX_Face::New(FT_Library library,
@@ -12,8 +13,9 @@
pdfium::span<const FT_Byte> data,
FT_Long face_index) {
FXFT_FaceRec* pRec = nullptr;
- if (FT_New_Memory_Face(library, data.data(), data.size(), face_index,
- &pRec) != 0) {
+ if (FT_New_Memory_Face(library, data.data(),
+ pdfium::base::checked_cast<FT_Long>(data.size()),
+ face_index, &pRec) != 0) {
return nullptr;
}
return pdfium::WrapRetain(new CFX_Face(pRec, pDesc));
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 2af6275..5688660 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -39,6 +39,7 @@
#include "third_party/base/check_op.h"
#include "third_party/base/cxx17_backports.h"
#include "third_party/base/notreached.h"
+#include "third_party/base/numerics/safe_conversions.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/span.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -490,8 +491,8 @@
float boundsStart = pFunc->GetDomain(0);
const auto& subFunctions = pFunc->GetSubFunctions();
- int subFunctionCount = subFunctions.size();
- for (int i = 0; i < subFunctionCount; ++i) {
+ size_t subFunctionCount = subFunctions.size();
+ for (size_t i = 0; i < subFunctionCount; ++i) {
const CPDF_ExpIntFunc* pSubFunc = subFunctions[i]->ToExpIntFunc();
if (!pSubFunc)
return false;
@@ -1620,7 +1621,8 @@
intervals[i * 2 + 1] = off;
}
spaint->setPathEffect(SkDashPathEffect::Make(
- intervals.data(), intervals.size(), pGraphState->m_DashPhase));
+ intervals.data(), pdfium::base::checked_cast<int>(intervals.size()),
+ pGraphState->m_DashPhase));
}
spaint->setStyle(SkPaint::kStroke_Style);
spaint->setAntiAlias(!m_FillOptions.aliased_path);
@@ -2176,7 +2178,7 @@
}
const std::vector<std::unique_ptr<CPDF_Function>>& pFuncs =
pPattern->GetFuncs();
- int nFuncs = pFuncs.size();
+ size_t nFuncs = pFuncs.size();
if (nFuncs > 1) // TODO(caryclark) remove this restriction
return false;
const CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict();
@@ -2187,7 +2189,7 @@
// yet.)
SkTDArray<SkColor> skColors;
SkTDArray<SkScalar> skPos;
- for (int j = 0; j < nFuncs; j++) {
+ for (size_t j = 0; j < nFuncs; j++) {
if (!pFuncs[j])
continue;