Skip to content

Commit f101fe6

Browse files
authored
Merge pull request #57 from CESNET/clang-tools-fix
Fix clang-tidy and clang-format warnings
2 parents 02958db + 7147b6e commit f101fe6

10 files changed

Lines changed: 30 additions & 29 deletions

File tree

common/include/factory/pluginFactoryRegistrator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ struct PluginFactoryRegistrator {
4040
*/
4141
explicit PluginFactoryRegistrator(
4242
const PluginManifest& manifest,
43-
Generator generator = g_lambdaPluginGenerator<Base, Derived>)
43+
const Generator& generator = g_lambdaPluginGenerator<Base, Derived>)
4444
{
4545
static_assert(
46-
std::is_base_of<Base, Derived>::value,
46+
std::is_base_of_v<Base, Derived>,
4747
"Derived template type must be derived from Base");
4848

4949
bool inserted;

modules/deduplicator/src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace Nemea;
3232
* @param biInterface Bidirectional interface for Unirec communication.
3333
* @param deduplicator Deduplicator instance.
3434
*/
35-
void handleFormatChange(
35+
static void handleFormatChange(
3636
UnirecBidirectionalInterface& biInterface,
3737
Deduplicator::Deduplicator& deduplicator)
3838
{
@@ -49,7 +49,7 @@ void handleFormatChange(
4949
* @param biInterface Bidirectional interface for Unirec communication.
5050
* @param deduplicator Deduplicator instance to process flows.
5151
*/
52-
void processNextRecord(
52+
static void processNextRecord(
5353
UnirecBidirectionalInterface& biInterface,
5454
Deduplicator::Deduplicator& deduplicator)
5555
{
@@ -73,7 +73,7 @@ void processNextRecord(
7373
* @param biInterface Bidirectional interface for Unirec communication.
7474
* @param deduplicator Deduplicator instance to process flows.
7575
*/
76-
void processUnirecRecords(
76+
static void processUnirecRecords(
7777
UnirecBidirectionalInterface& biInterface,
7878
Deduplicator::Deduplicator& deduplicator)
7979
{

modules/listDetector/src/ipAddressFieldMatcher.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ uint16_t IpAddressFieldMatcher::getNotLastNodeNextNode(NodePos pos) const noexce
7777
const auto& [octetIndex, startIndex] = pos;
7878

7979
if (octetIndex == 0) {
80-
return (uint16_t)m_octets[octetIndex].size();
80+
return (uint16_t) m_octets[octetIndex].size();
8181
}
8282
auto index = startIndex + 1U;
8383
for (; index < m_octets[octetIndex - 1UL].size() && m_octets[octetIndex - 1UL][index].isLast;
8484
index++) {}
8585
if (index == m_octets[octetIndex - 1UL].size()) {
86-
return (uint16_t)m_octets[octetIndex].size();
86+
return (uint16_t) m_octets[octetIndex].size();
8787
}
8888
return m_octets[octetIndex - 1UL][index].index.nextNode;
8989
}

modules/listDetector/src/ipAddressPrefix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ IpAddressPrefix::IpAddressPrefix(Nemea::IpAddress ipAddress, size_t prefix)
4949
}
5050

5151
if (prefixBits != 0U) {
52-
m_mask.ip.bytes[prefixBytes] = (uint8_t)(UINT8_MAX << (CHAR_BIT - prefixBits));
52+
m_mask.ip.bytes[prefixBytes] = (uint8_t) (UINT8_MAX << (CHAR_BIT - prefixBits));
5353
}
5454
}
5555

modules/listDetector/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
using namespace Nemea;
3030

31-
std::atomic<bool> g_stopFlag(false);
31+
static std::atomic<bool> g_stopFlag(false);
3232

33-
void signalHandler(int signum)
33+
static void signalHandler(int signum)
3434
{
3535
Nm::loggerGet("signalHandler")->info("Interrupt signal {} received", signum);
3636
g_stopFlag.store(true);

modules/listDetector/src/octetNode.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace ListDetector {
1919
struct OctetNode {
2020
public:
2121
/**
22-
* @brief Operator for comparing two OctetNodes.
23-
* @param other The OctetNode to compare with.
24-
* @return True if the two OctetNodes have same value and mask, but current node is terminating.
25-
*/
22+
* @brief Operator for comparing two OctetNodes.
23+
* @param other The OctetNode to compare with.
24+
* @return True if the two OctetNodes have same value and mask, but current node is terminating.
25+
*/
2626
bool operator==(const OctetNode& other) const noexcept
2727
{
2828
return value == other.value && mask == other.mask && !isLast;

modules/sampler/src/main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
using namespace Nemea;
2929

30-
std::atomic<bool> g_stopFlag(false);
30+
static std::atomic<bool> g_stopFlag(false);
3131

32-
void signalHandler(int signum)
32+
static void signalHandler(int signum)
3333
{
3434
Nm::loggerGet("signalHandler")->info("Interrupt signal {} received", signum);
3535
g_stopFlag.store(true);
@@ -43,7 +43,7 @@ void signalHandler(int signum)
4343
*
4444
* @param biInterface Bidirectional interface for Unirec communication.
4545
*/
46-
void handleFormatChange(UnirecBidirectionalInterface& biInterface)
46+
static void handleFormatChange(UnirecBidirectionalInterface& biInterface)
4747
{
4848
biInterface.changeTemplate();
4949
}
@@ -58,7 +58,7 @@ void handleFormatChange(UnirecBidirectionalInterface& biInterface)
5858
* @param sampler Sampler class for sampling.
5959
*/
6060

61-
void processNextRecord(UnirecBidirectionalInterface& biInterface, Sampler::Sampler& sampler)
61+
static void processNextRecord(UnirecBidirectionalInterface& biInterface, Sampler::Sampler& sampler)
6262
{
6363
std::optional<UnirecRecordView> unirecRecord = biInterface.receive();
6464
if (!unirecRecord) {
@@ -80,7 +80,8 @@ void processNextRecord(UnirecBidirectionalInterface& biInterface, Sampler::Sampl
8080
* @param biInterface Bidirectional interface for Unirec communication.
8181
* @param sampler Sampler class for sampling.
8282
*/
83-
void processUnirecRecords(UnirecBidirectionalInterface& biInterface, Sampler::Sampler& sampler)
83+
static void
84+
processUnirecRecords(UnirecBidirectionalInterface& biInterface, Sampler::Sampler& sampler)
8485
{
8586
while (!g_stopFlag.load()) {
8687
try {
@@ -95,7 +96,7 @@ void processUnirecRecords(UnirecBidirectionalInterface& biInterface, Sampler::Sa
9596
}
9697
}
9798

98-
telemetry::Content getSamplerTelemetry(const Sampler::Sampler& sampler)
99+
static telemetry::Content getSamplerTelemetry(const Sampler::Sampler& sampler)
99100
{
100101
auto stats = sampler.getStats();
101102

modules/sampler/src/sampler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Sampler {
1717
*/
1818
struct SamplerStats {
1919
uint64_t sampledRecords = 0; ///< Number of sampled records.
20-
uint64_t totalRecords = 0; ///< Total number of records.
20+
uint64_t totalRecords = 0; ///< Total number of records.
2121
};
2222

2323
/**

modules/telemetry/src/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
using namespace Nemea;
3030

31-
std::atomic<bool> g_stopFlag(false);
31+
static std::atomic<bool> g_stopFlag(false);
3232

33-
void signalHandler(int signum)
33+
static void signalHandler(int signum)
3434
{
3535
Nm::loggerGet("signalHandler")->info("Interrupt signal {} received", signum);
3636
g_stopFlag.store(true);
@@ -44,7 +44,7 @@ void signalHandler(int signum)
4444
*
4545
* @param biInterface Bidirectional interface for Unirec communication.
4646
*/
47-
void handleFormatChange(UnirecBidirectionalInterface& biInterface)
47+
static void handleFormatChange(UnirecBidirectionalInterface& biInterface)
4848
{
4949
biInterface.changeTemplate();
5050
}
@@ -54,7 +54,7 @@ void handleFormatChange(UnirecBidirectionalInterface& biInterface)
5454
*
5555
* @param biInterface Bidirectional interface for Unirec communication.
5656
*/
57-
void processNextRecord(UnirecBidirectionalInterface& biInterface)
57+
static void processNextRecord(UnirecBidirectionalInterface& biInterface)
5858
{
5959
std::optional<UnirecRecordView> unirecRecord = biInterface.receive();
6060
if (!unirecRecord) {
@@ -72,7 +72,7 @@ void processNextRecord(UnirecBidirectionalInterface& biInterface)
7272
*
7373
* @param biInterface Bidirectional interface for Unirec communication.
7474
*/
75-
void processUnirecRecords(UnirecBidirectionalInterface& biInterface)
75+
static void processUnirecRecords(UnirecBidirectionalInterface& biInterface)
7676
{
7777
while (!g_stopFlag.load()) {
7878
try {
@@ -87,7 +87,7 @@ void processUnirecRecords(UnirecBidirectionalInterface& biInterface)
8787
}
8888
}
8989

90-
std::pair<std::string, std::string> splitPluginParams(const std::string& pluginParams)
90+
static std::pair<std::string, std::string> splitPluginParams(const std::string& pluginParams)
9191
{
9292
const std::size_t position = pluginParams.find_first_of(':');
9393
if (position == std::string::npos) {
@@ -99,7 +99,7 @@ std::pair<std::string, std::string> splitPluginParams(const std::string& pluginP
9999
std::string(pluginParams, position + 1));
100100
}
101101

102-
void showOutputPluginUsage()
102+
static void showOutputPluginUsage()
103103
{
104104
auto& outputPluginFactory = Nm::PluginFactory<
105105
TelemetryStats::OutputPlugin,

modules/telemetry/src/ncurses-wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void Ncurces::print(const std::string_view& string)
2929
const std::lock_guard<std::mutex> lock(m_mutex);
3030

3131
clear();
32-
printw("%s\n", string.data());
32+
printw("%.*s\n", static_cast<int>(string.size()), string.data());
3333
refresh();
3434
}
3535

0 commit comments

Comments
 (0)