summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-06-04 20:22:08 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-04 20:22:08 +0000
commit80c6ab7b99bcbd7b940f78dc0cac52c30249f59c (patch)
tree0e65dfe95df518322656ecf5fab5432b1b6ba18f
parent36aae4fc09a353e01738bf0bbc302a21ba21ed07 (diff)
downloadpdfium-80c6ab7b99bcbd7b940f78dc0cac52c30249f59c.tar.xz
Convert (void) to static_cast<void> in C++ codechromium/3450
Converting instances of old C-style void casts to suppress return values to use C++ style static cases. There are a few examples of (void) that remain, since they are in C code, and the third_party/ instances are not touched at all. Change-Id: I72b3fc0e1d713db669b76135e03d1cf87873a2fe Reviewed-on: https://pdfium-review.googlesource.com/33790 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
-rw-r--r--core/fpdfapi/font/cfx_cttgsubtable.cpp6
-rw-r--r--core/fpdfapi/parser/cpdf_parser_embeddertest.cpp2
-rw-r--r--core/fxcrt/fx_memory_unittest.cpp8
-rw-r--r--fpdfsdk/fpdf_formfill.cpp4
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp2
-rw-r--r--samples/pdfium_test.cc2
-rw-r--r--samples/pdfium_test_write_helper.cc10
-rw-r--r--testing/embedder_test.cpp10
-rw-r--r--testing/test_support.cpp6
9 files changed, 26 insertions, 24 deletions
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp
index ae868ca5ab..6c93363857 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.cpp
+++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp
@@ -256,7 +256,7 @@ CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw) {
void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
TCoverageFormat1* rec) {
FT_Bytes sp = raw;
- (void)GetUInt16(sp);
+ static_cast<void>(GetUInt16(sp));
rec->GlyphArray = std::vector<uint16_t>(GetUInt16(sp));
for (auto& glyph : rec->GlyphArray)
glyph = GetUInt16(sp);
@@ -265,7 +265,7 @@ void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
TCoverageFormat2* rec) {
FT_Bytes sp = raw;
- (void)GetUInt16(sp);
+ static_cast<void>(GetUInt16(sp));
rec->RangeRecords = std::vector<TRangeRecord>(GetUInt16(sp));
for (auto& rangeRec : rec->RangeRecords) {
rangeRec.Start = GetUInt16(sp);
@@ -300,7 +300,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, TSubTable1* rec) {
void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, TSubTable2* rec) {
FT_Bytes sp = raw;
- (void)GetUInt16(sp);
+ static_cast<void>(GetUInt16(sp));
uint16_t offset = GetUInt16(sp);
rec->Coverage = ParseCoverage(&raw[offset]);
rec->Substitutes = std::vector<uint16_t>(GetUInt16(sp));
diff --git a/core/fpdfapi/parser/cpdf_parser_embeddertest.cpp b/core/fpdfapi/parser/cpdf_parser_embeddertest.cpp
index 3b8f550253..ef9d43828e 100644
--- a/core/fpdfapi/parser/cpdf_parser_embeddertest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_embeddertest.cpp
@@ -28,7 +28,7 @@ TEST_F(CPDFParserEmbeddertest, Bug_544880) {
// Shouldn't crash. We don't check the return value here because we get the
// the count from the "/Count 1" in the testcase (at the time of writing)
// rather than the actual count (0).
- (void)GetPageCount();
+ static_cast<void>(GetPageCount());
}
TEST_F(CPDFParserEmbeddertest, Bug_325a) {
diff --git a/core/fxcrt/fx_memory_unittest.cpp b/core/fxcrt/fx_memory_unittest.cpp
index 2856bb9592..d062885f85 100644
--- a/core/fxcrt/fx_memory_unittest.cpp
+++ b/core/fxcrt/fx_memory_unittest.cpp
@@ -21,11 +21,12 @@ const size_t kOverflowIntAlloc2D = kMaxIntAlloc / kWidth + 10;
// TODO(tsepez): re-enable OOM tests if we can find a way to
// prevent it from hosing the bots.
TEST(fxcrt, DISABLED_FX_AllocOOM) {
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc(int, kMaxIntAlloc), "");
+ EXPECT_DEATH_IF_SUPPORTED(static_cast<void>(FX_Alloc(int, kMaxIntAlloc)), "");
int* ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kMaxIntAlloc), "");
+ EXPECT_DEATH_IF_SUPPORTED(
+ static_cast<void>(FX_Realloc(int, ptr, kMaxIntAlloc)), "");
FX_Free(ptr);
}
@@ -37,7 +38,8 @@ TEST(fxcrt, FX_AllocOverflow) {
ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kOverflowIntAlloc), "");
+ EXPECT_DEATH_IF_SUPPORTED(
+ static_cast<void>(FX_Realloc(int, ptr, kOverflowIntAlloc)), "");
FX_Free(ptr);
}
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 62d2c00d55..8ebf7faaff 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -272,9 +272,9 @@ FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
return -1;
CPDF_InterForm interform(pPage->GetDocument());
int z_order = -1;
- (void)interform.GetControlAtPoint(
+ static_cast<void>(interform.GetControlAtPoint(
pPage, CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)),
- &z_order);
+ &z_order));
return z_order;
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index f9f5981efb..595c4a919f 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -644,7 +644,7 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
if (!it)
return true;
- (void)it->MoveToNext();
+ static_cast<void>(it->MoveToNext());
CXFA_Node* pNode = it->MoveToNext();
while (pNode) {
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index d2e84872d6..0491840b34 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -682,7 +682,7 @@ void RenderPdf(const std::string& name,
return;
}
- (void)FPDF_GetDocPermissions(doc.get());
+ static_cast<void>(FPDF_GetDocPermissions(doc.get()));
if (options.show_metadata)
DumpMetaData(doc.get());
diff --git a/samples/pdfium_test_write_helper.cc b/samples/pdfium_test_write_helper.cc
index c436c97fbe..758f5efe72 100644
--- a/samples/pdfium_test_write_helper.cc
+++ b/samples/pdfium_test_write_helper.cc
@@ -211,7 +211,7 @@ void WriteText(FPDF_PAGE page, const char* pdf_name, int num) {
uint32_t bom = 0x0000FEFF;
if (fwrite(&bom, sizeof(bom), 1, fp) != 1) {
fprintf(stderr, "Failed to write to %s\n", filename);
- (void)fclose(fp);
+ static_cast<void>(fclose(fp));
return;
}
@@ -223,7 +223,7 @@ void WriteText(FPDF_PAGE page, const char* pdf_name, int num) {
break;
}
}
- (void)fclose(fp);
+ static_cast<void>(fclose(fp));
}
void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) {
@@ -343,7 +343,7 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) {
}
}
- (void)fclose(fp);
+ static_cast<void>(fclose(fp));
}
std::string WritePng(const char* pdf_name,
@@ -383,7 +383,7 @@ std::string WritePng(const char* pdf_name,
if (bytes_written != png_encoding.size())
fprintf(stderr, "Failed to write to %s\n", filename);
- (void)fclose(fp);
+ static_cast<void>(fclose(fp));
return std::string(filename);
}
@@ -649,6 +649,6 @@ void WriteImages(FPDF_PAGE page, const char* pdf_name, int page_num) {
else
fprintf(stderr, "Successfully wrote embedded image %s.\n", filename);
- (void)fclose(fp);
+ static_cast<void>(fclose(fp));
}
}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 03eebe3abc..aaea965cf0 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -220,7 +220,7 @@ bool EmbedderTest::OpenDocumentHelper(const char* password,
FPDF_LoadXFA(*document);
#endif // PDF_ENABLE_XFA
- (void)FPDF_GetDocPermissions(*document);
+ static_cast<void>(FPDF_GetDocPermissions(*document));
return true;
}
@@ -262,16 +262,16 @@ void EmbedderTest::DoOpenActions() {
int EmbedderTest::GetFirstPageNum() {
int first_page = FPDFAvail_GetFirstPageNum(document_);
- (void)FPDFAvail_IsPageAvail(avail_, first_page,
- fake_file_access_->GetDownloadHints());
+ static_cast<void>(FPDFAvail_IsPageAvail(
+ avail_, first_page, fake_file_access_->GetDownloadHints()));
return first_page;
}
int EmbedderTest::GetPageCount() {
int page_count = FPDF_GetPageCount(document_);
for (int i = 0; i < page_count; ++i)
- (void)FPDFAvail_IsPageAvail(avail_, i,
- fake_file_access_->GetDownloadHints());
+ static_cast<void>(FPDFAvail_IsPageAvail(
+ avail_, i, fake_file_access_->GetDownloadHints()));
return page_count;
}
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index 2b6f436c32..16ae5b28b9 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -84,19 +84,19 @@ std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
fprintf(stderr, "Failed to open: %s\n", filename);
return nullptr;
}
- (void)fseek(file, 0, SEEK_END);
+ static_cast<void>(fseek(file, 0, SEEK_END));
size_t file_length = ftell(file);
if (!file_length) {
return nullptr;
}
- (void)fseek(file, 0, SEEK_SET);
+ static_cast<void>(fseek(file, 0, SEEK_SET));
std::unique_ptr<char, pdfium::FreeDeleter> buffer(
static_cast<char*>(malloc(file_length)));
if (!buffer) {
return nullptr;
}
size_t bytes_read = fread(buffer.get(), 1, file_length, file);
- (void)fclose(file);
+ static_cast<void>(fclose(file));
if (bytes_read != file_length) {
fprintf(stderr, "Failed to read: %s\n", filename);
return nullptr;