refactor: Replace memset calls with array initialization#21939
refactor: Replace memset calls with array initialization#21939laanwj merged 1 commit intobitcoin:masterfrom
Conversation
|
re-ACK 1c9255c Checked the disassembly with It doesn't generate memsets, but the Second constructor DetailsThis one is more complex, but it works out, contains the same clearing code: |
|
For reference, from https://en.cppreference.com/w/c/language/array_initialization
|
kristapsk
left a comment
There was a problem hiding this comment.
utACK 5d2e40c4d2394758e8026f796de89e8569f8dc86, code looks correct.
| memset(pchChecksum, 0, CHECKSUM_SIZE); | ||
| } | ||
|
|
||
| CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn) |
There was a problem hiding this comment.
We could also change the type here to std::string or std::span instead of a loose pointer, at some point and clean up the loop (oh and rename the argument to message_type maybe instead of command, when we're at it). No need to do so in this PR though.
|
Code review ACK 1c9255c Looking at the code I noticed both |
|
I have a patchset to remove |
Another good point. There are only very few places where bare 'char' is a good choice. But let's leave it for a future PR. |
…lization 1c9255c refactor: Replace memset calls with array initialization (João Barbosa) Pull request description: Follow up to bitcoin#21905 (review). ACKs for top commit: laanwj: re-ACK 1c9255c Crypt-iQ: Code review ACK 1c9255c Tree-SHA512: 4b61dec2094f4781ef1c0427ee3bda3cfea12111274eebc7bc40a84f261d9c1681dd0860c57200bea2456588e44e8e0aecd18545c25f1f1250dd331ab7d05f28
Follow up to #21905 (review).