summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-02-26 21:02:52 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-26 21:02:52 +0000
commit0bc02c152bd0c178a5946196e2054a5cdc7650f4 (patch)
tree4a651b86f0d240c4996ea77f041274d241e59c93
parent611431decd9a5b7dd456355fe763b2dee9c2a1a1 (diff)
downloadpdfium-chromium/3356.tar.xz
Add some more missing consts.chromium/3356
Get things out of the .data section. Change-Id: I375cf00186a3d5d8d10f5d147bd4b692f5db3683 Reviewed-on: https://pdfium-review.googlesource.com/27130 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp2
-rw-r--r--core/fxcodec/gif/cfx_gif.cpp4
-rw-r--r--core/fxcodec/gif/cfx_gif.h4
-rw-r--r--core/fxcrt/fx_string.cpp2
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.cpp2
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.h4
-rw-r--r--fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp23
-rw-r--r--fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h24
-rw-r--r--fxjs/xfa/cjx_object.cpp19
-rw-r--r--fxjs/xfa/cjx_object.h4
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmlexer.cpp2
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp10
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h8
-rw-r--r--xfa/fxfa/parser/cxfa_node_statics.cpp8
14 files changed, 59 insertions, 57 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 02df3cff60..c74965c3e7 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -24,7 +24,7 @@
namespace {
-char kPDFiumKey_HasGeneratedAP[] = "PDFIUM_HasGeneratedAP";
+const char kPDFiumKey_HasGeneratedAP[] = "PDFIUM_HasGeneratedAP";
bool IsTextMarkupAnnotation(CPDF_Annot::Subtype type) {
return type == CPDF_Annot::Subtype::HIGHLIGHT ||
diff --git a/core/fxcodec/gif/cfx_gif.cpp b/core/fxcodec/gif/cfx_gif.cpp
index 985a687906..e87b9df975 100644
--- a/core/fxcodec/gif/cfx_gif.cpp
+++ b/core/fxcodec/gif/cfx_gif.cpp
@@ -6,8 +6,8 @@
#include "core/fxcodec/gif/cfx_gif.h"
-const char* kGifSignature87 = "GIF87a";
-const char* kGifSignature89 = "GIF89a";
+const char kGifSignature87[] = "GIF87a";
+const char kGifSignature89[] = "GIF89a";
static_assert(sizeof(CFX_CFX_GifImageInfo) == 9,
"CFX_CFX_GifImageInfo should have a size of 9");
diff --git a/core/fxcodec/gif/cfx_gif.h b/core/fxcodec/gif/cfx_gif.h
index ab8278ecd2..5abe1ad33f 100644
--- a/core/fxcodec/gif/cfx_gif.h
+++ b/core/fxcodec/gif/cfx_gif.h
@@ -12,8 +12,8 @@
class CFX_GifContext;
-extern const char* kGifSignature87;
-extern const char* kGifSignature89;
+extern const char kGifSignature87[];
+extern const char kGifSignature89[];
#define GIF_SIG_EXTENSION 0x21
#define GIF_SIG_IMAGE 0x2C
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp
index 13eb3a5bdd..83d0e6d906 100644
--- a/core/fxcrt/fx_string.cpp
+++ b/core/fxcrt/fx_string.cpp
@@ -37,7 +37,7 @@ class CFX_UTF8Encoder {
else
nbytes = 6;
- static uint8_t prefix[] = {0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
+ static const uint8_t prefix[] = {0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
int order = 1 << ((nbytes - 1) * 6);
int code = unicodeAsWchar;
m_Buffer.push_back(prefix[nbytes - 2] | (code / order));
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 35077ee628..83442645e4 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -102,9 +102,9 @@ const uint8_t* const FACTORS[16] = {
} // namespace
-int32_t CBC_ErrorCorrection::MODULO_VALUE = 0x12D;
int32_t CBC_ErrorCorrection::LOG[256] = {0};
int32_t CBC_ErrorCorrection::ALOG[256] = {0};
+
void CBC_ErrorCorrection::Initialize() {
int32_t p = 1;
for (int32_t i = 0; i < 255; i++) {
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.h b/fxbarcode/datamatrix/BC_ErrorCorrection.h
index 361b205ef4..ccb83f0b86 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.h
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.h
@@ -23,11 +23,11 @@ class CBC_ErrorCorrection {
int32_t& e);
private:
- static int32_t MODULO_VALUE;
+ static const int32_t MODULO_VALUE = 0x12D;
+
static int32_t LOG[256];
static int32_t ALOG[256];
- private:
static WideString createECCBlock(WideString codewords,
int32_t numECWords,
int32_t& e);
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index 059287a665..ffc057a5f6 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -31,21 +31,22 @@
#define SUBMODE_LOWER 1
#define SUBMODE_MIXED 2
-int32_t CBC_PDF417HighLevelEncoder::TEXT_COMPACTION = 0;
-int32_t CBC_PDF417HighLevelEncoder::BYTE_COMPACTION = 1;
-int32_t CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION = 2;
-int32_t CBC_PDF417HighLevelEncoder::SUBMODE_PUNCTUATION = 3;
-int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_TEXT = 900;
-int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE_PADDED = 901;
-int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_NUMERIC = 902;
-int32_t CBC_PDF417HighLevelEncoder::SHIFT_TO_BYTE = 913;
-int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE = 924;
-uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = {
+const int32_t CBC_PDF417HighLevelEncoder::TEXT_COMPACTION = 0;
+const int32_t CBC_PDF417HighLevelEncoder::BYTE_COMPACTION = 1;
+const int32_t CBC_PDF417HighLevelEncoder::NUMERIC_COMPACTION = 2;
+const int32_t CBC_PDF417HighLevelEncoder::SUBMODE_PUNCTUATION = 3;
+const int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_TEXT = 900;
+const int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE_PADDED = 901;
+const int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_NUMERIC = 902;
+const int32_t CBC_PDF417HighLevelEncoder::SHIFT_TO_BYTE = 913;
+const int32_t CBC_PDF417HighLevelEncoder::LATCH_TO_BYTE = 924;
+const uint8_t CBC_PDF417HighLevelEncoder::TEXT_MIXED_RAW[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 38, 13, 9, 44, 58,
35, 45, 46, 36, 47, 43, 37, 42, 61, 94, 0, 32, 0, 0, 0};
-uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = {
+const uint8_t CBC_PDF417HighLevelEncoder::TEXT_PUNCTUATION_RAW[] = {
59, 60, 62, 64, 91, 92, 93, 95, 96, 126, 33, 13, 9, 44, 58,
10, 45, 46, 36, 47, 34, 124, 42, 40, 41, 63, 123, 125, 39, 0};
+
int32_t CBC_PDF417HighLevelEncoder::MIXED[128] = {0};
int32_t CBC_PDF417HighLevelEncoder::PUNCTUATION[128] = {0};
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
index 2701c810fb..5e0ab52961 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h
@@ -22,19 +22,21 @@ class CBC_PDF417HighLevelEncoder {
static void Finalize();
private:
- static int32_t TEXT_COMPACTION;
- static int32_t BYTE_COMPACTION;
- static int32_t NUMERIC_COMPACTION;
- static int32_t SUBMODE_PUNCTUATION;
- static int32_t LATCH_TO_TEXT;
- static int32_t LATCH_TO_BYTE_PADDED;
- static int32_t LATCH_TO_NUMERIC;
- static int32_t SHIFT_TO_BYTE;
- static int32_t LATCH_TO_BYTE;
- static uint8_t TEXT_MIXED_RAW[];
- static uint8_t TEXT_PUNCTUATION_RAW[];
+ static const int32_t TEXT_COMPACTION;
+ static const int32_t BYTE_COMPACTION;
+ static const int32_t NUMERIC_COMPACTION;
+ static const int32_t SUBMODE_PUNCTUATION;
+ static const int32_t LATCH_TO_TEXT;
+ static const int32_t LATCH_TO_BYTE_PADDED;
+ static const int32_t LATCH_TO_NUMERIC;
+ static const int32_t SHIFT_TO_BYTE;
+ static const int32_t LATCH_TO_BYTE;
+ static const uint8_t TEXT_MIXED_RAW[];
+ static const uint8_t TEXT_PUNCTUATION_RAW[];
+
static int32_t MIXED[128];
static int32_t PUNCTUATION[128];
+
static int32_t encodeText(WideString msg,
int32_t startpos,
int32_t count,
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 5a2c4bd130..bb8eef123e 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -51,8 +51,8 @@ void XFA_CopyWideString(void*& pData) {
pData = new WideString(*reinterpret_cast<WideString*>(pData));
}
-XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString,
- XFA_CopyWideString};
+const XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {
+ XFA_DeleteWideString, XFA_CopyWideString};
enum XFA_KEYTYPE {
XFA_KEYTYPE_Custom,
@@ -72,8 +72,8 @@ void* GetMapKey_Element(XFA_Element eType, XFA_Attribute eAttribute) {
void XFA_DefaultFreeData(void* pData) {}
-XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = {XFA_DefaultFreeData,
- nullptr};
+const XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = {XFA_DefaultFreeData,
+ nullptr};
std::tuple<int32_t, int32_t, int32_t> StrToRGB(const WideString& strRGB) {
int32_t r = 0;
@@ -111,7 +111,7 @@ std::tuple<int32_t, int32_t, int32_t> StrToRGB(const WideString& strRGB) {
struct XFA_MAPDATABLOCK {
uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); }
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo;
+ const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo;
int32_t iBytes;
};
@@ -949,9 +949,10 @@ CXFA_Node* CJX_Object::GetOrCreatePropertyInternal(int32_t index,
return pNewNode;
}
-bool CJX_Object::SetUserData(void* pKey,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
+bool CJX_Object::SetUserData(
+ void* pKey,
+ void* pData,
+ const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
SetMapModuleBuffer(pKey, &pData, sizeof(void*),
pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData);
return true;
@@ -1004,7 +1005,7 @@ void CJX_Object::SetMapModuleBuffer(
void* pKey,
void* pValue,
int32_t iBytes,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
+ const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
XFA_MAPDATABLOCK*& pBuffer = CreateMapModuleData()->m_BufferMap[pKey];
if (!pBuffer) {
pBuffer = reinterpret_cast<XFA_MAPDATABLOCK*>(
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index 12b58b0af8..88f1d8c814 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -243,7 +243,7 @@ class CJX_Object {
void OnChanging(XFA_Attribute eAttr, bool bNotify);
bool SetUserData(void* pKey,
void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo);
+ const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo);
// Returns a pointer to the XML node that needs to be updated with the new
// attribute value. |nullptr| if no update is needed.
@@ -261,7 +261,7 @@ class CJX_Object {
void SetMapModuleBuffer(void* pKey,
void* pValue,
int32_t iBytes,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo);
+ const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo);
bool GetMapModuleBuffer(void* pKey,
void*& pValue,
int32_t& iBytes,
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index 41989f0a2d..3559fb7aeb 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -78,7 +78,7 @@ const XFA_FMKeyword keyWords[] = {
};
#ifndef NDEBUG
-const wchar_t* tokenStrings[] = {
+const wchar_t* const tokenStrings[] = {
L"TOKand", L"TOKlparen", L"TOKrparen", L"TOKmul",
L"TOKplus", L"TOKcomma", L"TOKminus", L"TOKdot",
L"TOKdiv", L"TOKlt", L"TOKassign", L"TOKgt",
diff --git a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp
index 6312ba6b3d..023516bb6e 100644
--- a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp
@@ -4,17 +4,7 @@
#include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h"
-namespace {
-
-// Arbitarily picked by looking at how deep a translation got before hitting
-// the getting fuzzer memory limits. Should be larger then |kMaxParseDepth| in
-// cxfa_fmparser.cpp.
-const unsigned int kMaxDepth = 5000;
-
-} // namespace
-
unsigned long CXFA_FMToJavaScriptDepth::depth_ = 0;
-unsigned long CXFA_FMToJavaScriptDepth::max_depth_ = kMaxDepth;
void CXFA_FMToJavaScriptDepth::Reset() {
depth_ = 0;
diff --git a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h
index 14f87a68f5..f4cd1be472 100644
--- a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h
+++ b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h
@@ -10,13 +10,17 @@ class CXFA_FMToJavaScriptDepth {
CXFA_FMToJavaScriptDepth() { depth_++; }
~CXFA_FMToJavaScriptDepth() { depth_--; }
- bool IsWithinMaxDepth() const { return depth_ <= max_depth_; }
+ bool IsWithinMaxDepth() const { return depth_ <= kMaxDepth; }
static void Reset();
private:
+ // Arbitarily picked by looking at how deep a translation got before hitting
+ // the getting fuzzer memory limits. Should be larger then |kMaxParseDepth| in
+ // cxfa_fmparser.cpp.
+ const unsigned long kMaxDepth = 5000;
+
static unsigned long depth_;
- static unsigned long max_depth_;
};
#endif // XFA_FXFA_FM2JS_CXFA_FMTOJAVASCRIPTDEPTH_H_
diff --git a/xfa/fxfa/parser/cxfa_node_statics.cpp b/xfa/fxfa/parser/cxfa_node_statics.cpp
index 93860c6a0a..3d64c1a66f 100644
--- a/xfa/fxfa/parser/cxfa_node_statics.cpp
+++ b/xfa/fxfa/parser/cxfa_node_statics.cpp
@@ -318,7 +318,9 @@ namespace {
struct ElementNameInfo {
uint32_t hash;
XFA_Element element;
-} ElementNameToEnum[] = {
+};
+
+const ElementNameInfo ElementNameToEnum[] = {
{0x23ee3 /* ps */, XFA_Element::Ps},
{0x25363 /* to */, XFA_Element::To},
{0x2587e /* ui */, XFA_Element::Ui},
@@ -631,7 +633,9 @@ struct ElementNameInfo {
struct AttributeNameInfo {
uint32_t hash;
XFA_Attribute attribute;
-} AttributeNameInfoToEnum[] = {
+};
+
+const AttributeNameInfo AttributeNameInfoToEnum[] = {
{0x68 /* h */, XFA_Attribute::H},
{0x77 /* w */, XFA_Attribute::W},
{0x78 /* x */, XFA_Attribute::X},