summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp10
-rw-r--r--fpdfsdk/fpdfsave_embeddertest.cpp4
-rw-r--r--fpdfsdk/fpdftext_embeddertest.cpp37
-rw-r--r--fpdfsdk/fpdfview.cpp3
-rw-r--r--fpdfsdk/fpdfview_embeddertest.cpp18
-rw-r--r--fpdfsdk/javascript/Field.cpp2
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp2
7 files changed, 41 insertions, 35 deletions
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index bf91038ca6..855235858b 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -72,7 +72,7 @@ TEST_F(FPDFDocEmbeddertest, NoBookmarks) {
// The non-existent top-level bookmark has no title.
unsigned short buf[128];
- EXPECT_EQ(0, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
+ EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
// The non-existent top-level bookmark has no children.
EXPECT_EQ(nullptr, FPDFBookmark_GetFirstChild(document(), nullptr));
@@ -84,11 +84,11 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) {
// The existent top-level bookmark has no title.
unsigned short buf[128];
- EXPECT_EQ(0, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
+ EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(), nullptr);
EXPECT_NE(nullptr, child);
- EXPECT_EQ(34, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
+ EXPECT_EQ(34u, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
EXPECT_EQ(CFX_WideString(L"A Good Beginning"),
CFX_WideString::FromUTF16LE(buf, 16));
@@ -96,7 +96,7 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) {
FPDF_BOOKMARK sibling = FPDFBookmark_GetNextSibling(document(), child);
EXPECT_NE(nullptr, sibling);
- EXPECT_EQ(28, FPDFBookmark_GetTitle(sibling, buf, sizeof(buf)));
+ EXPECT_EQ(28u, FPDFBookmark_GetTitle(sibling, buf, sizeof(buf)));
EXPECT_EQ(CFX_WideString(L"A Good Ending"),
CFX_WideString::FromUTF16LE(buf, 13));
@@ -115,7 +115,7 @@ TEST_F(FPDFDocEmbeddertest, FindBookmarks) {
// Check that the string matches.
unsigned short buf[128];
- EXPECT_EQ(34, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
+ EXPECT_EQ(34u, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
EXPECT_EQ(CFX_WideString(L"A Good Beginning"),
CFX_WideString::FromUTF16LE(buf, 16));
diff --git a/fpdfsdk/fpdfsave_embeddertest.cpp b/fpdfsdk/fpdfsave_embeddertest.cpp
index 2b138a61e4..5dbff36327 100644
--- a/fpdfsdk/fpdfsave_embeddertest.cpp
+++ b/fpdfsdk/fpdfsave_embeddertest.cpp
@@ -19,14 +19,14 @@ TEST_F(FPDFSaveEmbedderTest, SaveSimpleDoc) {
EXPECT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
- EXPECT_EQ(843, GetString().length());
+ EXPECT_EQ(843u, GetString().length());
}
TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithVersion) {
EXPECT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 14));
EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.4\r\n"));
- EXPECT_EQ(843, GetString().length());
+ EXPECT_EQ(843u, GetString().length());
}
TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithBadVersion) {
diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp
index ed20882a1b..a5215c20cc 100644
--- a/fpdfsdk/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/fpdftext_embeddertest.cpp
@@ -48,7 +48,8 @@ TEST_F(FPDFTextEmbeddertest, Text) {
EXPECT_TRUE(check_unsigned_shorts(expected, fixed_buffer, sizeof(expected)));
// Count does not include the terminating NUL in the string literal.
- EXPECT_EQ(sizeof(expected) - 1, FPDFText_CountChars(textpage));
+ EXPECT_EQ(sizeof(expected) - 1,
+ static_cast<size_t>(FPDFText_CountChars(textpage)));
for (size_t i = 0; i < sizeof(expected) - 1; ++i) {
EXPECT_EQ(static_cast<unsigned int>(expected[i]),
FPDFText_GetUnicode(textpage, i))
@@ -285,6 +286,7 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0));
static const char expected_url[] = "http://example.com?q=foo";
+ static const size_t expected_len = sizeof(expected_url);
unsigned short fixed_buffer[128];
// Retrieve a link with too small a buffer. Buffer will not be
@@ -297,30 +299,27 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
// Check buffer that doesn't have space for a terminating NUL.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(
- sizeof(expected_url) - 1,
- FPDFLink_GetURL(pagelink, 0, fixed_buffer, sizeof(expected_url) - 1));
- EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer,
- sizeof(expected_url) - 1));
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url) - 1]);
+ EXPECT_EQ(static_cast<int>(expected_len - 1),
+ FPDFLink_GetURL(pagelink, 0, fixed_buffer, expected_len - 1));
+ EXPECT_TRUE(
+ check_unsigned_shorts(expected_url, fixed_buffer, expected_len - 1));
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len - 1]);
// Retreive link with exactly-sized buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
- FPDFLink_GetURL(pagelink, 0, fixed_buffer, sizeof(expected_url)));
- EXPECT_TRUE(
- check_unsigned_shorts(expected_url, fixed_buffer, sizeof(expected_url)));
- EXPECT_EQ(0u, fixed_buffer[sizeof(expected_url) - 1]);
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url)]);
+ EXPECT_EQ(static_cast<int>(expected_len),
+ FPDFLink_GetURL(pagelink, 0, fixed_buffer, expected_len));
+ EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer, expected_len));
+ EXPECT_EQ(0u, fixed_buffer[expected_len - 1]);
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len]);
// Retreive link with ample-sized-buffer.
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
- EXPECT_EQ(sizeof(expected_url),
+ EXPECT_EQ(static_cast<int>(expected_len),
FPDFLink_GetURL(pagelink, 0, fixed_buffer, 128));
- EXPECT_TRUE(
- check_unsigned_shorts(expected_url, fixed_buffer, sizeof(expected_url)));
- EXPECT_EQ(0u, fixed_buffer[sizeof(expected_url) - 1]);
- EXPECT_EQ(0xbdbd, fixed_buffer[sizeof(expected_url)]);
+ EXPECT_TRUE(check_unsigned_shorts(expected_url, fixed_buffer, expected_len));
+ EXPECT_EQ(0u, fixed_buffer[expected_len - 1]);
+ EXPECT_EQ(0xbdbd, fixed_buffer[expected_len]);
// Each link rendered in a single rect in this test page.
EXPECT_EQ(1, FPDFLink_CountRects(pagelink, 0));
@@ -382,7 +381,7 @@ TEST_F(FPDFTextEmbeddertest, GetFontSize) {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
int count = FPDFText_CountChars(textpage);
- ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), count);
+ ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), static_cast<size_t>(count));
for (int i = 0; i < count; ++i)
EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i;
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 9995fc0426..9183b4073b 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -194,7 +194,8 @@ FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer,
FX_SAFE_FILESIZE newPos =
pdfium::base::checked_cast<FX_FILESIZE, size_t>(size);
newPos += offset;
- if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) {
+ if (!newPos.IsValid() ||
+ newPos.ValueOrDie() > static_cast<FX_FILESIZE>(m_FileAccess.m_FileLen)) {
return FALSE;
}
return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset, (uint8_t*)buffer,
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 29eb91ab4d..10fe3aa822 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -88,14 +88,16 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
// Try to retrieve the forth item with ample buffer. Item is taken
// from Dests NameTree but has a vale of the wrong type in named_dests.pdf.
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
// Try to retrieve fifth item with ample buffer. Item taken from the
// old-style Dests dictionary object in named_dests.pdf.
@@ -120,25 +122,29 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
// Try to underflow/overflow the integer index.
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::max(),
fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(),
fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size);
EXPECT_EQ(nullptr, dest);
- EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
+ EXPECT_EQ(sizeof(fixed_buffer),
+ static_cast<size_t>(buffer_size)); // unmodified.
}
TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 54b4f6432c..5b8750d88e 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -1014,7 +1014,7 @@ void Field::SetCurrentValueIndices(CPDFSDK_Document* pDocument,
for (size_t i = 0; i < array.size(); ++i) {
if (i != 0 && !(dwFieldFlags & (1 << 21)))
break;
- if (array[i] < pFormField->CountOptions() &&
+ if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) &&
!pFormField->IsItemSelected(array[i])) {
pFormField->SetItemSelection(array[i], TRUE);
}
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index a4c13564c8..62659e4163 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -1502,7 +1502,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (wChange.empty())
return TRUE;
- int iIndexMask = pEvent->SelStart();
+ size_t iIndexMask = pEvent->SelStart();
size_t combined_len = wstrValue.length() + wChange.length() -
(pEvent->SelEnd() - pEvent->SelStart());