Skip to content

Commit faece47

Browse files
author
MarcoFalke
committed
refactor: Avoid &foo[0] on C-Style arrays
This is confusing at best when parts of a class use the redundant operators and other parts do not.
1 parent face961 commit faece47

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/key.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
293293
bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
294294
out.nDepth = nDepth + 1;
295295
CKeyID id = key.GetPubKey().GetID();
296-
memcpy(&out.vchFingerprint[0], &id, 4);
296+
memcpy(out.vchFingerprint, &id, 4);
297297
out.nChild = _nChild;
298298
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
299299
}
@@ -312,7 +312,7 @@ void CExtKey::SetSeed(const unsigned char *seed, unsigned int nSeedLen) {
312312
CExtPubKey CExtKey::Neuter() const {
313313
CExtPubKey ret;
314314
ret.nDepth = nDepth;
315-
memcpy(&ret.vchFingerprint[0], &vchFingerprint[0], 4);
315+
memcpy(ret.vchFingerprint, vchFingerprint, 4);
316316
ret.nChild = nChild;
317317
ret.pubkey = key.GetPubKey();
318318
ret.chaincode = chaincode;

src/key.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct CExtKey {
151151
friend bool operator==(const CExtKey& a, const CExtKey& b)
152152
{
153153
return a.nDepth == b.nDepth &&
154-
memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], sizeof(vchFingerprint)) == 0 &&
154+
memcmp(a.vchFingerprint, b.vchFingerprint, sizeof(vchFingerprint)) == 0 &&
155155
a.nChild == b.nChild &&
156156
a.chaincode == b.chaincode &&
157157
a.key == b.key;

src/pubkey.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) {
293293
bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
294294
out.nDepth = nDepth + 1;
295295
CKeyID id = pubkey.GetID();
296-
memcpy(&out.vchFingerprint[0], &id, 4);
296+
memcpy(out.vchFingerprint, &id, 4);
297297
out.nChild = _nChild;
298298
return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode);
299299
}

src/pubkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct CExtPubKey {
247247
friend bool operator==(const CExtPubKey &a, const CExtPubKey &b)
248248
{
249249
return a.nDepth == b.nDepth &&
250-
memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], sizeof(vchFingerprint)) == 0 &&
250+
memcmp(a.vchFingerprint, b.vchFingerprint, sizeof(vchFingerprint)) == 0 &&
251251
a.nChild == b.nChild &&
252252
a.chaincode == b.chaincode &&
253253
a.pubkey == b.pubkey;

src/zmq/zmqpublishnotifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ bool CZMQAbstractPublishNotifier::SendZmqMessage(const char *command, const void
168168

169169
/* send three parts, command & data & a LE 4byte sequence number */
170170
unsigned char msgseq[sizeof(uint32_t)];
171-
WriteLE32(&msgseq[0], nSequence);
171+
WriteLE32(msgseq, nSequence);
172172
int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, msgseq, (size_t)sizeof(uint32_t), nullptr);
173173
if (rc == -1)
174174
return false;

0 commit comments

Comments
 (0)