From eebf35b8b48b9349bbd2cd544cb25a55af97dfcc Mon Sep 17 00:00:00 2001 From: Shubham Mathur Date: Sat, 22 May 2021 21:27:59 +1000 Subject: [PATCH] Avoid &foo[0] on C-Style arrays Confusing as some parts of class use redundant operators and other parts do not. --- src/key.cpp | 4 ++-- src/key.h | 2 +- src/pubkey.cpp | 2 +- src/pubkey.h | 2 +- src/zmq/zmqpublishnotifier.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index 846ee7448..e723ac0f0 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -245,7 +245,7 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const { out.nDepth = nDepth + 1; CKeyID id = key.GetPubKey().GetID(); - memcpy(&out.vchFingerprint[0], &id, 4); + memcpy(out.vchFingerprint, &id, 4); out.nChild = _nChild; return key.Derive(out.key, out.chaincode, _nChild, chaincode); } @@ -264,7 +264,7 @@ void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) { CExtPubKey CExtKey::Neuter() const { CExtPubKey ret; ret.nDepth = nDepth; - memcpy(&ret.vchFingerprint[0], &vchFingerprint[0], 4); + memcpy(ret.vchFingerprint, vchFingerprint, 4); ret.nChild = nChild; ret.pubkey = key.GetPubKey(); ret.chaincode = chaincode; diff --git a/src/key.h b/src/key.h index 37c74e873..c195f1d17 100644 --- a/src/key.h +++ b/src/key.h @@ -150,7 +150,7 @@ struct CExtKey { friend bool operator==(const CExtKey& a, const CExtKey& b) { return a.nDepth == b.nDepth && - memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], sizeof(vchFingerprint)) == 0 && + memcmp(a.vchFingerprint, b.vchFingerprint, sizeof(vchFingerprint)) == 0 && a.nChild == b.nChild && a.chaincode == b.chaincode && a.key == b.key; diff --git a/src/pubkey.cpp b/src/pubkey.cpp index cb5ad1917..e2ee5f901 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -281,7 +281,7 @@ void CExtPubKey::Decode(const unsigned char code[BIP32_EXTKEY_SIZE]) { bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const { out.nDepth = nDepth + 1; CKeyID id = pubkey.GetID(); - memcpy(&out.vchFingerprint[0], &id, 4); + memcpy(out.vchFingerprint, &id, 4); out.nChild = _nChild; return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode); } diff --git a/src/pubkey.h b/src/pubkey.h index 947423ae6..12d75aa66 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -214,7 +214,7 @@ struct CExtPubKey { friend bool operator==(const CExtPubKey &a, const CExtPubKey &b) { return a.nDepth == b.nDepth && - memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], sizeof(vchFingerprint)) == 0 && + memcmp(a.vchFingerprint, b.vchFingerprint, sizeof(vchFingerprint)) == 0 && a.nChild == b.nChild && a.chaincode == b.chaincode && a.pubkey == b.pubkey; diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index e63cfd178..557445c7a 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -135,7 +135,7 @@ bool CZMQAbstractPublishNotifier::SendMessage(const char *command, const void* d /* send three parts, command & data & a LE 4byte sequence number */ unsigned char msgseq[sizeof(uint32_t)]; - WriteLE32(&msgseq[0], nSequence); + WriteLE32(msgseq, nSequence); int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, msgseq, (size_t)sizeof(uint32_t), (void*)0); if (rc == -1) return false;