This is an automated email from the ASF dual-hosted git repository.
dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new f749e893bf Coverity: Avoid order initalization issue 2. (#12037)
f749e893bf is described below
commit f749e893bfa662f0e0c95ad2ce2ddfce7facc256
Author: Damian Meden <[email protected]>
AuthorDate: Mon Mar 3 09:45:32 2025 +0100
Coverity: Avoid order initalization issue 2. (#12037)
Convert from static member to static singleton function.
---
lib/swoc/include/swoc/bwf_base.h | 24 +++++++++++++++---------
lib/swoc/src/bw_format.cc | 2 --
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/lib/swoc/include/swoc/bwf_base.h b/lib/swoc/include/swoc/bwf_base.h
index e76ccc78a3..0b21ba207e 100644
--- a/lib/swoc/include/swoc/bwf_base.h
+++ b/lib/swoc/include/swoc/bwf_base.h
@@ -108,7 +108,7 @@ protected:
bool is_sign(char c);
/// Handrolled initialization the character syntactic property data.
- static const struct Property {
+ struct Property {
Property(); ///< Default constructor, creates initialized flag set.
/// Flag storage, indexed by character value.
uint8_t _data[0x100]{};
@@ -118,7 +118,13 @@ protected:
static constexpr uint8_t UPPER_TYPE_CHAR = 0x20; ///< Upper case flag.
static constexpr uint8_t NUMERIC_TYPE_CHAR = 0x40; ///< Numeric output.
static constexpr uint8_t SIGN_CHAR = 0x80; ///< Is sign character.
- } _prop; ///< Character property
map.
+ };
+ static const Property &
+ Get_Prop()
+ {
+ static const Property prop;
+ return prop;
+ } ///< Character property map.
};
/** Format string support.
@@ -474,37 +480,37 @@ extern ExternalNames& Global_Names();
inline Spec::Align
Spec::align_of(char c) {
- return static_cast<Align>(_prop._data[static_cast<unsigned>(c)] &
Property::ALIGN_MASK);
+ return static_cast<Align>(Get_Prop()._data[static_cast<unsigned>(c)] &
Property::ALIGN_MASK);
}
inline bool
Spec::is_sign(char c) {
- return _prop._data[static_cast<unsigned>(c)] & Property::SIGN_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(c)] & Property::SIGN_CHAR;
}
inline bool
Spec::is_type(char c) {
- return _prop._data[static_cast<unsigned>(c)] & Property::TYPE_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(c)] & Property::TYPE_CHAR;
}
inline bool
Spec::is_upper_case_type(char c) {
- return _prop._data[static_cast<unsigned>(c)] & Property::UPPER_TYPE_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(c)] &
Property::UPPER_TYPE_CHAR;
}
inline bool
Spec::is_numeric_type(char c) {
- return _prop._data[static_cast<unsigned>(c)] & Property::NUMERIC_TYPE_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(c)] &
Property::NUMERIC_TYPE_CHAR;
}
inline bool
Spec::has_numeric_type() const {
- return _prop._data[static_cast<unsigned>(_type)] &
Property::NUMERIC_TYPE_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(_type)] &
Property::NUMERIC_TYPE_CHAR;
}
inline bool
Spec::has_upper_case_type() const {
- return _prop._data[static_cast<unsigned>(_type)] & Property::UPPER_TYPE_CHAR;
+ return Get_Prop()._data[static_cast<unsigned>(_type)] &
Property::UPPER_TYPE_CHAR;
}
inline bool
diff --git a/lib/swoc/src/bw_format.cc b/lib/swoc/src/bw_format.cc
index a5ccbb7150..5b87fc9909 100644
--- a/lib/swoc/src/bw_format.cc
+++ b/lib/swoc/src/bw_format.cc
@@ -37,8 +37,6 @@ ExternalNames& Global_Names() {
const Spec Spec::DEFAULT;
-const Spec::Property Spec::_prop;
-
#pragma GCC diagnostic ignored "-Wchar-subscripts"
Spec::Property::Property() {