From bc818e18efb6a7475b98215638c93d03c1e87dce Mon Sep 17 00:00:00 2001 From: Kangping Dong Date: Sun, 31 Mar 2024 22:02:58 +0800 Subject: [PATCH] [style] update formatter to clang-format-14 clang-format-14 is used by openthread and ot-br-posix, so just follow it. --- .github/workflows/android-app-build.yml | 2 +- .github/workflows/android-app-release.yml | 2 +- .github/workflows/build.yml | 14 +-- include/commissioner/commissioner.hpp | 14 +-- script/bootstrap.sh | 6 +- script/clang-format | 4 +- src/app/border_agent.cpp | 6 +- src/app/border_agent.hpp | 4 +- src/app/br_discover.cpp | 2 +- src/app/cli/interpreter.cpp | 4 +- src/app/cli/interpreter.hpp | 14 +-- src/app/cli/interpreter_test.cpp | 2 +- src/app/cli/job.cpp | 4 +- src/app/cli/job.hpp | 8 +- src/app/commissioner_app.cpp | 12 +- src/app/commissioner_app.hpp | 22 ++-- src/app/commissioner_app_dummy.cpp | 12 +- src/app/file_logger.hpp | 2 +- src/app/file_util_test.cpp | 2 +- src/app/mdns_handler.cpp | 8 +- src/app/mdns_handler.hpp | 4 +- src/app/ps/registry.cpp | 8 +- src/app/ps/registry_entries.cpp | 10 +- src/app/ps/registry_entries.hpp | 10 +- src/common/error_macros.hpp | 137 ++++++++++++++++------ src/library/cbor.hpp | 2 +- src/library/coap.cpp | 10 +- src/library/coap.hpp | 8 +- src/library/coap_secure_test.cpp | 2 +- src/library/coap_test.cpp | 2 +- src/library/commissioner_impl.cpp | 10 +- src/library/commissioner_impl.hpp | 9 +- src/library/commissioner_impl_test.cpp | 2 +- src/library/commissioner_safe.cpp | 2 +- src/library/commissioner_safe.hpp | 4 +- src/library/cose.cpp | 6 +- src/library/dtls.cpp | 2 +- src/library/dtls.hpp | 4 +- src/library/dtls_test.cpp | 2 +- src/library/joiner_session.cpp | 8 +- src/library/joiner_session.hpp | 14 +-- src/library/openthread/pbkdf2_cmac.cpp | 4 +- src/library/openthread/pbkdf2_cmac.hpp | 2 +- src/library/socket.hpp | 6 +- src/library/tlv.hpp | 2 +- src/library/token_manager.cpp | 16 +-- src/library/token_manager.hpp | 6 +- src/library/udp_proxy.cpp | 6 +- src/library/udp_proxy.hpp | 6 +- 49 files changed, 255 insertions(+), 193 deletions(-) diff --git a/.github/workflows/android-app-build.yml b/.github/workflows/android-app-build.yml index 3b20359ee..d79c323d9 100644 --- a/.github/workflows/android-app-build.yml +++ b/.github/workflows/android-app-build.yml @@ -37,7 +37,7 @@ jobs: matrix: android-api: [24, 34] android-abi: [x86_64] - os: [macos-12, ubuntu-20.04] + os: [macos-12, ubuntu-22.04] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v4 diff --git a/.github/workflows/android-app-release.yml b/.github/workflows/android-app-release.yml index 32842f1e4..6e3440fbb 100644 --- a/.github/workflows/android-app-release.yml +++ b/.github/workflows/android-app-release.yml @@ -35,7 +35,7 @@ on: [push, pull_request] jobs: build-release: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v4 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b4280291..2a1420615 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ on: [push, pull_request] jobs: cancel-previous-runs: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: rokroskar/workflow-run-cleanup-action@master env: @@ -41,13 +41,13 @@ jobs: if: "github.ref != 'refs/heads/main'" pretty: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Bootstrap run: | sudo apt update - sudo apt --no-install-recommends install -y clang-format-9 + sudo apt --no-install-recommends install -y clang-format-14 python3 -m pip install yapf==0.29.0 - name: Check run: | @@ -55,7 +55,7 @@ jobs: gcc-build: name: gcc-${{ matrix.gcc_ver }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: gcc_ver: [5, 6, 7, 8, 9, 10] @@ -95,7 +95,7 @@ jobs: clang-build: name: clang-${{ matrix.clang_ver }}-${{ matrix.build_type }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: clang_ver: [5, 6, 7, 8, 9, 10, 11] @@ -151,7 +151,7 @@ jobs: ./tests/interpreter-test android-ndk: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Bootstrap @@ -184,7 +184,7 @@ jobs: ninja fmt-format-check: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Bootstrap diff --git a/include/commissioner/commissioner.hpp b/include/commissioner/commissioner.hpp index ff543b1b8..31d0f5cda 100644 --- a/include/commissioner/commissioner.hpp +++ b/include/commissioner/commissioner.hpp @@ -199,13 +199,13 @@ class CommissionerHandler * @note This will be called when A well-formed JOIN_FIN.req has been received. * */ - virtual bool OnJoinerFinalize(const ByteArray & aJoinerId, + virtual bool OnJoinerFinalize(const ByteArray &aJoinerId, const std::string &aVendorName, const std::string &aVendorModel, const std::string &aVendorSwVersion, - const ByteArray & aVendorStackVersion, + const ByteArray &aVendorStackVersion, const std::string &aProvisioningUrl, - const ByteArray & aVendorData) + const ByteArray &aVendorData) { (void)aJoinerId; (void)aVendorName; @@ -251,7 +251,7 @@ class CommissionerHandler */ virtual void OnEnergyReport(const std::string &aPeerAddr, const ChannelMask &aChannelMask, - const ByteArray & aEnergyList) + const ByteArray &aEnergyList) { (void)aPeerAddr; (void)aChannelMask; @@ -1055,7 +1055,7 @@ class Commissioner * listener to the included multicast group(s) expires; In seconds. * @return Error::kNone, succeed, the address has been successfully registered; Otherwise, failed; */ - virtual Error RegisterMulticastListener(uint8_t & aStatus, + virtual Error RegisterMulticastListener(uint8_t &aStatus, const std::vector &aMulticastAddrList, uint32_t aTimeout) = 0; @@ -1116,10 +1116,10 @@ class Commissioner * * @return Error::kNone, succeed; Otherwise, failed; */ - static Error GeneratePSKc(ByteArray & aPSKc, + static Error GeneratePSKc(ByteArray &aPSKc, const std::string &aPassphrase, const std::string &aNetworkName, - const ByteArray & aExtendedPanId); + const ByteArray &aExtendedPanId); /** * @brief Compute joiner ID with its IEEE EUI-64 value. diff --git a/script/bootstrap.sh b/script/bootstrap.sh index 43ee39a79..fd94dcbab 100755 --- a/script/bootstrap.sh +++ b/script/bootstrap.sh @@ -92,7 +92,7 @@ if [ "$(uname)" = "Linux" ]; then lcov \ jsonlint - sudo apt-get --no-install-recommends install -y clang-format-9 || echo 'WARNING: could not install clang-format-9, which is useful if you plan to contribute C/C++ code to the OpenThread project.' + sudo apt-get --no-install-recommends install -y clang-format-14 || echo 'WARNING: could not install clang-format-14, which is useful if you plan to contribute C/C++ code to the OpenThread project.' python3 -m pip install yapf==0.29.0 || echo 'WARNING: could not install yapf, which is useful if you plan to contribute python code to the OpenThread project.' ## Install newest CMake @@ -118,8 +118,8 @@ elif [ "$(uname)" = "Darwin" ]; then swig@4 \ lcov && true - brew install llvm@9 && sudo ln -s "$(brew --prefix llvm@9)/bin/clang-format" /usr/local/bin/clang-format-9 \ - || echo 'WARNING: could not install clang-format-9, which is useful if you plan to contribute C/C++ code to the OpenThread project.' + brew install llvm@14 && sudo ln -s "$(brew --prefix llvm@14)/bin/clang-format" /usr/local/bin/clang-format-14 \ + || echo 'WARNING: could not install clang-format-14, which is useful if you plan to contribute C/C++ code to the OpenThread project.' ## Install latest cmake match_version "$(cmake --version | grep -E -o '[0-9].*')" "${MIN_CMAKE_VERSION}" || { diff --git a/script/clang-format b/script/clang-format index 01b9535e0..97dfada81 100755 --- a/script/clang-format +++ b/script/clang-format @@ -39,8 +39,8 @@ die() # expand_aliases shell option is set using shopt. shopt -s expand_aliases -if command -v clang-format-9 >/dev/null; then - alias clang-format=clang-format-9 +if command -v clang-format-14 >/dev/null; then + alias clang-format=clang-format-14 elif command -v clang-format >/dev/null; then case "$(clang-format --version)" in "$CLANG_FORMAT_VERSION"*) ;; diff --git a/src/app/border_agent.cpp b/src/app/border_agent.cpp index e04bfc81f..e711341e9 100644 --- a/src/app/border_agent.cpp +++ b/src/app/border_agent.cpp @@ -49,7 +49,7 @@ UnixTime::UnixTime(std::time_t aTime /* =0 */) Error UnixTime::FromString(UnixTime &aTime, const std::string &aTimeStr) { std::tm lTm; - char * result = strptime(aTimeStr.c_str(), kFmtString.c_str(), &lTm); + char *result = strptime(aTimeStr.c_str(), kFmtString.c_str(), &lTm); if (result != nullptr && *result == '\000') { aTime = std::mktime(&lTm); @@ -117,7 +117,7 @@ BorderAgent::BorderAgent() BorderAgent::BorderAgent(std::string const &aAddr, uint16_t aPort, - ByteArray const & aDiscriminator, + ByteArray const &aDiscriminator, std::string const &aThreadVersion, BorderAgent::State aState, std::string const &aNetworkName, @@ -127,7 +127,7 @@ BorderAgent::BorderAgent(std::string const &aAddr, Timestamp aActiveTimestamp, uint32_t aPartitionId, std::string const &aVendorData, - ByteArray const & aVendorOui, + ByteArray const &aVendorOui, std::string const &aDomainName, uint8_t aBbrSeqNumber, uint16_t aBbrPort, diff --git a/src/app/border_agent.hpp b/src/app/border_agent.hpp index 8fa1c4c47..6a1b514bf 100644 --- a/src/app/border_agent.hpp +++ b/src/app/border_agent.hpp @@ -252,7 +252,7 @@ struct BorderAgent BorderAgent(std::string const &aAddr, uint16_t aPort, - ByteArray const & aDiscriminator, + ByteArray const &aDiscriminator, std::string const &aThreadVersion, BorderAgent::State aState, std::string const &aNetworkName, @@ -262,7 +262,7 @@ struct BorderAgent Timestamp aActiveTimestamp, uint32_t aPartitionId, std::string const &aVendorData, - ByteArray const & aVendorOui, + ByteArray const &aVendorOui, std::string const &aDomainName, uint8_t aBbrSeqNumber, uint16_t aBbrPort, diff --git a/src/app/br_discover.cpp b/src/app/br_discover.cpp index eee36a764..f0928756a 100644 --- a/src/app/br_discover.cpp +++ b/src/app/br_discover.cpp @@ -42,7 +42,7 @@ Error DiscoverBorderAgent(BorderAgentHandler aBorderAgentHandler, size_t aTimeou { static constexpr size_t kDefaultBufferSize = 1024 * 16; static constexpr mdns_record_type_t kMdnsQueryType = MDNS_RECORDTYPE_PTR; - static const char * kServiceName = "_meshcop._udp.local"; + static const char *kServiceName = "_meshcop._udp.local"; Error error; uint8_t buf[kDefaultBufferSize]; diff --git a/src/app/cli/interpreter.cpp b/src/app/cli/interpreter.cpp index 5402f2a48..613b2208a 100644 --- a/src/app/cli/interpreter.cpp +++ b/src/app/cli/interpreter.cpp @@ -326,7 +326,7 @@ template static Error ParseInteger(T &aInteger, const std::string & { Error error; uint64_t integer; - char * endPtr = nullptr; + char *endPtr = nullptr; integer = strtoull(aStr.c_str(), &endPtr, 0); @@ -1385,7 +1385,7 @@ Interpreter::Value Interpreter::ProcessBr(const Expression &aExpr) int mdnsSocket = -1; FDGuard fdgMdnsSocket; std::thread selectThread; - event_base * base; + event_base *base; timeval tvTimeout; std::unique_ptr mdnsEvent(nullptr, event_free); std::unique_ptr cancelEvent(nullptr, event_free); diff --git a/src/app/cli/interpreter.hpp b/src/app/cli/interpreter.hpp index 8fd3bccda..57283fab3 100644 --- a/src/app/cli/interpreter.hpp +++ b/src/app/cli/interpreter.hpp @@ -255,13 +255,13 @@ class Interpreter */ int mCancelPipe[2] = {-1, -1}; - static const std::map & mUsageMap; - static const std::map & mEvaluatorMap; - static const std::vector & mMultiNetworkSyntax; - static const std::vector & mMultiJobExecution; - static const std::vector & mInactiveCommissionerExecution; - static const std::vector & mExportSyntax; - static const std::vector & mImportSyntax; + static const std::map &mUsageMap; + static const std::map &mEvaluatorMap; + static const std::vector &mMultiNetworkSyntax; + static const std::vector &mMultiJobExecution; + static const std::vector &mInactiveCommissionerExecution; + static const std::vector &mExportSyntax; + static const std::vector &mImportSyntax; static const std::map &mJobEvaluatorMap; }; diff --git a/src/app/cli/interpreter_test.cpp b/src/app/cli/interpreter_test.cpp index bf193240f..b6dfe00b3 100644 --- a/src/app/cli/interpreter_test.cpp +++ b/src/app/cli/interpreter_test.cpp @@ -73,7 +73,7 @@ class InterpreterTestSuite : public testing::Test ~TestContext() { ClearCommissionerAppStaticExpecter(); } Interpreter mInterpreter; - Registry * mRegistry = nullptr; + Registry *mRegistry = nullptr; CommissionerAppMockPtr mDefaultCommissionerObject{new CommissionerAppMock()}; CommissionerAppStaticExpecter mCommissionerAppStaticExpecter; }; diff --git a/src/app/cli/job.cpp b/src/app/cli/job.cpp index 3756731bf..7535e3ea7 100644 --- a/src/app/cli/job.cpp +++ b/src/app/cli/job.cpp @@ -75,8 +75,8 @@ std::string Job::GetCommandString() return out; } -Job::Job(Interpreter & aInterpreter, - CommissionerAppPtr & aCommApp, +Job::Job(Interpreter &aInterpreter, + CommissionerAppPtr &aCommApp, Interpreter::Expression aExpr, Interpreter::JobEvaluator aEval, XpanId aXpanId) diff --git a/src/app/cli/job.hpp b/src/app/cli/job.hpp index 4b813364b..7ff1492f1 100644 --- a/src/app/cli/job.hpp +++ b/src/app/cli/job.hpp @@ -46,8 +46,8 @@ namespace commissioner { class Job { public: - Job(Interpreter & aInterpreter, - CommissionerAppPtr & aCommApp, + Job(Interpreter &aInterpreter, + CommissionerAppPtr &aCommApp, Interpreter::Expression aExpr, Interpreter::JobEvaluator aEval, XpanId aXpanId); @@ -63,8 +63,8 @@ class Job std::string GetCommandString(); private: - Interpreter & mInterpreter; - CommissionerAppPtr & mCommissioner; + Interpreter &mInterpreter; + CommissionerAppPtr &mCommissioner; Interpreter::Expression mExpr; Interpreter::JobEvaluator mEval; Interpreter::Value mValue; diff --git a/src/app/commissioner_app.cpp b/src/app/commissioner_app.cpp index 70d577716..d30df0d6b 100644 --- a/src/app/commissioner_app.cpp +++ b/src/app/commissioner_app.cpp @@ -88,7 +88,7 @@ Error CommissionerApp::Init(const Config &aConfig) return error; } -Error CommissionerApp::Start(std::string & aExistingCommissionerId, +Error CommissionerApp::Start(std::string &aExistingCommissionerId, const std::string &aBorderAgentAddr, uint16_t aBorderAgentPort) { @@ -575,7 +575,7 @@ Error CommissionerApp::SetMeshLocalPrefix(const std::string &aPrefix, MilliSecon return error; } -Error CommissionerApp::GetMeshLocalAddr(std::string & aMeshLocalAddr, +Error CommissionerApp::GetMeshLocalAddr(std::string &aMeshLocalAddr, const std::string &aMeshLocalPrefix, uint16_t aLocator16) { @@ -1240,13 +1240,13 @@ void CommissionerApp::OnJoinerConnected(const ByteArray &aJoinerId, Error aError // TODO(wgtdkp): logging } -bool CommissionerApp::OnJoinerFinalize(const ByteArray & aJoinerId, +bool CommissionerApp::OnJoinerFinalize(const ByteArray &aJoinerId, const std::string &aVendorName, const std::string &aVendorModel, const std::string &aVendorSwVersion, - const ByteArray & aVendorStackVersion, + const ByteArray &aVendorStackVersion, const std::string &aProvisioningUrl, - const ByteArray & aVendorData) + const ByteArray &aVendorData) { (void)aVendorName; (void)aVendorModel; @@ -1285,7 +1285,7 @@ void CommissionerApp::OnPanIdConflict(const std::string &aPeerAddr, const Channe void CommissionerApp::OnEnergyReport(const std::string &aPeerAddr, const ChannelMask &aChannelMask, - const ByteArray & aEnergyList) + const ByteArray &aEnergyList) { Address addr; diff --git a/src/app/commissioner_app.hpp b/src/app/commissioner_app.hpp index 6504a9fb4..8371fe01c 100644 --- a/src/app/commissioner_app.hpp +++ b/src/app/commissioner_app.hpp @@ -104,13 +104,13 @@ class CommissionerApp : public CommissionerHandler MOCKABLE void OnJoinerConnected(const ByteArray &aJoinerId, Error aError) override; - MOCKABLE bool OnJoinerFinalize(const ByteArray & aJoinerId, + MOCKABLE bool OnJoinerFinalize(const ByteArray &aJoinerId, const std::string &aVendorName, const std::string &aVendorModel, const std::string &aVendorSwVersion, - const ByteArray & aVendorStackVersion, + const ByteArray &aVendorStackVersion, const std::string &aProvisioningUrl, - const ByteArray & aVendorData) override; + const ByteArray &aVendorData) override; MOCKABLE void OnKeepAliveResponse(Error aError) override; @@ -120,11 +120,11 @@ class CommissionerApp : public CommissionerHandler MOCKABLE void OnEnergyReport(const std::string &aPeerAddr, const ChannelMask &aChannelMask, - const ByteArray & aEnergyList) override; + const ByteArray &aEnergyList) override; MOCKABLE void OnDatasetChanged() override; - MOCKABLE Error Start(std::string & aExistingCommissionerId, + MOCKABLE Error Start(std::string &aExistingCommissionerId, const std::string &aBorderAgentAddr, uint16_t aBorderAgentPort); MOCKABLE void Stop(); @@ -192,7 +192,7 @@ class CommissionerApp : public CommissionerHandler * * @return Error::kNone, succeed; Otherwise, failed. */ - MOCKABLE Error GetMeshLocalAddr(std::string & aMeshLocalAddr, + MOCKABLE Error GetMeshLocalAddr(std::string &aMeshLocalAddr, const std::string &aMeshLocalPrefix, uint16_t aLocator16); @@ -245,9 +245,9 @@ class CommissionerApp : public CommissionerHandler * Commercial Commissioning features */ - MOCKABLE Error Reenroll(const std::string &aDstAddr); - MOCKABLE Error DomainReset(const std::string &aDstAddr); - MOCKABLE Error Migrate(const std::string &aDstAddr, const std::string &aDesignatedNetwork); + MOCKABLE Error Reenroll(const std::string &aDstAddr); + MOCKABLE Error DomainReset(const std::string &aDstAddr); + MOCKABLE Error Migrate(const std::string &aDstAddr, const std::string &aDesignatedNetwork); MOCKABLE const ByteArray &GetToken() const; MOCKABLE Error RequestToken(const std::string &aAddr, uint16_t aPort); MOCKABLE Error SetToken(const ByteArray &aSignedToken); @@ -264,7 +264,7 @@ class CommissionerApp : public CommissionerHandler uint16_t aPeriod, uint16_t aScanDuration, const std::string &aDstAddr); - MOCKABLE const EnergyReport *GetEnergyReport(const Address &aDstAddr) const; + MOCKABLE const EnergyReport *GetEnergyReport(const Address &aDstAddr) const; MOCKABLE const EnergyReportMap &GetAllEnergyReports() const; const std::string &GetDomainName() const; @@ -288,7 +288,7 @@ class CommissionerApp : public CommissionerHandler CommissionerDataset MakeDefaultCommissionerDataset(); static ByteArray &GetSteeringData(CommissionerDataset &aDataset, JoinerType aJoinerType); - static uint16_t & GetJoinerUdpPort(CommissionerDataset &aDataset, JoinerType aJoinerType); + static uint16_t &GetJoinerUdpPort(CommissionerDataset &aDataset, JoinerType aJoinerType); // Erases all joiner with specific type. Returns the number of erased joiners. size_t EraseAllJoiners(JoinerType aJoinerType); diff --git a/src/app/commissioner_app_dummy.cpp b/src/app/commissioner_app_dummy.cpp index 380b15f1f..54038001b 100644 --- a/src/app/commissioner_app_dummy.cpp +++ b/src/app/commissioner_app_dummy.cpp @@ -46,13 +46,13 @@ void CommissionerApp::OnJoinerConnected(const ByteArray &aJoinerId, Error aError UNUSED(aError); } -bool CommissionerApp::OnJoinerFinalize(const ByteArray & aJoinerId, +bool CommissionerApp::OnJoinerFinalize(const ByteArray &aJoinerId, const std::string &aVendorName, const std::string &aVendorModel, const std::string &aVendorSwVersion, - const ByteArray & aVendorStackVersion, + const ByteArray &aVendorStackVersion, const std::string &aProvisioningUrl, - const ByteArray & aVendorData) + const ByteArray &aVendorData) { UNUSED(aJoinerId); UNUSED(aVendorName); @@ -80,7 +80,7 @@ void CommissionerApp::OnPanIdConflict(const std::string &aPeerAddr, const Channe void CommissionerApp::OnEnergyReport(const std::string &aPeerAddr, const ChannelMask &aChannelMask, - const ByteArray & aEnergyList) + const ByteArray &aEnergyList) { UNUSED(aPeerAddr); UNUSED(aChannelMask); @@ -91,7 +91,7 @@ void CommissionerApp::OnDatasetChanged() { } -Error CommissionerApp::Start(std::string & aExistingCommissionerId, +Error CommissionerApp::Start(std::string &aExistingCommissionerId, const std::string &aBorderAgentAddr, uint16_t aBorderAgentPort) { @@ -260,7 +260,7 @@ Error CommissionerApp::SetMeshLocalPrefix(const std::string &aPrefix, MilliSecon return Error{}; } -Error CommissionerApp::GetMeshLocalAddr(std::string & aMeshLocalAddr, +Error CommissionerApp::GetMeshLocalAddr(std::string &aMeshLocalAddr, const std::string &aMeshLocalPrefix, uint16_t aLocator16) { diff --git a/src/app/file_logger.hpp b/src/app/file_logger.hpp index 6b4dfbc10..b38057727 100644 --- a/src/app/file_logger.hpp +++ b/src/app/file_logger.hpp @@ -74,7 +74,7 @@ class FileLogger : public Logger FileLogger() = default; Error Init(const std::string &aFilename, LogLevel aLogLevel); - FILE * mLogFile; + FILE *mLogFile; LogLevel mLogLevel; std::mutex mLogMutex; }; diff --git a/src/app/file_util_test.cpp b/src/app/file_util_test.cpp index 7d93bd12c..e60a73e87 100644 --- a/src/app/file_util_test.cpp +++ b/src/app/file_util_test.cpp @@ -90,7 +90,7 @@ TEST(FileUtil, PathExists) TEST(FileUtil, WriteFile) { - FILE * f = NULL; + FILE *f = NULL; std::string path = "./test_write"; std::string test = "test"; std::string alt = "alt"; diff --git a/src/app/mdns_handler.cpp b/src/app/mdns_handler.cpp index c4d8a4e8c..395769359 100644 --- a/src/app/mdns_handler.cpp +++ b/src/app/mdns_handler.cpp @@ -54,11 +54,11 @@ int HandleRecord(const struct sockaddr *from, uint16_t type, uint16_t rclass, uint32_t ttl, - const void * data, + const void *data, size_t size, size_t offset, size_t length, - void * aBorderAgent) + void *aBorderAgent) { struct sockaddr_storage fromAddrStorage; Address fromAddr; @@ -67,8 +67,8 @@ int HandleRecord(const struct sockaddr *from, char nameBuffer[256]; BorderAgentOrErrorMsg &borderAgentOrErrorMsg = *reinterpret_cast(aBorderAgent); - BorderAgent & borderAgent = borderAgentOrErrorMsg.mBorderAgent; - Error & error = borderAgentOrErrorMsg.mError; + BorderAgent &borderAgent = borderAgentOrErrorMsg.mBorderAgent; + Error &error = borderAgentOrErrorMsg.mError; (void)rclass; (void)ttl; diff --git a/src/app/mdns_handler.hpp b/src/app/mdns_handler.hpp index 814a5fcd7..e6b231c51 100644 --- a/src/app/mdns_handler.hpp +++ b/src/app/mdns_handler.hpp @@ -40,11 +40,11 @@ int HandleRecord(const struct sockaddr *from, uint16_t type, uint16_t rclass, uint32_t ttl, - const void * data, + const void *data, size_t size, size_t offset, size_t length, - void * userData); + void *userData); } // namespace commissioner diff --git a/src/app/ps/registry.cpp b/src/app/ps/registry.cpp index 97497774c..917ae4677 100644 --- a/src/app/ps/registry.cpp +++ b/src/app/ps/registry.cpp @@ -412,8 +412,8 @@ Registry::Status Registry::GetAllNetworks(NetworkArray &aRet) } Registry::Status Registry::GetNetworkXpansByAliases(const StringArray &aAliases, - XpanIdArray & aRet, - StringArray & aUnresolved) + XpanIdArray &aRet, + StringArray &aUnresolved) { NetworkArray networks; Registry::Status status = GetNetworksByAliases(aAliases, networks, aUnresolved); @@ -429,8 +429,8 @@ Registry::Status Registry::GetNetworkXpansByAliases(const StringArray &aAliases, } Registry::Status Registry::GetNetworksByAliases(const StringArray &aAliases, - NetworkArray & aRet, - StringArray & aUnresolved) + NetworkArray &aRet, + StringArray &aUnresolved) { Registry::Status status; NetworkArray networks; diff --git a/src/app/ps/registry_entries.cpp b/src/app/ps/registry_entries.cpp index 5ef081967..bc5f5d8ce 100644 --- a/src/app/ps/registry_entries.cpp +++ b/src/app/ps/registry_entries.cpp @@ -371,8 +371,8 @@ BorderRouterId::BorderRouterId() { } -Registrar::Registrar(RegistrarId const & aId, - std::string const & aAddr, +Registrar::Registrar(RegistrarId const &aId, + std::string const &aAddr, unsigned int const aPort, std::vector const &aDomains) : mId(aId) @@ -398,10 +398,10 @@ Domain::Domain() { } -Network::Network(NetworkId const & aId, - DomainId const & aDomainId, +Network::Network(NetworkId const &aId, + DomainId const &aDomainId, std::string const &aName, - XpanId const & aXpan, + XpanId const &aXpan, unsigned int const aChannel, uint16_t const aPan, std::string const &aMlp, diff --git a/src/app/ps/registry_entries.hpp b/src/app/ps/registry_entries.hpp index 9d2abdd6f..9c90617c8 100644 --- a/src/app/ps/registry_entries.hpp +++ b/src/app/ps/registry_entries.hpp @@ -108,8 +108,8 @@ struct Registrar unsigned int mPort; /**< registrar port */ std::vector mDomains; /**< domains supplied by registrar */ - Registrar(RegistrarId const & aId, - std::string const & aAddr, + Registrar(RegistrarId const &aId, + std::string const &aAddr, unsigned int const aPort, std::vector const &aDomains); Registrar(); @@ -144,10 +144,10 @@ struct Network int mCcm; /**< Commercial commissioning mode;<0 not set, * 0 false, >0 true */ - Network(NetworkId const & aId, - DomainId const & aDomainId, + Network(NetworkId const &aId, + DomainId const &aDomainId, std::string const &aName, - XpanId const & aXpan, + XpanId const &aXpan, unsigned int const aChannel, uint16_t const aPan, std::string const &aMlp, diff --git a/src/common/error_macros.hpp b/src/common/error_macros.hpp index d04dc81c0..9eea79ec0 100644 --- a/src/common/error_macros.hpp +++ b/src/common/error_macros.hpp @@ -39,44 +39,103 @@ #include #define ERROR_NONE \ - Error {} -#define ERROR_CANCELLED(aFormat, ...) \ - Error { ErrorCode::kCancelled, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_INVALID_ARGS(aFormat, ...) \ - Error { ErrorCode::kInvalidArgs, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_INVALID_COMMAND(aFormat, ...) \ - Error { ErrorCode::kInvalidCommand, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_TIMEOUT(aFormat, ...) \ - Error { ErrorCode::kTimeout, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_NOT_FOUND(aFormat, ...) \ - Error { ErrorCode::kNotFound, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_SECURITY(aFormat, ...) \ - Error { ErrorCode::kSecurity, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_UNIMPLEMENTED(aFormat, ...) \ - Error { ErrorCode::kUnimplemented, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_BAD_FORMAT(aFormat, ...) \ - Error { ErrorCode::kBadFormat, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_BUSY(aFormat, ...) \ - Error { ErrorCode::kBusy, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_OUT_OF_MEMORY(aFormat, ...) \ - Error { ErrorCode::kOutOfMemory, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_IO_ERROR(aFormat, ...) \ - Error { ErrorCode::kIOError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_IO_BUSY(aFormat, ...) \ - Error { ErrorCode::kIOBusy, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_ALREADY_EXISTS(aFormat, ...) \ - Error { ErrorCode::kAlreadyExists, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_ABORTED(aFormat, ...) \ - Error { ErrorCode::kAborted, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_INVALID_STATE(aFormat, ...) \ - Error { ErrorCode::kInvalidState, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_REJECTED(aFormat, ...) \ - Error { ErrorCode::kRejected, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_COAP_ERROR(aFormat, ...) \ - Error { ErrorCode::kCoapError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_REGISTRY_ERROR(aFormat, ...) \ - Error { ErrorCode::kRegistryError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } -#define ERROR_UNKNOWN(aFormat, ...) \ - Error { ErrorCode::kUnknown, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) } + Error \ + { \ + } +#define ERROR_CANCELLED(aFormat, ...) \ + Error \ + { \ + ErrorCode::kCancelled, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_INVALID_ARGS(aFormat, ...) \ + Error \ + { \ + ErrorCode::kInvalidArgs, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_INVALID_COMMAND(aFormat, ...) \ + Error \ + { \ + ErrorCode::kInvalidCommand, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_TIMEOUT(aFormat, ...) \ + Error \ + { \ + ErrorCode::kTimeout, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_NOT_FOUND(aFormat, ...) \ + Error \ + { \ + ErrorCode::kNotFound, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_SECURITY(aFormat, ...) \ + Error \ + { \ + ErrorCode::kSecurity, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_UNIMPLEMENTED(aFormat, ...) \ + Error \ + { \ + ErrorCode::kUnimplemented, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_BAD_FORMAT(aFormat, ...) \ + Error \ + { \ + ErrorCode::kBadFormat, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_BUSY(aFormat, ...) \ + Error \ + { \ + ErrorCode::kBusy, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_OUT_OF_MEMORY(aFormat, ...) \ + Error \ + { \ + ErrorCode::kOutOfMemory, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_IO_ERROR(aFormat, ...) \ + Error \ + { \ + ErrorCode::kIOError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_IO_BUSY(aFormat, ...) \ + Error \ + { \ + ErrorCode::kIOBusy, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_ALREADY_EXISTS(aFormat, ...) \ + Error \ + { \ + ErrorCode::kAlreadyExists, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_ABORTED(aFormat, ...) \ + Error \ + { \ + ErrorCode::kAborted, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_INVALID_STATE(aFormat, ...) \ + Error \ + { \ + ErrorCode::kInvalidState, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_REJECTED(aFormat, ...) \ + Error \ + { \ + ErrorCode::kRejected, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_COAP_ERROR(aFormat, ...) \ + Error \ + { \ + ErrorCode::kCoapError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_REGISTRY_ERROR(aFormat, ...) \ + Error \ + { \ + ErrorCode::kRegistryError, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } +#define ERROR_UNKNOWN(aFormat, ...) \ + Error \ + { \ + ErrorCode::kUnknown, fmt::format(FMT_STRING((aFormat)), ##__VA_ARGS__) \ + } #endif // ERROR_MACROS_HPP_ diff --git a/src/library/cbor.hpp b/src/library/cbor.hpp index 1cf04be7d..ab480c936 100644 --- a/src/library/cbor.hpp +++ b/src/library/cbor.hpp @@ -57,7 +57,7 @@ class CborValue virtual Error Init() = 0; void Free(); - cn_cbor * GetImpl() { return mCbor; } + cn_cbor *GetImpl() { return mCbor; } const cn_cbor *GetImpl() const { return mCbor; } bool IsValid() const { return mCbor != nullptr; } diff --git a/src/library/coap.cpp b/src/library/coap.cpp index 847016acb..8f574329f 100644 --- a/src/library/coap.cpp +++ b/src/library/coap.cpp @@ -343,7 +343,7 @@ bool Message::Header::IsValid() const Error Message::Serialize(OptionType aOptionNumber, const OptionValue &aOptionValue, uint16_t aLastOptionNumber, - ByteArray & aBuf) const + ByteArray &aBuf) const { Error error; uint16_t delta = utils::to_underlying(aOptionNumber) - aLastOptionNumber; @@ -406,11 +406,11 @@ Error Message::Serialize(OptionType aOptionNumber, return error; } -Error Message::Deserialize(OptionType & aOptionNumber, - OptionValue & aOptionValue, +Error Message::Deserialize(OptionType &aOptionNumber, + OptionValue &aOptionValue, uint16_t aLastOptionNumber, const ByteArray &aBuf, - size_t & aOffset) + size_t &aOffset) { Error error; uint16_t delta; @@ -637,7 +637,7 @@ void Coap::ReceiveMessage(Endpoint &aEndpoint, std::shared_ptr aMessage void Coap::HandleRequest(const Request &aRequest) { Error error; - const Response * response = nullptr; + const Response *response = nullptr; std::string uriPath; decltype(mResources)::const_iterator resource; diff --git a/src/library/coap.hpp b/src/library/coap.hpp index c1fe6f2c7..f47f5c675 100644 --- a/src/library/coap.hpp +++ b/src/library/coap.hpp @@ -519,12 +519,12 @@ class Message Error Serialize(OptionType aOptionNumber, const OptionValue &aOptionValue, uint16_t aLastOptionNumber, - ByteArray & aBuf) const; - static Error Deserialize(OptionType & aOptionNumber, - OptionValue & aOptionValue, + ByteArray &aBuf) const; + static Error Deserialize(OptionType &aOptionNumber, + OptionValue &aOptionValue, uint16_t aLastOptionNumber, const ByteArray &aBuf, - size_t & aOffset); + size_t &aOffset); // Split the URI path by slash ('/'). static Error SplitUriPath(std::list &aUriPathList, const std::string &aUriPath); diff --git a/src/library/coap_secure_test.cpp b/src/library/coap_secure_test.cpp index 5c070fc21..2406e4cf9 100644 --- a/src/library/coap_secure_test.cpp +++ b/src/library/coap_secure_test.cpp @@ -103,7 +103,7 @@ static const std::string kServerKey = "-----BEGIN PRIVATE KEY-----\r\n" "Xvr27euqi54WCMXJEMk6IIaPyFBNNw8bJvqXWfZ5g7t4hj7amsvqUST2\r\n" "-----END PRIVATE KEY-----\r\n"; -static const char * kServerAddr = "::"; +static const char *kServerAddr = "::"; static constexpr uint16_t kServerPort = 5683; TEST(CoapsTest, CoapsClientServerHello) diff --git a/src/library/coap_test.cpp b/src/library/coap_test.cpp index d993257fb..2f8c3ecd8 100644 --- a/src/library/coap_test.cpp +++ b/src/library/coap_test.cpp @@ -329,7 +329,7 @@ class MockEndpoint : public Endpoint Address mAddr; uint16_t mPort; - MockEndpoint * mPeer; + MockEndpoint *mPeer; bool mDropMessage; std::queue mSendQueue; }; diff --git a/src/library/commissioner_impl.cpp b/src/library/commissioner_impl.cpp index 360383796..50b84f118 100644 --- a/src/library/commissioner_impl.cpp +++ b/src/library/commissioner_impl.cpp @@ -58,10 +58,10 @@ static constexpr uint16_t kDefaultMmPort = 61631; static constexpr uint32_t kMinKeepAliveInterval = 30; static constexpr uint32_t kMaxKeepAliveInterval = 45; -Error Commissioner::GeneratePSKc(ByteArray & aPSKc, +Error Commissioner::GeneratePSKc(ByteArray &aPSKc, const std::string &aPassphrase, const std::string &aNetworkName, - const ByteArray & aExtendedPanId) + const ByteArray &aExtendedPanId) { Error error; const std::string saltPrefix = "Thread"; @@ -1520,7 +1520,7 @@ Error CommissionerImpl::DecodeActiveOperationalDataset(ActiveOperationalDataset } Error CommissionerImpl::DecodePendingOperationalDataset(PendingOperationalDataset &aDataset, - const coap::Response & aResponse) + const coap::Response &aResponse) { Error error; tlv::TlvSet tlvSet; @@ -1583,7 +1583,7 @@ Error CommissionerImpl::DecodeChannelMask(ChannelMask &aChannelMask, const ByteA return error; } -Error CommissionerImpl::EncodeActiveOperationalDataset(coap::Request & aRequest, +Error CommissionerImpl::EncodeActiveOperationalDataset(coap::Request &aRequest, const ActiveOperationalDataset &aDataset) { Error error; @@ -1650,7 +1650,7 @@ Error CommissionerImpl::EncodeActiveOperationalDataset(coap::Request & return error; } -Error CommissionerImpl::EncodePendingOperationalDataset(coap::Request & aRequest, +Error CommissionerImpl::EncodePendingOperationalDataset(coap::Request &aRequest, const PendingOperationalDataset &aDataset) { Error error; diff --git a/src/library/commissioner_impl.hpp b/src/library/commissioner_impl.hpp index 1e2a02eac..0491b18b9 100644 --- a/src/library/commissioner_impl.hpp +++ b/src/library/commissioner_impl.hpp @@ -70,7 +70,7 @@ class CommissionerImpl : public Commissioner public: explicit CommissionerImpl(CommissionerHandler &aHandler, struct event_base *aEventBase); - CommissionerImpl(const CommissionerImpl &aCommissioner) = delete; + CommissionerImpl(const CommissionerImpl &aCommissioner) = delete; const CommissionerImpl &operator=(const CommissionerImpl &aCommissioner) = delete; Error Init(const Config &aConfig) override; @@ -227,7 +227,10 @@ class CommissionerImpl : public Commissioner Error SignRequest(coap::Request &aRequest, tlv::Scope aScope = tlv::Scope::kMeshCoP, bool aAppendToken = true); #endif - Duration GetKeepAliveInterval() const { return std::chrono::seconds(mConfig.mKeepAliveInterval); }; + Duration GetKeepAliveInterval() const + { + return std::chrono::seconds(mConfig.mKeepAliveInterval); + }; void SendProxyMessage(ErrorHandler aHandler, const std::string &aDstAddr, const std::string &aUriPath); @@ -251,7 +254,7 @@ class CommissionerImpl : public Commissioner */ CommissionerHandler &mCommissionerHandler; - struct event_base * mEventBase; + struct event_base *mEventBase; Config mConfig; diff --git a/src/library/commissioner_impl_test.cpp b/src/library/commissioner_impl_test.cpp index e75bbd262..800595114 100644 --- a/src/library/commissioner_impl_test.cpp +++ b/src/library/commissioner_impl_test.cpp @@ -99,7 +99,7 @@ TEST(CommissionerImpl, NotImplementedApis) config.mPSKc = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; CommissionerHandler dummyHandler; - struct event_base * eventBase = event_base_new(); + struct event_base *eventBase = event_base_new(); CommissionerImpl commImpl(dummyHandler, eventBase); EXPECT_EQ(commImpl.Init(config), ErrorCode::kNone); diff --git a/src/library/commissioner_safe.cpp b/src/library/commissioner_safe.cpp index a72aac8cf..df81c124e 100644 --- a/src/library/commissioner_safe.cpp +++ b/src/library/commissioner_safe.cpp @@ -431,7 +431,7 @@ void CommissionerSafe::RegisterMulticastListener(Handler PushAsyncRequest([=]() { mImpl->RegisterMulticastListener(aHandler, aMulticastAddrList, aTimeout); }); } -Error CommissionerSafe::RegisterMulticastListener(uint8_t & aStatus, +Error CommissionerSafe::RegisterMulticastListener(uint8_t &aStatus, const std::vector &aMulticastAddrList, uint32_t aTimeout) { diff --git a/src/library/commissioner_safe.hpp b/src/library/commissioner_safe.hpp index 5523cd6d0..8c4ef0197 100644 --- a/src/library/commissioner_safe.hpp +++ b/src/library/commissioner_safe.hpp @@ -71,7 +71,7 @@ class CommissionerSafe : public Commissioner { } - CommissionerSafe(const CommissionerSafe &aCommissioner) = delete; + CommissionerSafe(const CommissionerSafe &aCommissioner) = delete; const CommissionerSafe &operator=(const CommissionerSafe &aCommissioner) = delete; Error Init(const Config &aConfig) override; @@ -149,7 +149,7 @@ class CommissionerSafe : public Commissioner void RegisterMulticastListener(Handler aHandler, const std::vector &aMulticastAddrList, uint32_t aTimeout) override; - Error RegisterMulticastListener(uint8_t & aStatus, + Error RegisterMulticastListener(uint8_t &aStatus, const std::vector &aMulticastAddrList, uint32_t aTimeout) override; diff --git a/src/library/cose.cpp b/src/library/cose.cpp index 3bc57be88..fd091aeae 100644 --- a/src/library/cose.cpp +++ b/src/library/cose.cpp @@ -154,7 +154,7 @@ Error Sign1Message::SetContent(const ByteArray &aContent) } else { - uint8_t emptyContent; + uint8_t emptyContent = 0; VerifyOrExit(COSE_Sign0_SetContent(mSign, &emptyContent, 0, nullptr), error = ERROR_UNKNOWN("set COSE SIGN1 message content")); } @@ -244,8 +244,8 @@ static cn_cbor *CborArrayAt(cn_cbor *arr, size_t index) const uint8_t *Sign1Message::GetPayload(size_t &aLength) { const uint8_t *ret = nullptr; - cn_cbor * cbor; - cn_cbor * payload; + cn_cbor *cbor; + cn_cbor *payload; VerifyOrDie(mSign != nullptr); VerifyOrExit((cbor = COSE_get_cbor(reinterpret_cast(mSign))) != nullptr); diff --git a/src/library/dtls.cpp b/src/library/dtls.cpp index adf9dc39e..04216519a 100644 --- a/src/library/dtls.cpp +++ b/src/library/dtls.cpp @@ -335,7 +335,7 @@ std::string DtlsSession::GetStateString() const return stateString; } -int DtlsSession::HandleMbedtlsExportKeys(void * aDtlsSession, +int DtlsSession::HandleMbedtlsExportKeys(void *aDtlsSession, const unsigned char *aMasterSecret, const unsigned char *aKeyBlock, size_t aMacLength, diff --git a/src/library/dtls.hpp b/src/library/dtls.hpp index e61060982..f907e1d46 100644 --- a/src/library/dtls.hpp +++ b/src/library/dtls.hpp @@ -90,7 +90,7 @@ class DtlsSession : public Endpoint DtlsSession(struct event_base *aEventBase, bool aIsServer, SocketPtr aSocket); ~DtlsSession() override; - DtlsSession(const DtlsSession &aOther) = delete; + DtlsSession(const DtlsSession &aOther) = delete; const DtlsSession &operator=(const DtlsSession &aOther) = delete; Error Send(const ByteArray &aBuf, MessageSubType aSubType) override; @@ -170,7 +170,7 @@ class DtlsSession : public Endpoint // Decide if we should stop processing this session by given error. static bool ShouldStop(Error aError); - static int HandleMbedtlsExportKeys(void * aDtlsSession, + static int HandleMbedtlsExportKeys(void *aDtlsSession, const unsigned char *aMasterSecret, const unsigned char *aKeyBlock, size_t aMacLength, diff --git a/src/library/dtls_test.cpp b/src/library/dtls_test.cpp index 291c09d84..78341b62a 100644 --- a/src/library/dtls_test.cpp +++ b/src/library/dtls_test.cpp @@ -103,7 +103,7 @@ static const std::string kServerKey = "-----BEGIN PRIVATE KEY-----\r\n" "Xvr27euqi54WCMXJEMk6IIaPyFBNNw8bJvqXWfZ5g7t4hj7amsvqUST2\r\n" "-----END PRIVATE KEY-----\r\n"; -static const char * kServerAddr = "::"; +static const char *kServerAddr = "::"; static constexpr uint16_t kServerPort = 5683; TEST(DtlsTest, MbedtlsClientServer) diff --git a/src/library/joiner_session.cpp b/src/library/joiner_session.cpp index 730bccef0..01b42ea82 100644 --- a/src/library/joiner_session.cpp +++ b/src/library/joiner_session.cpp @@ -42,14 +42,14 @@ namespace ot { namespace commissioner { -JoinerSession::JoinerSession(CommissionerImpl & aCommImpl, - const ByteArray & aJoinerId, +JoinerSession::JoinerSession(CommissionerImpl &aCommImpl, + const ByteArray &aJoinerId, const std::string &aJoinerPSkd, uint16_t aJoinerUdpPort, uint16_t aJoinerRouterLocator, - const Address & aJoinerAddr, + const Address &aJoinerAddr, uint16_t aJoinerPort, - const Address & aLocalAddr, + const Address &aLocalAddr, uint16_t aLocalPort) : mCommImpl(aCommImpl) , mJoinerId(aJoinerId) diff --git a/src/library/joiner_session.hpp b/src/library/joiner_session.hpp index 1ed86cf58..d30c5f94a 100644 --- a/src/library/joiner_session.hpp +++ b/src/library/joiner_session.hpp @@ -66,18 +66,18 @@ using JoinerSessionPtr = std::shared_ptr; class JoinerSession : std::enable_shared_from_this { public: - JoinerSession(CommissionerImpl & aCommImpl, - const ByteArray & aJoinerId, + JoinerSession(CommissionerImpl &aCommImpl, + const ByteArray &aJoinerId, const std::string &aJoinerPSkd, uint16_t aJoinerUdpPort, uint16_t aJoinerRouterLocator, - const Address & aJoinerAddr, + const Address &aJoinerAddr, uint16_t aJoinerPort, - const Address & aLocalAddr, + const Address &aLocalAddr, uint16_t aLocalPort); - JoinerSession(JoinerSession &&aOther) = delete; - JoinerSession &operator=(JoinerSession &&aOther) = delete; - JoinerSession(const JoinerSession &aOther) = delete; + JoinerSession(JoinerSession &&aOther) = delete; + JoinerSession &operator=(JoinerSession &&aOther) = delete; + JoinerSession(const JoinerSession &aOther) = delete; JoinerSession &operator=(const JoinerSession &aOther) = delete; ~JoinerSession() = default; diff --git a/src/library/openthread/pbkdf2_cmac.cpp b/src/library/openthread/pbkdf2_cmac.cpp index 6ef04bbba..3a03ce62a 100644 --- a/src/library/openthread/pbkdf2_cmac.cpp +++ b/src/library/openthread/pbkdf2_cmac.cpp @@ -49,7 +49,7 @@ void otPbkdf2Cmac(const uint8_t *aPassword, uint16_t aSaltLen, uint32_t aIterationCounter, uint16_t aKeyLen, - uint8_t * aKey) + uint8_t *aKey) { const size_t kBlockSize = MBEDTLS_CIPHER_BLKSIZE_MAX; uint8_t prfInput[OT_PBKDF2_SALT_MAX_LEN + 4]; // Salt || INT(), for U1 calculation @@ -57,7 +57,7 @@ void otPbkdf2Cmac(const uint8_t *aPassword, long prfTwo[kBlockSize / sizeof(long)]; long keyBlock[kBlockSize / sizeof(long)]; uint32_t blockCounter = 0; - uint8_t * key = aKey; + uint8_t *key = aKey; uint16_t keyLen = aKeyLen; uint16_t useLen = 0; diff --git a/src/library/openthread/pbkdf2_cmac.hpp b/src/library/openthread/pbkdf2_cmac.hpp index 3ed61d773..860e6f463 100644 --- a/src/library/openthread/pbkdf2_cmac.hpp +++ b/src/library/openthread/pbkdf2_cmac.hpp @@ -61,7 +61,7 @@ void otPbkdf2Cmac(const uint8_t *aPassword, uint16_t aSaltLen, uint32_t aIterationCounter, uint16_t aKeyLen, - uint8_t * aKey); + uint8_t *aKey); } // namespace commissioner diff --git a/src/library/socket.hpp b/src/library/socket.hpp index ceebd63d7..e692248b8 100644 --- a/src/library/socket.hpp +++ b/src/library/socket.hpp @@ -53,9 +53,9 @@ class Socket { public: explicit Socket(struct event_base *aEventBase); - Socket(Socket &&aOther) = default; - Socket &operator=(Socket &&aOther) = delete; - Socket(const Socket &aOther) = delete; + Socket(Socket &&aOther) = default; + Socket &operator=(Socket &&aOther) = delete; + Socket(const Socket &aOther) = delete; Socket &operator=(const Socket &aOther) = delete; virtual ~Socket(); diff --git a/src/library/tlv.hpp b/src/library/tlv.hpp index ca741a5dd..b478767ad 100644 --- a/src/library/tlv.hpp +++ b/src/library/tlv.hpp @@ -174,7 +174,7 @@ class Tlv uint16_t GetValueAsUint16() const; std::string GetValueAsString() const; const ByteArray &GetValue() const; - ByteArray & GetValue(); + ByteArray &GetValue(); private: Scope mScope = Scope::kMeshCoP; diff --git a/src/library/token_manager.cpp b/src/library/token_manager.cpp index 43697f5e9..a8344787a 100644 --- a/src/library/token_manager.cpp +++ b/src/library/token_manager.cpp @@ -95,18 +95,18 @@ Error TokenManager::Init(const Config &aConfig) return error; } -Error TokenManager::ValidateToken(CborMap & aToken, - const ByteArray & aSignedToken, +Error TokenManager::ValidateToken(CborMap &aToken, + const ByteArray &aSignedToken, const mbedtls_pk_context &aPublicKey) const { Error error; cose::Sign1Message coseSign; CborMap token; - const uint8_t * payload; + const uint8_t *payload; size_t payloadLength; - const char * domainName; + const char *domainName; size_t domainNameLength; - const char * expire; + const char *expire; size_t expireLength; VerifyOrExit(!aSignedToken.empty(), error = ERROR_INVALID_ARGS("the signed COM_TOK is empty")); @@ -283,10 +283,10 @@ Error TokenManager::GetKeyId(ByteArray &aKeyId) const return error; } -Error TokenManager::MakeTokenRequest(ByteArray & aBuf, +Error TokenManager::MakeTokenRequest(ByteArray &aBuf, const mbedtls_pk_context &aPublicKey, - const std::string & aId, - const std::string & aDomainName) + const std::string &aId, + const std::string &aDomainName) { static constexpr size_t kMaxTokenRequestSize = 1024; diff --git a/src/library/token_manager.hpp b/src/library/token_manager.hpp index 6b87054fb..a9a09ef84 100644 --- a/src/library/token_manager.hpp +++ b/src/library/token_manager.hpp @@ -182,10 +182,10 @@ class TokenManager Error ValidateToken(const ByteArray &aSignedToken, const mbedtls_pk_context &aPublicKey) const; void SendTokenRequest(Commissioner::Handler aHandler); - static Error MakeTokenRequest(ByteArray & aBuf, + static Error MakeTokenRequest(ByteArray &aBuf, const mbedtls_pk_context &aPublicKey, - const std::string & aId, - const std::string & aDomainName); + const std::string &aId, + const std::string &aDomainName); // Prepare the content to be signed. // Described in 12.5.5 of Thread 1.2 spec. diff --git a/src/library/udp_proxy.cpp b/src/library/udp_proxy.cpp index dc9417ede..f8aa20b49 100644 --- a/src/library/udp_proxy.cpp +++ b/src/library/udp_proxy.cpp @@ -84,7 +84,7 @@ Error ProxyEndpoint::Send(const ByteArray &aRequest, MessageSubType aSubType) return error; } -void ProxyClient::SendRequest(const coap::Request & aRequest, +void ProxyClient::SendRequest(const coap::Request &aRequest, coap::ResponseHandler aHandler, uint16_t aPeerAloc16, uint16_t aPeerPort) @@ -108,9 +108,9 @@ void ProxyClient::SendRequest(const coap::Request & aRequest, } } -void ProxyClient::SendRequest(const coap::Request & aRequest, +void ProxyClient::SendRequest(const coap::Request &aRequest, coap::ResponseHandler aHandler, - const Address & aPeerAddr, + const Address &aPeerAddr, uint16_t aPeerPort) { VerifyOrDie(aPeerAddr.IsValid() && aPeerAddr.IsIpv6()); diff --git a/src/library/udp_proxy.hpp b/src/library/udp_proxy.hpp index f13f4fd94..8011def7a 100644 --- a/src/library/udp_proxy.hpp +++ b/src/library/udp_proxy.hpp @@ -79,14 +79,14 @@ class ProxyClient public: ProxyClient(CommissionerImpl &aCommissioner, coap::CoapSecure &aBrClient); - void SendRequest(const coap::Request & aRequest, + void SendRequest(const coap::Request &aRequest, coap::ResponseHandler aHandler, uint16_t aPeerAloc16, uint16_t aPeerPort); - void SendRequest(const coap::Request & aRequest, + void SendRequest(const coap::Request &aRequest, coap::ResponseHandler aHandler, - const Address & aPeerAddr, + const Address &aPeerAddr, uint16_t aPeerPort); void SendEmptyChanged(const coap::Request &aRequest);