Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-diff-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: git fetch
- name: Run Clang-Format-Diff.py
run: |
git diff -U0 origin/develop -- . ':(exclude)src/qt/dashstrings.cpp' ':(exclude)src/qt/locale/' | ./contrib/devtools/clang-format-diff.py -p1 > diff_output.txt
git diff -U0 origin/develop -- $(git ls-files -- $(cat test/util/data/non-backported.txt)) | ./contrib/devtools/clang-format-diff.py -p1 > diff_output.txt
if [ -s diff_output.txt ]; then
echo "Clang format differences found:"
cat diff_output.txt
Expand Down
22 changes: 13 additions & 9 deletions src/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,34 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterFunction: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 4
Expand All @@ -37,7 +39,9 @@ MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PackConstructorInitializers: Never
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakAssignment: 100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 100
Expand All @@ -52,6 +56,6 @@ SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
Standard: Cpp11
Standard: c++20
TabWidth: 8
UseTab: Never
16 changes: 8 additions & 8 deletions src/wallet/bip39.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
int mlen = len * 3 / 4;
SecureString mnemonic;

int i, j, idx;
for (i = 0; i < mlen; i++) {
idx = 0;
for (j = 0; j < 11; j++) {
for (int i = 0; i < mlen; i++) {
int idx = 0;
for (int j = 0; j < 11; j++) {
idx <<= 1;
idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0;
}
Expand All @@ -76,7 +75,7 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
return mnemonic;
}

bool CMnemonic::Check(SecureString mnemonic)
bool CMnemonic::Check(const SecureString& mnemonic)
{
if (mnemonic.empty()) {
return false;
Expand All @@ -98,7 +97,7 @@ bool CMnemonic::Check(SecureString mnemonic)
SecureString ssCurrentWord;
SecureVector bits(32 + 1);

uint32_t nWordIndex, ki, nBitsCount{};
uint32_t ki, nBitsCount{};

for (size_t i = 0; i < mnemonic.size(); ++i)
{
Expand All @@ -110,7 +109,7 @@ bool CMnemonic::Check(SecureString mnemonic)
ssCurrentWord += mnemonic[i + ssCurrentWord.size()];
}
i += ssCurrentWord.size();
nWordIndex = 0;
uint32_t nWordIndex = 0;
for (;;) {
if (!wordlist[nWordIndex]) { // word not found
return false;
Expand Down Expand Up @@ -140,8 +139,9 @@ bool CMnemonic::Check(SecureString mnemonic)
}

// passphrase must be at most 256 characters otherwise it would be truncated
void CMnemonic::ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
void CMnemonic::ToSeed(const SecureString& mnemonic, const SecureString& passphrase, SecureVector& seedRet)
{

SecureString ssSalt = SecureString("mnemonic") + passphrase;
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
seedRet.resize(64);
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/bip39.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class CMnemonic
public:
static SecureString Generate(int strength); // strength in bits
static SecureString FromData(const SecureVector& data, int len);
static bool Check(SecureString mnemonic);
static bool Check(const SecureString& mnemonic);
// passphrase must be at most 256 characters otherwise it would be truncated
static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet);
static void ToSeed(const SecureString& mnemonic, const SecureString& passphrase, SecureVector& seedRet);
};

#endif // BITCOIN_WALLET_BIP39_H
45 changes: 3 additions & 42 deletions test/lint/lint-cppcheck-dash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ IGNORED_WARNINGS=(
"src/llmq/commitment.cpp.* warning: Consider using std::all_of or std::none_of algorithm instead of a raw loop. \[useStlAlgorithm\]"
"src/rpc/.*cpp:.*: note: Function pointer used here."
"src/masternode/sync.cpp:.*: warning: Variable 'pnode' can be declared as pointer to const \[constVariableReference\]"
"src/wallet/bip39.cpp.*: warning: The scope of the variable 'ssCurrentWord' can be reduced. \[variableScope\]"


"src/stacktraces.cpp:.*: .*: Parameter 'info' can be declared as pointer to const"
"src/stacktraces.cpp:.*: note: You might need to cast the function pointer here"
Expand All @@ -59,48 +61,7 @@ IGNORED_WARNINGS=(
)

# We should attempt to update this with all dash specific code
FILES=$(git ls-files -- "src/batchedlogger.*" \
"src/bench/bls*.cpp" \
"src/bls/*.cpp" \
"src/bls/*.h" \
"src/cachemap.h" \
"src/cachemultimap.h" \
"src/coinjoin/*.cpp" \
"src/coinjoin/*.h" \
"src/ctpl_stl.h" \
"src/cxxtimer.hpp" \
"src/dsnotificationinterface.*" \
"src/evo/*.cpp" \
"src/evo/*.h" \
"src/governance/*.cpp" \
"src/governance/*.h" \
"src/keepass.*" \
"src/llmq/*.cpp" \
"src/llmq/*.h" \
"src/masternode/*.cpp" \
"src/masternode/*.h" \
"src/messagesigner.*" \
"src/netfulfilledman.*" \
"src/qt/governancelist.*" \
"src/qt/masternodelist.*" \
"src/rpc/coinjoin.cpp" \
"src/rpc/evo.cpp" \
"src/rpc/governance.cpp" \
"src/rpc/masternode.cpp" \
"src/rpc/quorums.cpp" \
"src/saltedhasher.*" \
"src/spork.*" \
"src/stacktraces.*" \
"src/statsd_client.*" \
"src/test/block_reward_reallocation_tests.cpp" \
"src/test/bls_tests.cpp" \
"src/test/dip0020opcodes_tests.cpp" \
"src/test/dynamic_activation*.cpp" \
"src/test/evo*.cpp" \
"src/test/governance*.cpp" \
"src/wallet/hdchain.*" \
"src/unordered_lru_cache.h" \
)
FILES=$(git ls-files -- $(cat test/util/data/non-backported.txt))


if ! command -v cppcheck > /dev/null; then
Expand Down
41 changes: 41 additions & 0 deletions test/util/data/non-backported.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
src/batchedlogger.*
src/bench/bls*.cpp
src/bls/*.cpp
src/bls/*.h
src/cachemap.h
src/cachemultimap.h
src/coinjoin/*.cpp
src/coinjoin/*.h
src/ctpl_stl.h
src/cxxtimer.hpp
src/dsnotificationinterface.*
src/evo/*.cpp
src/evo/*.h
src/governance/*.cpp
src/governance/*.h
src/llmq/*.cpp
src/llmq/*.h
src/masternode/*.cpp
src/masternode/*.h
src/messagesigner.*
src/netfulfilledman.*
src/qt/governancelist.*
src/qt/masternodelist.*
src/rpc/coinjoin.cpp
src/rpc/evo.cpp
src/rpc/governance.cpp
src/rpc/masternode.cpp
src/rpc/quorums.cpp
src/saltedhasher.*
src/spork.*
src/stacktraces.*
src/statsd_client.*
src/test/block_reward_reallocation_tests.cpp
src/test/bls_tests.cpp
src/test/dip0020opcodes_tests.cpp
src/test/dynamic_activation*.cpp
src/test/evo*.cpp
src/test/governance*.cpp
src/unordered_lru_cache.h
src/wallet/bip39*
src/wallet/hdchain.*