From ce865a9ba86e603e6eb69aba53f791203b80fcb2 Mon Sep 17 00:00:00 2001 From: marco <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 14 Jul 2026 11:05:39 +0200 Subject: [PATCH 1/3] refactor: Directly use value in CustomBuildField This avoids a std::span ctor. Recommended in https://github.com/bitcoin-core/libmultiprocess/pull/305#pullrequestreview-4689778284 --- include/mp/type-data.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/mp/type-data.h b/include/mp/type-data.h index 09c93df9..9110be91 100644 --- a/include/mp/type-data.h +++ b/include/mp/type-data.h @@ -32,9 +32,8 @@ template void CustomBuildField(TypeList, Priority<2>, InvokeContext& invoke_context, Value&& value, Output&& output) requires (std::is_same_v && IsByteSpan) { - auto data = std::span{value}; - auto result = output.init(data.size()); - std::ranges::copy(data, result.begin()); + auto result = output.init(value.size()); + std::ranges::copy(value, result.begin()); } template From 17eab90b526e3fb713acbda1ec01321f2b9f2e84 Mon Sep 17 00:00:00 2001 From: marco <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 14 Jul 2026 11:06:41 +0200 Subject: [PATCH 2/3] test: Fix typo in listen_tests.cpp Recommended by the LLM in https://github.com/bitcoin/bitcoin/pull/35684#issuecomment-4916571942 --- test/mp/test/listen_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mp/test/listen_tests.cpp b/test/mp/test/listen_tests.cpp index 1506eaa4..24ca1652 100644 --- a/test/mp/test/listen_tests.cpp +++ b/test/mp/test/listen_tests.cpp @@ -225,7 +225,7 @@ KJ_TEST("ListenConnections enforces a local connection limit") { // With max-connections=1, the second socket can connect to the kernel // backlog, but ListenConnections should not accept or serve it until the - // first accepts clients disconnects. + // first accepted client disconnects. ListenSetup server(/*max_connections=*/1); From 8226c05549b0405ebac3208751c53a03563ea745 Mon Sep 17 00:00:00 2001 From: marco <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 14 Jul 2026 11:08:48 +0200 Subject: [PATCH 3/3] refactor: memcpy -> std::ranges::copy I think there is no issue of passing a nullptr here, but it makes sense to use the std-lib copy for consistency. Recommended in https://github.com/bitcoin-core/libmultiprocess/pull/305#pullrequestreview-4689778284 --- include/mp/type-char.h | 8 +++++--- include/mp/type-string.h | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/mp/type-char.h b/include/mp/type-char.h index b51ffeb1..19080b46 100644 --- a/include/mp/type-char.h +++ b/include/mp/type-char.h @@ -7,6 +7,9 @@ #include +#include +#include + namespace mp { template void CustomBuildField(TypeList, @@ -16,7 +19,7 @@ void CustomBuildField(TypeList, Output&& output) { auto result = output.init(size); - memcpy(result.begin(), value, size); + std::ranges::copy(value, result.begin()); } template @@ -27,8 +30,7 @@ decltype(auto) CustomReadField(TypeList, ReadDest&& read_dest) { return read_dest.update([&](auto& value) { - auto data = input.get(); - memcpy(value, data.begin(), size); + std::ranges::copy(input.get(), std::ranges::begin(value)); }); } } // namespace mp diff --git a/include/mp/type-string.h b/include/mp/type-string.h index d4c3383b..a8275a39 100644 --- a/include/mp/type-string.h +++ b/include/mp/type-string.h @@ -7,6 +7,9 @@ #include +#include +#include + namespace mp { template void CustomBuildField(TypeList, @@ -16,7 +19,7 @@ void CustomBuildField(TypeList, Output&& output) { auto result = output.init(value.size()); - memcpy(result.begin(), value.data(), value.size()); + std::ranges::copy(value, result.begin()); } template