summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-09-21 18:28:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-21 18:28:49 +0000
commitb1d6afbeef3213412e2b45269cab36d016c60bcd (patch)
treebcfc08dc77e8dc80f16687e0455e034e5c8ec206 /core/fpdfapi
parent8e54f192f977824744cd14f04b6f35b79e0c42be (diff)
downloadpdfium-b1d6afbeef3213412e2b45269cab36d016c60bcd.tar.xz
Make OutputIndex() a void method
The return value is never used, so OutputIndex() can be void. The if statement still helps to stop when the work has failed. Change-Id: I7e9c72db1d1e226bb0466ebb26fd07915e2396bf Reviewed-on: https://pdfium-review.googlesource.com/42930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index c41f4b64f9..0823146b15 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -127,15 +127,12 @@ std::vector<uint8_t> GenerateFileID(uint32_t dwSeed1, uint32_t dwSeed2) {
return buffer;
}
-int32_t OutputIndex(IFX_ArchiveStream* archive, FX_FILESIZE offset) {
- if (!archive->WriteByte(static_cast<uint8_t>(offset >> 24)) ||
- !archive->WriteByte(static_cast<uint8_t>(offset >> 16)) ||
- !archive->WriteByte(static_cast<uint8_t>(offset >> 8)) ||
- !archive->WriteByte(static_cast<uint8_t>(offset)) ||
- !archive->WriteByte(0)) {
- return -1;
- }
- return 0;
+bool OutputIndex(IFX_ArchiveStream* archive, FX_FILESIZE offset) {
+ return archive->WriteByte(static_cast<uint8_t>(offset >> 24)) &&
+ archive->WriteByte(static_cast<uint8_t>(offset >> 16)) &&
+ archive->WriteByte(static_cast<uint8_t>(offset >> 8)) &&
+ archive->WriteByte(static_cast<uint8_t>(offset)) &&
+ archive->WriteByte(0);
}
} // namespace
@@ -535,7 +532,8 @@ CPDF_Creator::Stage CPDF_Creator::WriteDoc_Stage4() {
auto it = m_ObjectOffsets.find(i);
if (it == m_ObjectOffsets.end())
continue;
- OutputIndex(m_Archive.get(), it->second);
+ if (!OutputIndex(m_Archive.get(), it->second))
+ return Stage::kInvalid;
}
} else {
size_t count = m_NewObjNumArray.size();
@@ -551,8 +549,10 @@ CPDF_Creator::Stage CPDF_Creator::WriteDoc_Stage4() {
!m_Archive->WriteString(">>stream\r\n")) {
return Stage::kInvalid;
}
- for (i = 0; i < count; ++i)
- OutputIndex(m_Archive.get(), m_ObjectOffsets[m_NewObjNumArray[i]]);
+ for (i = 0; i < count; ++i) {
+ if (!OutputIndex(m_Archive.get(), m_ObjectOffsets[m_NewObjNumArray[i]]))
+ return Stage::kInvalid;
+ }
}
if (!m_Archive->WriteString("\r\nendstream"))
return Stage::kInvalid;