Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clang-format #4414

Merged
merged 2 commits into from
Feb 1, 2024
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
37 changes: 26 additions & 11 deletions .github/workflows/analyzers.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
name: Static Analyzers

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
clang_format:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
- name: Installing clang-format 12
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0

- name: Installing clang-format
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt-get install clang-format-12
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
sudo apt install clang-format-17

- name: Check clang-format
run: ci/clang-format-check.sh



cmake_format:
runs-on: ubuntu-20.04
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 #v4.3.0
with:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0

- name: Setup Python
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 #v4.3.0
with:
python-version: '3.x'
architecture: 'x64'
- uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318
with:

- name: Install cmake-format
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318
with:
packages: |
cmake-format

- name: Check cmake-format
run: ci/cmake-format-check.sh


code_inspector:
runs-on: ubuntu-20.04
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down
2 changes: 1 addition & 1 deletion ci/impl/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###################################################################################################

CLANG_FORMAT=""
CLANG_FORMAT_VERSION="12"
CLANG_FORMAT_VERSION="17"

###################################################################################################

Expand Down
6 changes: 3 additions & 3 deletions nano/lib/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ nano::error::operator std::string () const
}

/**
* Get error message, or an empty string if there's no error. If a custom error message is set,
* that will be returned, otherwise the error_code#message() is returned.
*/
* Get error message, or an empty string if there's no error. If a custom error message is set,
* that will be returned, otherwise the error_code#message() is returned.
*/
std::string nano::error::get_message () const
{
std::string res = message;
Expand Down
2 changes: 1 addition & 1 deletion nano/lib/ipc_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace ipc
}

/**
* Returns a buffer with an IPC preamble for the given \p encoding_a followed by the payload. Depending on encoding,
* Returns a buffer with an IPC preamble for the given \p encoding_a followed by the payload. Depending on encoding,
* the buffer may contain a payload length or end sentinel.
*/
nano::shared_const_buffer prepare_request (nano::ipc::payload_encoding encoding_a, std::string const & payload_a);
Expand Down
2 changes: 1 addition & 1 deletion nano/lib/jsonconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ nano::jsonconfig::jsonconfig (boost::property_tree::ptree & tree_a, std::shared_
}

/**
* Reads a json object from the stream
* Reads a json object from the stream
* @return nano::error&, including a descriptive error message if the config file is malformed.
*/
nano::error & nano::jsonconfig::read (std::filesystem::path const & path_a)
Expand Down
6 changes: 3 additions & 3 deletions nano/lib/locks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class unique_lock final
};

/** Assumes std implementations of std::condition_variable never actually call nano::unique_lock::lock/unlock,
but instead use OS intrinsics with the mutex handle directly. Due to this we also do not account for any
but instead use OS intrinsics with the mutex handle directly. Due to this we also do not account for any
time the condition variable is blocked on another holder of the mutex. */
class condition_variable final
{
Expand Down Expand Up @@ -283,7 +283,7 @@ class locked
owner->mutex.unlock ();
}

T * operator-> ()
T * operator->()
{
return &owner->obj;
}
Expand All @@ -301,7 +301,7 @@ class locked
locked * owner{ nullptr };
};

scoped_lock operator-> ()
scoped_lock operator->()
{
return scoped_lock (this);
}
Expand Down
4 changes: 2 additions & 2 deletions nano/lib/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ bool get_use_memory_pools ();
void set_use_memory_pools (bool use_memory_pools);

/** This makes some heuristic assumptions about the implementation defined shared_ptr internals.
Should only be used in the memory pool purge functions at exit, which doesn't matter much if
it is incorrect (other than reports from heap memory analysers) */
Should only be used in the memory pool purge functions at exit, which doesn't matter much if
it is incorrect (other than reports from heap memory analysers) */
template <typename T>
constexpr size_t determine_shared_ptr_pool_size ()
{
Expand Down
8 changes: 4 additions & 4 deletions nano/lib/optional_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class optional_ptr
return *ptr;
}

T * const operator-> ()
T * const operator->()
{
return ptr.operator-> ();
return ptr.operator->();
}

T const * const operator-> () const
T const * const operator->() const
{
return ptr.operator-> ();
return ptr.operator->();
}

T const * const get () const
Expand Down
4 changes: 2 additions & 2 deletions nano/lib/tomlconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ std::shared_ptr<cpptoml::array> nano::tomlconfig::create_array (std::string cons
}

/**
* Erase keys whose values are equal to the one in \p defaults
*/
* Erase keys whose values are equal to the one in \p defaults
*/
void nano::tomlconfig::erase_default_values (tomlconfig & defaults_a)
{
std::shared_ptr<cpptoml::table> clone = std::dynamic_pointer_cast<cpptoml::table> (tree->clone ());
Expand Down
8 changes: 4 additions & 4 deletions nano/slow_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TEST (bootstrap_ascending, profile)
flags_server.disable_ongoing_bootstrap = true;
flags_server.disable_ascending_bootstrap = true;
auto data_path_server = nano::working_path (network);
//auto data_path_server = "";
// auto data_path_server = "";
auto server = std::make_shared<nano::node> (system.io_ctx, data_path_server, config_server, system.work, flags_server);
system.nodes.push_back (server);
server->start ();
Expand All @@ -93,10 +93,10 @@ TEST (bootstrap_ascending, profile)
config_client.ipc_config.transport_tcp.enabled = true;
// Disable database integrity safety for higher throughput
config_client.lmdb_config.sync = nano::lmdb_config::sync_strategy::nosync_unsafe;
//auto client = system.add_node (config_client, flags_client);
// auto client = system.add_node (config_client, flags_client);

// macos 16GB RAM disk: diskutil erasevolume HFS+ "RAMDisk" `hdiutil attach -nomount ram://33554432`
//auto data_path_client = "/Volumes/RAMDisk";
// auto data_path_client = "/Volumes/RAMDisk";
auto data_path_client = nano::unique_path ();
auto client = std::make_shared<nano::node> (system.io_ctx, data_path_client, config_client, system.work, flags_client);
system.nodes.push_back (client);
Expand Down Expand Up @@ -186,7 +186,7 @@ TEST (bootstrap_ascending, profile)
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_previous, nano::stat::dir::in);
rate.background_print (3s);

//wait_for_key ();
// wait_for_key ();
while (true)
{
nano::test::establish_tcp (system, *client, server->network.endpoint ());
Expand Down
2 changes: 1 addition & 1 deletion nano/store/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class iterator final
return *this;
}
iterator<T, U> & operator= (iterator<T, U> const &) = delete;
std::pair<T, U> * operator-> ()
std::pair<T, U> * operator->()
{
return &current;
}
Expand Down
24 changes: 12 additions & 12 deletions nano/store/lmdb/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ class account : public nano::store::account
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::account, nano::account_info>, store::iterator<nano::account, nano::account_info>)> const & action_a) const override;

/**
* Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed)
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
*/
* Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed)
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
*/
MDB_dbi accounts_v0_handle{ 0 };

/**
* Maps account v0 to account information, head, rep, open, balance, timestamp and block count. (Removed)
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
*/
* Maps account v0 to account information, head, rep, open, balance, timestamp and block count. (Removed)
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
*/
MDB_dbi accounts_v1_handle{ 0 };

/**
* Maps account v0 to account information, head, rep, open, balance, timestamp, block count and epoch
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t, nano::epoch
*/
* Maps account v0 to account information, head, rep, open, balance, timestamp, block count and epoch
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t, nano::epoch
*/
MDB_dbi accounts_handle{ 0 };

/**
* Representative weights. (Removed)
* nano::account -> nano::uint128_t
*/
* Representative weights. (Removed)
* nano::account -> nano::uint128_t
*/
MDB_dbi representation_handle{ 0 };
};
} // amespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class block : public nano::store::block
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::block_hash, block_w_sideband>, store::iterator<nano::block_hash, block_w_sideband>)> const & action_a) const override;

/**
* Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks)
* nano::block_hash -> nano::block_sideband, nano::block
*/
* Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks)
* nano::block_hash -> nano::block_sideband, nano::block
*/
MDB_dbi blocks_handle{ 0 };

protected:
Expand Down
6 changes: 3 additions & 3 deletions nano/store/lmdb/confirmation_height.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class confirmation_height : public nano::store::confirmation_height
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::account, nano::confirmation_height_info>, store::iterator<nano::account, nano::confirmation_height_info>)> const & action_a) const override;

/*
* Confirmation height of an account, and the hash for the block at that height
* nano::account -> uint64_t, nano::block_hash
*/
* Confirmation height of an account, and the hash for the block at that height
* nano::account -> uint64_t, nano::block_hash
*/
MDB_dbi confirmation_height_handle{ 0 };
};
} // namespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/final_vote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class final_vote : public nano::store::final_vote
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::qualified_root, nano::block_hash>, store::iterator<nano::qualified_root, nano::block_hash>)> const & action_a) const override;

/**
* Maps root to block hash for generated final votes.
* nano::qualified_root -> nano::block_hash
*/
* Maps root to block hash for generated final votes.
* nano::qualified_root -> nano::block_hash
*/
MDB_dbi final_votes_handle{ 0 };
};
} // namespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/frontier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class frontier : public nano::store::frontier
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::block_hash, nano::account>, store::iterator<nano::block_hash, nano::account>)> const & action_a) const override;

/**
* Maps head block to owning account
* nano::block_hash -> nano::account
*/
* Maps head block to owning account
* nano::block_hash -> nano::account
*/
MDB_dbi frontiers_handle{ 0 };
};
} // namespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class iterator : public iterator_impl<T, U>
return *this;
}

std::pair<store::db_val<MDB_val>, store::db_val<MDB_val>> * operator-> ()
std::pair<store::db_val<MDB_val>, store::db_val<MDB_val>> * operator->()
{
return &current;
}
Expand Down Expand Up @@ -213,9 +213,9 @@ class merge_iterator : public iterator_impl<T, U>
return *this;
}

std::pair<store::db_val<MDB_val>, store::db_val<MDB_val>> * operator-> ()
std::pair<store::db_val<MDB_val>, store::db_val<MDB_val>> * operator->()
{
return least_iterator ().operator-> ();
return least_iterator ().operator->();
}

bool operator== (merge_iterator<T, U> const & other) const
Expand Down
6 changes: 3 additions & 3 deletions nano/store/lmdb/online_weight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class online_weight : public nano::store::online_weight
void clear (store::write_transaction const & transaction_a) override;

/**
* Samples of online vote weight
* uint64_t -> nano::amount
*/
* Samples of online vote weight
* uint64_t -> nano::amount
*/
MDB_dbi online_weight_handle{ 0 };
};
} // namespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/peer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class peer : public nano::store::peer
store::iterator<nano::endpoint_key, nano::no_value> end () const override;

/*
* Endpoints for peers
* nano::endpoint_key -> no_value
*/
* Endpoints for peers
* nano::endpoint_key -> no_value
*/
MDB_dbi peers_handle{ 0 };
};
} // namespace nano::store::lmdb
18 changes: 9 additions & 9 deletions nano/store/lmdb/pending.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ class pending : public nano::store::pending
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::pending_key, nano::pending_info>, store::iterator<nano::pending_key, nano::pending_info>)> const & action_a) const override;

/**
* Maps min_version 0 (destination account, pending block) to (source account, amount). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount
*/
* Maps min_version 0 (destination account, pending block) to (source account, amount). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount
*/
MDB_dbi pending_v0_handle{ 0 };

/**
* Maps min_version 1 (destination account, pending block) to (source account, amount). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount
*/
* Maps min_version 1 (destination account, pending block) to (source account, amount). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount
*/
MDB_dbi pending_v1_handle{ 0 };

/**
* Maps (destination account, pending block) to (source account, amount, version). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount, nano::epoch
*/
* Maps (destination account, pending block) to (source account, amount, version). (Removed)
* nano::account, nano::block_hash -> nano::account, nano::amount, nano::epoch
*/
MDB_dbi pending_handle{ 0 };
};
} // namespace nano::store::lmdb
6 changes: 3 additions & 3 deletions nano/store/lmdb/pruned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class pruned : public nano::store::pruned
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::block_hash, std::nullptr_t>, store::iterator<nano::block_hash, std::nullptr_t>)> const & action_a) const override;

/**
* Pruned blocks hashes
* nano::block_hash -> none
*/
* Pruned blocks hashes
* nano::block_hash -> none
*/
MDB_dbi pruned_handle{ 0 };
};
} // namespace nano::store::lmdb
Loading
Loading