From 24ba142c150e2bec21f345503b7ea053f0e222dc Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 8 Oct 2021 16:20:35 +0800 Subject: [PATCH] Import fixes for sanitizer reported issues See discussion in https://github.com/bitcoin/bitcoin/pull/22646. Co-authored-by: MarcoFalke --- lib/univalue_read.cpp | 4 ++-- lib/univalue_write.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/univalue_read.cpp b/lib/univalue_read.cpp index f8a5d4d..be39bfe 100644 --- a/lib/univalue_read.cpp +++ b/lib/univalue_read.cpp @@ -227,7 +227,7 @@ enum jtokentype getJsonToken(std::string& tokenVal, unsigned int& consumed, } else { - writer.push_back(*raw); + writer.push_back(static_cast(*raw)); raw++; } } @@ -244,7 +244,7 @@ enum jtokentype getJsonToken(std::string& tokenVal, unsigned int& consumed, } } -enum expect_bits { +enum expect_bits : unsigned { EXP_OBJ_NAME = (1U << 0), EXP_COLON = (1U << 1), EXP_ARR_VALUE = (1U << 2), diff --git a/lib/univalue_write.cpp b/lib/univalue_write.cpp index db039fc..3a2c580 100644 --- a/lib/univalue_write.cpp +++ b/lib/univalue_write.cpp @@ -13,13 +13,13 @@ static std::string json_escape(const std::string& inS) outS.reserve(inS.size() * 2); for (unsigned int i = 0; i < inS.size(); i++) { - unsigned char ch = inS[i]; + unsigned char ch = static_cast(inS[i]); const char *escStr = escapes[ch]; if (escStr) outS += escStr; else - outS += ch; + outS += static_cast(ch); } return outS;