mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
refactor: add self-assign checks to classes which violate the clang-tidy check
Both of these cases appear to be harmless, but adding the tests allows us to turn on the aggressive clang-tidy checks.
This commit is contained in:
@@ -43,8 +43,10 @@ public:
|
||||
|
||||
base_uint& operator=(const base_uint& b)
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
pn[i] = b.pn[i];
|
||||
if (this != &b) {
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
pn[i] = b.pn[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
14
src/key.h
14
src/key.h
@@ -75,13 +75,15 @@ public:
|
||||
|
||||
CKey& operator=(const CKey& other)
|
||||
{
|
||||
if (other.keydata) {
|
||||
MakeKeyData();
|
||||
*keydata = *other.keydata;
|
||||
} else {
|
||||
ClearKeyData();
|
||||
if (this != &other) {
|
||||
if (other.keydata) {
|
||||
MakeKeyData();
|
||||
*keydata = *other.keydata;
|
||||
} else {
|
||||
ClearKeyData();
|
||||
}
|
||||
fCompressed = other.fCompressed;
|
||||
}
|
||||
fCompressed = other.fCompressed;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1508,8 +1508,10 @@ struct Tracker
|
||||
Tracker(Tracker&& t) noexcept : origin(t.origin), copies(t.copies) {}
|
||||
Tracker& operator=(const Tracker& t) noexcept
|
||||
{
|
||||
origin = t.origin;
|
||||
copies = t.copies + 1;
|
||||
if (this != &t) {
|
||||
origin = t.origin;
|
||||
copies = t.copies + 1;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user