Skip to content

Commit

Permalink
refactor: add self-assign checks to classes which violate the clang-t…
Browse files Browse the repository at this point in the history
…idy check

Both of these cases appear to be harmless, but adding the tests allows us to
turn on the aggressive clang-tidy checks.
  • Loading branch information
theuni committed Jun 5, 2024
1 parent ff7d205 commit 027907d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ class base_uint

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;
}

Expand Down
14 changes: 8 additions & 6 deletions src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ class CKey

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;
}

Expand Down

0 comments on commit 027907d

Please sign in to comment.