Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Commit a44caf6

Browse files
committed
Merge #28: Import fixes for sanitizer reported issues
1352543 Import fixes for sanitizer reported issues (fanquake) d5fb869 refactor: use c++11 range based for loop in checkObject (fanquake) ff9c379 refactor: Use nullptr (c++11) instead of NULL (Barry Deeney) 08a9975 build: use ax_cxx_compile_stdcxx.m4 to check for C++11 support (Barry Deeney) Pull request description: See discussion in bitcoin/bitcoin#22646. Note that this code takes advantage of C++11 features, however this is fine, because this tree is for our downstream use, where we already require C++17. Co-authored-by: MarcoFalke <falke.marco@gmail.com> ACKs for top commit: MarcoFalke: Concept ACK 1352543 🚍 Tree-SHA512: fbbee06630d3702953c290a5a4a2fe843770deb128534b62106230ecb020486b55dffdf25bf1acd6bc3f7f68c4539bc907e1fb159c3d2a95d4edaa00b1fcf8bd
2 parents 66d3713 + 1352543 commit a44caf6

File tree

9 files changed

+1202
-235
lines changed

9 files changed

+1202
-235
lines changed

build-aux/m4/ax_cxx_compile_stdcxx.m4

Lines changed: 962 additions & 0 deletions
Large diffs are not rendered by default.

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ AC_SUBST(LIBUNIVALUE_AGE)
4545
LT_INIT
4646
LT_LANG([C++])
4747

48+
dnl Require C++11 compiler (no GNU extensions)
49+
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault])
50+
4851
case $host in
4952
*mingw*)
5053
LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"

gen/gen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void outputEscape()
4545

4646
for (unsigned int i = 0; i < 256; i++) {
4747
if (escapes[i].empty()) {
48-
printf("\tNULL,\n");
48+
printf("\tnullptr,\n");
4949
} else {
5050
printf("\t\"");
5151

lib/univalue.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,19 @@ bool UniValue::findKey(const std::string& key, size_t& retIdx) const
178178

179179
bool UniValue::checkObject(const std::map<std::string,UniValue::VType>& t) const
180180
{
181-
if (typ != VOBJ)
181+
if (typ != VOBJ) {
182182
return false;
183+
}
183184

184-
for (std::map<std::string,UniValue::VType>::const_iterator it = t.begin();
185-
it != t.end(); ++it) {
185+
for (const auto& object: t) {
186186
size_t idx = 0;
187-
if (!findKey(it->first, idx))
187+
if (!findKey(object.first, idx)) {
188188
return false;
189+
}
189190

190-
if (values.at(idx).getType() != it->second)
191+
if (values.at(idx).getType() != object.second) {
191192
return false;
193+
}
192194
}
193195

194196
return true;
@@ -228,7 +230,7 @@ const char *uvTypeName(UniValue::VType t)
228230
}
229231

230232
// not reached
231-
return NULL;
233+
return nullptr;
232234
}
233235

234236
const UniValue& find_value(const UniValue& obj, const std::string& name)

0 commit comments

Comments
 (0)