Use more static_cast in fpdfsdk

This CL replaces some reinterpret_cast with static_cast in fpdfsdk. It also
removes an obsolete comment in fpdfedit.h

Change-Id: I36c29bfcd6382490a8c955b50ccfa4c93ab351c7
Reviewed-on: https://pdfium-review.googlesource.com/5632
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp
index 74c44f8..0c1cc0f 100644
--- a/fpdfsdk/fpdf_structtree.cpp
+++ b/fpdfsdk/fpdf_structtree.cpp
@@ -15,11 +15,11 @@
 namespace {
 
 CPDF_StructTree* ToStructTree(FPDF_STRUCTTREE struct_tree) {
-  return reinterpret_cast<CPDF_StructTree*>(struct_tree);
+  return static_cast<CPDF_StructTree*>(struct_tree);
 }
 
 CPDF_StructElement* ToStructTreeElement(FPDF_STRUCTELEMENT struct_element) {
-  return reinterpret_cast<CPDF_StructElement*>(struct_element);
+  return static_cast<CPDF_StructElement*>(struct_element);
 }
 
 unsigned long WideStringToBuffer(const CFX_WideString& str,
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 1b98b94..1f73887 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -106,7 +106,7 @@
 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper,
                                              const char* name,
                                              int charset) {
-  CFX_FontMapper* pMapper = reinterpret_cast<CFX_FontMapper*>(mapper);
+  CFX_FontMapper* pMapper = static_cast<CFX_FontMapper*>(mapper);
   pMapper->AddInstalledFont(name, charset);
 }
 
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index ed5fe3e..4559ee3 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -26,7 +26,7 @@
  protected:
   FPDF_DOCUMENT CreateNewDocument() {
     document_ = FPDF_CreateNewDocument();
-    cpdf_doc_ = reinterpret_cast<CPDF_Document*>(document_);
+    cpdf_doc_ = static_cast<CPDF_Document*>(document_);
     return document_;
   }
 
@@ -562,7 +562,7 @@
   std::unique_ptr<void, FPDFFontDeleter> font(
       FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, false));
   ASSERT_TRUE(font.get());
-  CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+  CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
   EXPECT_TRUE(typed_font->IsType1Font());
 
   CPDF_Dictionary* font_dict = typed_font->GetFontDict();
@@ -591,7 +591,7 @@
   std::unique_ptr<void, FPDFFontDeleter> font(
       FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, false));
   ASSERT_TRUE(font.get());
-  CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+  CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
   EXPECT_TRUE(typed_font->IsTrueTypeFont());
 
   CPDF_Dictionary* font_dict = typed_font->GetFontDict();
@@ -621,7 +621,7 @@
   std::unique_ptr<void, FPDFFontDeleter> font(
       FPDFText_LoadFont(document(), data, size, FPDF_FONT_TYPE1, 1));
   ASSERT_TRUE(font.get());
-  CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+  CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
   EXPECT_TRUE(typed_font->IsCIDFont());
 
   // Check font dictionary entries
@@ -663,7 +663,7 @@
   std::unique_ptr<void, FPDFFontDeleter> font(
       FPDFText_LoadFont(document(), data, size, FPDF_FONT_TRUETYPE, 1));
   ASSERT_TRUE(font.get());
-  CPDF_Font* typed_font = reinterpret_cast<CPDF_Font*>(font.get());
+  CPDF_Font* typed_font = static_cast<CPDF_Font*>(font.get());
   EXPECT_TRUE(typed_font->IsCIDFont());
 
   // Check font dictionary entries
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index 6a300c9..9f4b296 100644
--- a/fpdfsdk/fpdfeditimg.cpp
+++ b/fpdfsdk/fpdfeditimg.cpp
@@ -25,7 +25,7 @@
 
   CFX_RetainPtr<IFX_SeekableReadStream> pFile =
       MakeSeekableReadStream(fileAccess);
-  CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+  CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
 
   if (pages) {
     for (int index = 0; index < nCount; index++) {
@@ -82,7 +82,7 @@
   if (!image_object)
     return false;
 
-  CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+  CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
   pImgObj->set_matrix(CFX_Matrix(static_cast<float>(a), static_cast<float>(b),
                                  static_cast<float>(c), static_cast<float>(d),
                                  static_cast<float>(e), static_cast<float>(f)));
@@ -97,7 +97,7 @@
   if (!image_object || !bitmap || !pages)
     return false;
 
-  CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
+  CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
   for (int index = 0; index < nCount; index++) {
     CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
     if (pPage)
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index df752d4..431adca 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -135,7 +135,7 @@
 
 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
                                              FPDF_PAGEOBJECT page_obj) {
-  CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(page_obj);
+  CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(page_obj);
   if (!pPageObj)
     return;
 
@@ -201,7 +201,7 @@
   if (!pageObject)
     return false;
 
-  CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(pageObject);
+  CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(pageObject);
   int blend_type = pPageObj->m_GeneralState.GetBlendType();
   if (blend_type != FXDIB_BLEND_NORMAL)
     return true;
@@ -234,7 +234,7 @@
   if (!pageObject)
     return FPDF_PAGEOBJ_UNKNOWN;
 
-  CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(pageObject);
+  CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(pageObject);
   return pPageObj->GetType();
 }
 
@@ -255,7 +255,7 @@
                                              double d,
                                              double e,
                                              double f) {
-  CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(page_object);
+  CPDF_PageObject* pPageObj = static_cast<CPDF_PageObject*>(page_object);
   if (!pPageObj)
     return;
 
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
index a26ca51..60117ca 100644
--- a/fpdfsdk/fpdfeditpath.cpp
+++ b/fpdfsdk/fpdfeditpath.cpp
@@ -35,7 +35,7 @@
     return false;
 
   float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_GeneralState.SetStrokeAlpha(A / 255.f);
   pPathObj->m_ColorState.SetStrokeColor(
       CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
@@ -46,7 +46,7 @@
   if (!path || width < 0.0f)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_GraphState.SetLineWidth(width);
   return true;
 }
@@ -60,7 +60,7 @@
     return false;
 
   float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_GeneralState.SetFillAlpha(A / 255.f);
   pPathObj->m_ColorState.SetFillColor(
       CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
@@ -75,7 +75,7 @@
   if (!path || !R || !G || !B || !A)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   uint32_t fillRGB = pPathObj->m_ColorState.GetFillRGB();
   *R = FXSYS_GetRValue(fillRGB);
   *G = FXSYS_GetGValue(fillRGB);
@@ -89,7 +89,7 @@
   if (!path)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false);
   return true;
 }
@@ -98,7 +98,7 @@
   if (!path)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::LineTo, false);
   return true;
 }
@@ -113,7 +113,7 @@
   if (!path)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   pPathObj->m_Path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::BezierTo, false);
   pPathObj->m_Path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::BezierTo, false);
   pPathObj->m_Path.AppendPoint(CFX_PointF(x3, y3), FXPT_TYPE::BezierTo, false);
@@ -124,7 +124,7 @@
   if (!path)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
   if (pPathObj->m_Path.GetPoints().empty())
     return false;
 
@@ -138,7 +138,7 @@
   if (!path)
     return false;
 
-  auto* pPathObj = reinterpret_cast<CPDF_PathObject*>(path);
+  auto* pPathObj = static_cast<CPDF_PathObject*>(path);
 
   if (fillmode == FPDF_FILLMODE_ALTERNATE)
     pPathObj->m_FillType = FXFILL_ALTERNATE;
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index a466e73..121e1a9 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -67,11 +67,11 @@
 
 #ifdef PDF_ENABLE_XFA
 std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) {
-  return reinterpret_cast<std::vector<CFX_ByteString>*>(handle);
+  return static_cast<std::vector<CFX_ByteString>*>(handle);
 }
 
 FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
-  return reinterpret_cast<FPDF_STRINGHANDLE>(strings);
+  return static_cast<FPDF_STRINGHANDLE>(strings);
 }
 #endif  // PDF_ENABLE_XFA
 
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index f807807..2bf6dfc 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -156,7 +156,7 @@
     return false;
   }
   return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
-                                   reinterpret_cast<uint8_t*>(buffer), size);
+                                   static_cast<uint8_t*>(buffer), size);
 }
 
 #ifdef PDF_ENABLE_XFA
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index f9edfa3..a84b42a 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -434,7 +434,7 @@
                                              FPDF_WIDESTRING text);
 
 // Returns a font object loaded from a stream of data. The font is loaded
-// into the document. The caller does not need to free the returned object.
+// into the document.
 //
 // document   - handle to the document.
 // data       - the stream of data, which will be copied by the font object.