forked from Kistler-Group/sdbus-cpp
fix: address clang-tidy warnings in stress tests
This commit is contained in:
@@ -25,7 +25,10 @@ Checks: "*,\
|
|||||||
-llvmlibc-*,\
|
-llvmlibc-*,\
|
||||||
-altera-*,\
|
-altera-*,\
|
||||||
-fuchsia-*,
|
-fuchsia-*,
|
||||||
|
-cert-err58-cpp,\
|
||||||
-modernize-use-trailing-return-type,\
|
-modernize-use-trailing-return-type,\
|
||||||
|
-cppcoreguidelines-avoid-magic-numbers,\
|
||||||
|
-readability-magic-numbers,\
|
||||||
-readability-braces-around-statements,\
|
-readability-braces-around-statements,\
|
||||||
-google-readability-braces-around-statements,\
|
-google-readability-braces-around-statements,\
|
||||||
-hicpp-braces-around-statements,\
|
-hicpp-braces-around-statements,\
|
||||||
|
@@ -268,15 +268,17 @@ endif()
|
|||||||
|
|
||||||
if(SDBUSCPP_CLANG_TIDY)
|
if(SDBUSCPP_CLANG_TIDY)
|
||||||
message(STATUS "Building with static analysis")
|
message(STATUS "Building with static analysis")
|
||||||
|
#set(CLANG_TIDY "/home/one/CLion2/clion-2024.3.5/bin/clang/linux/x64/bin/clang-tidy")
|
||||||
find_program(CLANG_TIDY NAMES clang-tidy)
|
find_program(CLANG_TIDY NAMES clang-tidy)
|
||||||
if(NOT CLANG_TIDY)
|
if(NOT CLANG_TIDY)
|
||||||
message(STATUS "clang-tidy not found")
|
message(WARNING "clang-tidy not found")
|
||||||
else()
|
else()
|
||||||
message(STATUS "clang-tidy found: ${CLANG_TIDY}")
|
message(STATUS "clang-tidy found: ${CLANG_TIDY}")
|
||||||
set_target_properties(sdbus-c++-objlib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
set_target_properties(sdbus-c++-objlib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
set_target_properties(sdbus-c++ PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
set_target_properties(sdbus-c++ PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
set_target_properties(sdbus-c++-unit-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
#set_target_properties(sdbus-c++-unit-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
set_target_properties(sdbus-c++-integration-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
#set_target_properties(sdbus-c++-integration-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
|
set_target_properties(sdbus-c++-stress-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -62,13 +62,18 @@ public:
|
|||||||
registerAdaptor();
|
registerAdaptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CelsiusThermometerAdaptor(const CelsiusThermometerAdaptor&) = delete;
|
||||||
|
CelsiusThermometerAdaptor& operator=(const CelsiusThermometerAdaptor&) = delete;
|
||||||
|
CelsiusThermometerAdaptor(CelsiusThermometerAdaptor&&) = delete;
|
||||||
|
CelsiusThermometerAdaptor& operator=(CelsiusThermometerAdaptor&&) = delete;
|
||||||
|
|
||||||
~CelsiusThermometerAdaptor()
|
~CelsiusThermometerAdaptor()
|
||||||
{
|
{
|
||||||
unregisterAdaptor();
|
unregisterAdaptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uint32_t getCurrentTemperature() override
|
uint32_t getCurrentTemperature() override
|
||||||
{
|
{
|
||||||
return m_currentTemperature++;
|
return m_currentTemperature++;
|
||||||
}
|
}
|
||||||
@@ -86,6 +91,11 @@ public:
|
|||||||
registerProxy();
|
registerProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CelsiusThermometerProxy(const CelsiusThermometerProxy&) = delete;
|
||||||
|
CelsiusThermometerProxy& operator=(const CelsiusThermometerProxy&) = delete;
|
||||||
|
CelsiusThermometerProxy(CelsiusThermometerProxy&&) = delete;
|
||||||
|
CelsiusThermometerProxy& operator=(CelsiusThermometerProxy&&) = delete;
|
||||||
|
|
||||||
~CelsiusThermometerProxy()
|
~CelsiusThermometerProxy()
|
||||||
{
|
{
|
||||||
unregisterProxy();
|
unregisterProxy();
|
||||||
@@ -152,6 +162,11 @@ public:
|
|||||||
registerAdaptor();
|
registerAdaptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FahrenheitThermometerAdaptor(const FahrenheitThermometerAdaptor&) = delete;
|
||||||
|
FahrenheitThermometerAdaptor& operator=(const FahrenheitThermometerAdaptor&) = delete;
|
||||||
|
FahrenheitThermometerAdaptor(FahrenheitThermometerAdaptor&&) = delete;
|
||||||
|
FahrenheitThermometerAdaptor& operator=(FahrenheitThermometerAdaptor&&) = delete;
|
||||||
|
|
||||||
~FahrenheitThermometerAdaptor()
|
~FahrenheitThermometerAdaptor()
|
||||||
{
|
{
|
||||||
exit_ = true;
|
exit_ = true;
|
||||||
@@ -163,13 +178,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uint32_t getCurrentTemperature() override
|
uint32_t getCurrentTemperature() override
|
||||||
{
|
{
|
||||||
// In this D-Bus call, make yet another D-Bus call to another service over the same connection
|
// In this D-Bus call, make yet another D-Bus call to another service over the same connection
|
||||||
return static_cast<uint32_t>(celsiusProxy_.getCurrentTemperature() * 1.8 + 32.);
|
return static_cast<uint32_t>(celsiusProxy_.getCurrentTemperature() * 1.8 + 32.);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void createDelegateObject(sdbus::Result<sdbus::ObjectPath>&& result) override
|
void createDelegateObject(sdbus::Result<sdbus::ObjectPath>&& result) override
|
||||||
{
|
{
|
||||||
static size_t objectCounter{};
|
static size_t objectCounter{};
|
||||||
objectCounter++;
|
objectCounter++;
|
||||||
@@ -180,7 +195,7 @@ protected:
|
|||||||
cond_.notify_one();
|
cond_.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void destroyDelegateObject(sdbus::Result<>&& /*result*/, sdbus::ObjectPath delegate) override
|
void destroyDelegateObject(sdbus::Result<>&& /*result*/, sdbus::ObjectPath delegate) override
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
requests_.push(WorkItem{0, std::move(delegate), {}});
|
requests_.push(WorkItem{0, std::move(delegate), {}});
|
||||||
@@ -216,6 +231,11 @@ public:
|
|||||||
registerProxy();
|
registerProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FahrenheitThermometerProxy(const FahrenheitThermometerProxy&) = delete;
|
||||||
|
FahrenheitThermometerProxy& operator=(const FahrenheitThermometerProxy&) = delete;
|
||||||
|
FahrenheitThermometerProxy(FahrenheitThermometerProxy&&) = delete;
|
||||||
|
FahrenheitThermometerProxy& operator=(FahrenheitThermometerProxy&&) = delete;
|
||||||
|
|
||||||
~FahrenheitThermometerProxy()
|
~FahrenheitThermometerProxy()
|
||||||
{
|
{
|
||||||
unregisterProxy();
|
unregisterProxy();
|
||||||
@@ -262,6 +282,11 @@ public:
|
|||||||
registerAdaptor();
|
registerAdaptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConcatenatorAdaptor(const ConcatenatorAdaptor&) = delete;
|
||||||
|
ConcatenatorAdaptor& operator=(const ConcatenatorAdaptor&) = delete;
|
||||||
|
ConcatenatorAdaptor(ConcatenatorAdaptor&&) = delete;
|
||||||
|
ConcatenatorAdaptor& operator=(ConcatenatorAdaptor&&) = delete;
|
||||||
|
|
||||||
~ConcatenatorAdaptor()
|
~ConcatenatorAdaptor()
|
||||||
{
|
{
|
||||||
exit_ = true;
|
exit_ = true;
|
||||||
@@ -273,7 +298,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void concatenate(sdbus::Result<std::string>&& result, std::map<std::string, sdbus::Variant> params) override
|
void concatenate(sdbus::Result<std::string>&& result, std::map<std::string, sdbus::Variant> params) override
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
requests_.push(WorkItem{std::move(params), std::move(result)});
|
requests_.push(WorkItem{std::move(params), std::move(result)});
|
||||||
@@ -303,13 +328,18 @@ public:
|
|||||||
registerProxy();
|
registerProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConcatenatorProxy(const ConcatenatorProxy&) = delete;
|
||||||
|
ConcatenatorProxy& operator=(const ConcatenatorProxy&) = delete;
|
||||||
|
ConcatenatorProxy(ConcatenatorProxy&&) = delete;
|
||||||
|
ConcatenatorProxy& operator=(ConcatenatorProxy&&) = delete;
|
||||||
|
|
||||||
~ConcatenatorProxy()
|
~ConcatenatorProxy()
|
||||||
{
|
{
|
||||||
unregisterProxy();
|
unregisterProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void onConcatenateReply(const std::string& result, [[maybe_unused]] std::optional<sdbus::Error> error) override
|
void onConcatenateReply(const std::string& result, [[maybe_unused]] std::optional<sdbus::Error> error) override
|
||||||
{
|
{
|
||||||
assert(error == std::nullopt);
|
assert(error == std::nullopt);
|
||||||
|
|
||||||
@@ -318,21 +348,21 @@ private:
|
|||||||
str >> aString;
|
str >> aString;
|
||||||
assert(aString == "sdbus-c++-stress-tests");
|
assert(aString == "sdbus-c++-stress-tests");
|
||||||
|
|
||||||
uint32_t aNumber;
|
uint32_t aNumber{};
|
||||||
str >> aNumber;
|
str >> aNumber;
|
||||||
assert(aNumber > 0);
|
assert(aNumber > 0);
|
||||||
|
|
||||||
++repliesReceived_;
|
++repliesReceived_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onConcatenatedSignal(const std::string& concatenatedString) override
|
void onConcatenatedSignal(const std::string& concatenatedString) override
|
||||||
{
|
{
|
||||||
std::stringstream str(concatenatedString);
|
std::stringstream str(concatenatedString);
|
||||||
std::string aString;
|
std::string aString;
|
||||||
str >> aString;
|
str >> aString;
|
||||||
assert(aString == "sdbus-c++-stress-tests");
|
assert(aString == "sdbus-c++-stress-tests");
|
||||||
|
|
||||||
uint32_t aNumber;
|
uint32_t aNumber{};
|
||||||
str >> aNumber;
|
str >> aNumber;
|
||||||
assert(aNumber > 0);
|
assert(aNumber > 0);
|
||||||
|
|
||||||
@@ -345,10 +375,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) // NOLINT(bugprone-exception-escape, readability-function-cognitive-complexity)
|
||||||
{
|
{
|
||||||
long loops;
|
long loops{};
|
||||||
long loopDuration;
|
long loopDuration{};
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
@@ -357,8 +387,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (argc == 3)
|
else if (argc == 3)
|
||||||
{
|
{
|
||||||
loops = std::atol(argv[1]);
|
loops = std::atol(argv[1]); // NOLINT(cert-err34-c, cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||||
loopDuration = std::atol(argv[2]);
|
loopDuration = std::atol(argv[2]); // NOLINT(cert-err34-c, cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Wrong program options");
|
throw std::runtime_error("Wrong program options");
|
||||||
@@ -442,8 +472,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Update statistics
|
// Update statistics
|
||||||
concatenationCallsMade = localCounter;
|
concatenationCallsMade = localCounter;
|
||||||
concatenationRepliesReceived = (uint32_t)concatenator.repliesReceived_;
|
concatenationRepliesReceived = static_cast<uint32_t>(concatenator.repliesReceived_);
|
||||||
concatenationSignalsReceived = (uint32_t)concatenator.signalsReceived_;
|
concatenationSignalsReceived = static_cast<uint32_t>(concatenator.signalsReceived_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user