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

[style] update formatter to clang-format-14 #248

Merged
merged 1 commit into from
Apr 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
2 changes: 1 addition & 1 deletion .github/workflows/android-app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-app-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ 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:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
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: |
script/make-pretty check

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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions include/commissioner/commissioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<std::string> &aMulticastAddrList,
uint32_t aTimeout) = 0;

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions script/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}" || {
Expand Down
4 changes: 2 additions & 2 deletions script/clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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"*) ;;
Expand Down
6 changes: 3 additions & 3 deletions src/app/border_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/app/border_agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/app/br_discover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ template <typename T> 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);

Expand Down Expand Up @@ -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<event, void (*)(event *)> mdnsEvent(nullptr, event_free);
std::unique_ptr<event, void (*)(event *)> cancelEvent(nullptr, event_free);
Expand Down
14 changes: 7 additions & 7 deletions src/app/cli/interpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ class Interpreter
*/
int mCancelPipe[2] = {-1, -1};

static const std::map<std::string, std::string> & mUsageMap;
static const std::map<std::string, Evaluator> & mEvaluatorMap;
static const std::vector<StringArray> & mMultiNetworkSyntax;
static const std::vector<StringArray> & mMultiJobExecution;
static const std::vector<StringArray> & mInactiveCommissionerExecution;
static const std::vector<StringArray> & mExportSyntax;
static const std::vector<StringArray> & mImportSyntax;
static const std::map<std::string, std::string> &mUsageMap;
static const std::map<std::string, Evaluator> &mEvaluatorMap;
static const std::vector<StringArray> &mMultiNetworkSyntax;
static const std::vector<StringArray> &mMultiJobExecution;
static const std::vector<StringArray> &mInactiveCommissionerExecution;
static const std::vector<StringArray> &mExportSyntax;
static const std::vector<StringArray> &mImportSyntax;
static const std::map<std::string, JobEvaluator> &mJobEvaluatorMap;
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/interpreter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/app/cli/job.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/app/commissioner_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Loading
Loading