From 69fe7110e6af83ca82d71275a70ae4983daddd6f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 14 Sep 2017 18:26:26 -0700 Subject: Make static const char* arrays more const. Change-Id: I87b5e6cefe973b82b4868e56fc5285c95c53a12b Reviewed-on: https://pdfium-review.googlesource.com/12550 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- core/fpdfapi/parser/cpdf_object_unittest.cpp | 5 +++-- core/fpdfdoc/cpdf_aaction.cpp | 10 +++++++--- core/fpdfdoc/cpdf_aaction.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 169e0f1e56..770c718431 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -697,8 +697,9 @@ TEST(PDFArrayTest, AddInteger) { } 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(); auto name_array = pdfium::MakeUnique(); 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 033bf03a6a..fd29b52ef6 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 b2b691fc26..bacf1790f8 100644 --- a/core/fpdfdoc/cpdf_aaction.h +++ b/core/fpdfdoc/cpdf_aaction.h @@ -34,7 +34,8 @@ class CPDF_AAction { SaveDocument, DocumentSaved, PrintDocument, - DocumentPrinted + DocumentPrinted, + NumberOfActions // Must be last. }; CPDF_AAction(); -- cgit v1.2.3