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:
Cory Fields 2024-06-05 17:42:27 +00:00
parent 0b94fb8720
commit 32b1d13792
3 changed files with 16 additions and 10 deletions

View file

@ -43,8 +43,10 @@ public:
base_uint& operator=(const base_uint& b)
{
if (this != &b) {
for (int i = 0; i < WIDTH; i++)
pn[i] = b.pn[i];
}
return *this;
}

View file

@ -75,6 +75,7 @@ public:
CKey& operator=(const CKey& other)
{
if (this != &other) {
if (other.keydata) {
MakeKeyData();
*keydata = *other.keydata;
@ -82,6 +83,7 @@ public:
ClearKeyData();
}
fCompressed = other.fCompressed;
}
return *this;
}

View file

@ -1508,8 +1508,10 @@ struct Tracker
Tracker(Tracker&& t) noexcept : origin(t.origin), copies(t.copies) {}
Tracker& operator=(const Tracker& t) noexcept
{
if (this != &t) {
origin = t.origin;
copies = t.copies + 1;
}
return *this;
}
};