fuzz: pull latest FuzzedDataProvider.h from upstream
What changed, and why it matters
This commit updates a single test-only helper file used for fuzz testing. It removes an outdated comment and switches one conditional to use a C++17 compile-time feature. The changes do not touch production Bitcoin code, wallets, networking, consensus rules, or any user-facing functionality. There is no security issue here.
No action required. This is a routine test-infrastructure maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch synchronizes src/test/fuzz/FuzzedDataProvider.h with upstream LLVM. It removes a TODO comment about C++14 static_assert and replaces a runtime if with if constexpr in ConvertUnsignedToSigned, plus precomputes TS_max as a constexpr. These are code-quality/C++ modernization changes inside a fuzzing utility. The file is only compiled into test/fuzz targets, not into bitcoind or bitcoin-qt.
Changed components
src/test/fuzz/FuzzedDataProvider.hInspect captured patch +3 / −4
diff --git a/src/test/fuzz/FuzzedDataProvider.h b/src/test/fuzz/FuzzedDataProvider.h
index 11f2fbdb..5fab0c46 100644
--- a/src/test/fuzz/FuzzedDataProvider.h
+++ b/src/test/fuzz/FuzzedDataProvider.h
@@ -314,7 +314,6 @@ T FuzzedDataProvider::PickValueInArray(const std::array<T, size> &array) {
template <typename T>
T FuzzedDataProvider::PickValueInArray(std::initializer_list<const T> list) {
- // TODO(Dor1s): switch to static_assert once C++14 is allowed.
if (!list.size())
abort();
@@ -381,13 +380,13 @@ TS FuzzedDataProvider::ConvertUnsignedToSigned(TU value) {
static_assert(!std::numeric_limits<TU>::is_signed,
"Source type must be unsigned.");
- // TODO(Dor1s): change to `if constexpr` once C++17 becomes mainstream.
- if (std::numeric_limits<TS>::is_modulo)
+ if constexpr (std::numeric_limits<TS>::is_modulo)
return static_cast<TS>(value);
// Avoid using implementation-defined unsigned to signed conversions.
// To learn more, see https://stackoverflow.com/questions/13150449.
- if (value <= std::numeric_limits<TS>::max()) {
+ constexpr auto TS_max = static_cast<TU>(std::numeric_limits<TS>::max());
+ if (value <= TS_max) {
return static_cast<TS>(value);
} else {
constexpr auto TS_min = std::numeric_limits<TS>::min();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.