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 committed 2024-06-14 10:27:03 +00:00
1 parent 0b94fb8720
commit 32b1d13792
3 files changed
+16 -10

No files matched your search

+4 -2
View File
@@ -43,8 +43,10 @@ public:
base_uint& operator=(const base_uint& b) base_uint& operator=(const base_uint& b)
{ {
for (int i = 0; i < WIDTH; i++) if (this != &b) {
pn[i] = b.pn[i]; for (int i = 0; i < WIDTH; i++)
pn[i] = b.pn[i];
}
return *this; return *this;
} }
+8 -6
View File
@@ -75,13 +75,15 @@ public:
CKey& operator=(const CKey& other) CKey& operator=(const CKey& other)
{ {
if (other.keydata) { if (this != &other) {
MakeKeyData(); if (other.keydata) {
*keydata = *other.keydata; MakeKeyData();
} else { *keydata = *other.keydata;
ClearKeyData(); } else {
ClearKeyData();
}
fCompressed = other.fCompressed;
} }
fCompressed = other.fCompressed;
return *this; return *this;
} }
+4 -2
View File
@@ -1508,8 +1508,10 @@ struct Tracker
Tracker(Tracker&& t) noexcept : origin(t.origin), copies(t.copies) {} Tracker(Tracker&& t) noexcept : origin(t.origin), copies(t.copies) {}
Tracker& operator=(const Tracker& t) noexcept Tracker& operator=(const Tracker& t) noexcept
{ {
origin = t.origin; if (this != &t) {
copies = t.copies + 1; origin = t.origin;
copies = t.copies + 1;
}
return *this; return *this;
} }
}; };