Make static const char* arrays more const.
Change-Id: I87b5e6cefe973b82b4868e56fc5285c95c53a12b
Reviewed-on: https://pdfium-review.googlesource.com/12550
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index 169e0f1..770c718 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -697,8 +697,9 @@
}
TEST(PDFArrayTest, AddStringAndName) {
- const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323",
- "$#%^&**", " ", "This is a test.\r\n"};
+ static constexpr const char* vals[] = {
+ "", "a", "ehjhRIOYTTFdfcdnv", "122323",
+ "$#%^&**", " ", "This is a test.\r\n"};
auto string_array = pdfium::MakeUnique<CPDF_Array>();
auto name_array = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp
index 033bf03..fd29b52 100644
--- a/core/fpdfdoc/cpdf_aaction.cpp
+++ b/core/fpdfdoc/cpdf_aaction.cpp
@@ -8,9 +8,13 @@
namespace {
-const char* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO", "PC",
- "PV", "PI", "O", "C", "K", "F", "V", "C",
- "WC", "WS", "DS", "WP", "DP", ""};
+constexpr const char* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO",
+ "PC", "PV", "PI", "O", "C", "K", "F",
+ "V", "C", "WC", "WS", "DS", "WP", "DP"};
+
+// |g_sAATypes| should have as many elements as enum AActionType.
+static_assert(FX_ArraySize(g_sAATypes) == CPDF_AAction::NumberOfActions,
+ "g_sAATypes count mismatch");
} // namespace
diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h
index b2b691f..bacf179 100644
--- a/core/fpdfdoc/cpdf_aaction.h
+++ b/core/fpdfdoc/cpdf_aaction.h
@@ -34,7 +34,8 @@
SaveDocument,
DocumentSaved,
PrintDocument,
- DocumentPrinted
+ DocumentPrinted,
+ NumberOfActions // Must be last.
};
CPDF_AAction();
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index e21ce73..60a4d52 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -164,11 +164,8 @@
eEventType = XFA_EVENT_Exit;
break;
case CPDF_AAction::PageOpen:
- break;
case CPDF_AAction::PageClose:
- break;
case CPDF_AAction::PageVisible:
- break;
case CPDF_AAction::PageInvisible:
break;
case CPDF_AAction::KeyStroke:
@@ -188,6 +185,9 @@
case CPDF_AAction::PrintDocument:
case CPDF_AAction::DocumentPrinted:
break;
+ case CPDF_AAction::NumberOfActions:
+ NOTREACHED();
+ break;
}
return eEventType;
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 4b395c9..9cb772e 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -443,7 +443,7 @@
namespace {
-const char* g_FontFolders[] = {
+constexpr const char* g_FontFolders[] = {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
"/usr/share/fonts", "/usr/share/X11/fonts/Type1",
"/usr/share/X11/fonts/TTF", "/usr/local/share/fonts",