Skip to content

Commit

Permalink
Clang-tidy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
egecetin committed Nov 7, 2024
1 parent 35f486c commit 7f191ee
Show file tree
Hide file tree
Showing 29 changed files with 106 additions and 106 deletions.
1 change: 1 addition & 0 deletions Common++/header/LRUList.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstddef>
#include <list>
#include <unordered_map>

Expand Down
1 change: 1 addition & 0 deletions Common++/header/TablePrinter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <string>
#include <vector>

/// @file
Expand Down
8 changes: 4 additions & 4 deletions Examples/DpdkBridge/AppWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class AppWorkerThread : public pcpp::DpdkWorkerThread
: m_WorkerConfig(workerConfig), m_Stop(true), m_CoreId(MAX_NUM_OF_CORES + 1)
{}

virtual ~AppWorkerThread()
~AppWorkerThread() override
{
// do nothing
}

// implement abstract methods

bool run(uint32_t coreId)
bool run(uint32_t coreId) override
{
m_CoreId = coreId;
m_Stop = false;
Expand Down Expand Up @@ -73,13 +73,13 @@ class AppWorkerThread : public pcpp::DpdkWorkerThread
return true;
}

void stop()
void stop() override
{
// assign the stop flag which will cause the main loop to end
m_Stop = true;
}

uint32_t getCoreId() const
uint32_t getCoreId() const override
{
return m_CoreId;
}
Expand Down
8 changes: 4 additions & 4 deletions Examples/DpdkExample-FilterTraffic/AppWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppWorkerThread : public pcpp::DpdkWorkerThread
m_PacketMatchingEngine(matchingEngine)
{}

virtual ~AppWorkerThread()
~AppWorkerThread() override
{
// do nothing
}
Expand All @@ -42,7 +42,7 @@ class AppWorkerThread : public pcpp::DpdkWorkerThread

// implement abstract methods

bool run(uint32_t coreId)
bool run(uint32_t coreId) override
{
m_CoreId = coreId;
m_Stop = false;
Expand Down Expand Up @@ -161,13 +161,13 @@ class AppWorkerThread : public pcpp::DpdkWorkerThread
return true;
}

void stop()
void stop() override
{
// assign the stop flag which will cause the main loop to end
m_Stop = true;
}

uint32_t getCoreId() const
uint32_t getCoreId() const override
{
return m_CoreId;
}
Expand Down
6 changes: 3 additions & 3 deletions Examples/PcapSplitter/ConnectionSplitters.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TwoTupleSplitter : public ValueBasedSplitter
* Find the 2-tuple flow for this packet and get the file number it belongs to. If flow is new, return a new file
* number
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
// hash the 2-tuple and look for it in the flow table
uint32_t hash = pcpp::hash2Tuple(&packet);
Expand Down Expand Up @@ -90,7 +90,7 @@ class FiveTupleSplitter : public ValueBasedSplitter
/**
* Find the flow for this packet and get the file number it belongs to. If flow is new, return a new file number
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
// hash the 5-tuple and look for it in the flow table
uint32_t hash = pcpp::hash5Tuple(&packet);
Expand Down Expand Up @@ -153,7 +153,7 @@ class FiveTupleSplitter : public ValueBasedSplitter
/**
* Re-implement Splitter's getFileName() method, this time with the IPs/Ports/protocol value
*/
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber)
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber) override
{
std::ostringstream sstream;

Expand Down
20 changes: 10 additions & 10 deletions Examples/PcapSplitter/IPPortSplitters.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IPPortSplitter : public ValueBasedSplitter
* be an existing flow or a new flow). When opening new flows it uses a virtual abstract method that should be
* Implemented by inherited classes to determine to which file number the flow will be written to
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
// if it's not a TCP or UDP packet, put it in file #0
if (!packet.isPacketOfType(pcpp::TCP) && !packet.isPacketOfType(pcpp::UDP))
Expand Down Expand Up @@ -102,7 +102,7 @@ class IPPortSplitter : public ValueBasedSplitter
/**
* Re-implement Splitter's getFileName() method, this time with the IP/port value
*/
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber)
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber) override
{
// first set the base string as the outputPcapBasePath
std::string result = outputPcapBasePath;
Expand Down Expand Up @@ -259,7 +259,7 @@ class ClientIPSplitter : public IPPortSplitter
* Implementation of the abstract method of IPPortSplitter. This method returns the client IP for a certain flow
* by the logic written at the description of this class
*/
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
switch (packetType)
{
Expand All @@ -283,7 +283,7 @@ class ClientIPSplitter : public IPPortSplitter
}
}

std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
std::string prefix = "client-ip-";

Expand Down Expand Up @@ -335,7 +335,7 @@ class ServerIPSplitter : public IPPortSplitter
* Implementation of the abstract method of IPPortSplitter. This method returns the server IP for a certain flow
* by the logic written at the description of this class
*/
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
switch (packetType)
{
Expand All @@ -359,7 +359,7 @@ class ServerIPSplitter : public IPPortSplitter
}
}

std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
std::string prefix = "server-ip-";

Expand Down Expand Up @@ -412,7 +412,7 @@ class ServerPortSplitter : public IPPortSplitter
* Implementation of the abstract method of IPPortSplitter. This method returns the server port for a certain flow
* by the logic written at the description of this class
*/
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
switch (packetType)
{
Expand All @@ -433,7 +433,7 @@ class ServerPortSplitter : public IPPortSplitter
}
}

std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
std::string prefix = "server-port-";

Expand Down Expand Up @@ -491,7 +491,7 @@ class ClientPortSplitter : public IPPortSplitter
* Implementation of the abstract method of IPPortSplitter. This method returns the client port for a certain flow
* by the logic written at the description of this class
*/
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
uint32_t getValue(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
switch (packetType)
{
Expand All @@ -512,7 +512,7 @@ class ClientPortSplitter : public IPPortSplitter
}
}

std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort)
std::string getValueString(pcpp::Packet& packet, PacketType packetType, uint16_t srcPort, uint16_t dstPort) override
{
std::string prefix = "client-port-";

Expand Down
18 changes: 9 additions & 9 deletions Examples/PcapSplitter/SimpleSplitters.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PacketCountSplitter : public Splitter
* Return the current file number if its packet count didn't reach the limit, or else return the next
* file number and close the current file
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
// check the current file number
int curFile = m_PacketCount / m_MaxPacketsPerFile;
Expand All @@ -44,7 +44,7 @@ class PacketCountSplitter : public Splitter
/**
* Make sure packet count is a positive number
*/
bool isSplitterParamLegal(std::string& errorString)
bool isSplitterParamLegal(std::string& errorString) override
{
if (m_MaxPacketsPerFile < 1)
{
Expand Down Expand Up @@ -83,7 +83,7 @@ class FileSizeSplitter : public Splitter
* Return the current file number if its size didn't reach the file size limit, or else return the next
* file number and close the current file
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
// check the current file
int prevFile = m_TotalSize / m_MaxBytesPerFile;
Expand All @@ -100,7 +100,7 @@ class FileSizeSplitter : public Splitter
/**
* Each file size must be at least in size of PCAP_FILE_HEADER_SIZE + PCAP_PACKET_HEADER_SIZE
*/
bool isSplitterParamLegal(std::string& errorString)
bool isSplitterParamLegal(std::string& errorString) override
{
if (m_MaxBytesPerFile < PCAP_PACKET_HEADER_SIZE + 1)
{
Expand Down Expand Up @@ -129,7 +129,7 @@ class BpfCriteriaSplitter : public Splitter
/**
* Return file #0 if packet matches the BPF filer, and file #1 if it's not
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
if (pcpp::IPcapDevice::matchPacketWithFilter(filter, packet.getRawPacket()))
return 0;
Expand All @@ -140,7 +140,7 @@ class BpfCriteriaSplitter : public Splitter
* Re-implement Splitter's getFileName() method, clarifying which file was matched by the BPF
* filter and which didn't
*/
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber)
std::string getFileName(pcpp::Packet& packet, const std::string& outputPcapBasePath, int fileNumber) override
{
if (fileNumber == 0)
return outputPcapBasePath + "match-bpf";
Expand All @@ -151,7 +151,7 @@ class BpfCriteriaSplitter : public Splitter
/**
* Verifies the BPF filter set in the c'tor is a valid BPF filter
*/
bool isSplitterParamLegal(std::string& errorString)
bool isSplitterParamLegal(std::string& errorString) override
{
if (m_BpfFilter == "")
{
Expand Down Expand Up @@ -180,15 +180,15 @@ class RoundRobinSplitter : public SplitterWithMaxFiles
/**
* Get the next file number, SplitterWithMaxFiles#getNextFileNumber() takes care of the round-robin method
*/
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose)
int getFileNumber(pcpp::Packet& packet, std::vector<int>& filesToClose) override
{
return getNextFileNumber(filesToClose);
}

/**
* Number of files must be a positive integer
*/
bool isSplitterParamLegal(std::string& errorString)
bool isSplitterParamLegal(std::string& errorString) override
{
if (m_MaxFiles < 1)
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/PcapSplitter/Splitters.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SplitterWithMaxFiles : public Splitter
* This method checks the maximum number of file parameter. If it equals UNLIMITED_FILES_MAGIC_NUMBER it means there
* is no limit. Else it verifies the limit is a positive number
*/
bool isSplitterParamLegal(std::string& errorString)
bool isSplitterParamLegal(std::string& errorString) override
{
// unlimited number of output files
if (m_MaxFiles == UNLIMITED_FILES_MAGIC_NUMBER)
Expand Down
8 changes: 4 additions & 4 deletions Examples/Tutorials/Tutorial-DpdkL2Fwd/WorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class L2FwdWorkerThread : public pcpp::DpdkWorkerThread
L2FwdWorkerThread(pcpp::DpdkDevice* rxDevice, pcpp::DpdkDevice* txDevice);

// d'tor (does nothing)
~L2FwdWorkerThread()
~L2FwdWorkerThread() override
{}

// implement abstract method

// start running the worker thread
bool run(uint32_t coreId);
bool run(uint32_t coreId) override;

// ask the worker thread to stop
void stop();
void stop() override;

// get worker thread core ID
uint32_t getCoreId() const;
uint32_t getCoreId() const override;
};
8 changes: 4 additions & 4 deletions Packet++/header/HttpLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,13 @@ namespace pcpp
class HttpRequestFirstLineException : public std::exception
{
public:
~HttpRequestFirstLineException() noexcept
~HttpRequestFirstLineException() noexcept override
{}
void setMessage(const std::string& message)
{
m_Message = message;
}
virtual const char* what() const noexcept
const char* what() const noexcept override
{
return m_Message.c_str();
}
Expand Down Expand Up @@ -856,13 +856,13 @@ namespace pcpp
class HttpResponseFirstLineException : public std::exception
{
public:
~HttpResponseFirstLineException() noexcept
~HttpResponseFirstLineException() noexcept override
{}
void setMessage(const std::string& message)
{
m_Message = message;
}
virtual const char* what() const noexcept
const char* what() const noexcept override
{
return m_Message.c_str();
}
Expand Down
6 changes: 3 additions & 3 deletions Packet++/header/IPv6Extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace pcpp
/**
* A d'tor for this class, currently does nothing
*/
~IPv6Option()
~IPv6Option() override
{}

/**
Expand All @@ -247,7 +247,7 @@ namespace pcpp

// implement abstract methods

size_t getTotalSize() const
size_t getTotalSize() const override
{
if (m_Data == nullptr)
return 0;
Expand All @@ -258,7 +258,7 @@ namespace pcpp
return (size_t)(m_Data->recordLen + sizeof(uint16_t));
}

size_t getDataSize() const
size_t getDataSize() const override
{
if (m_Data == nullptr || m_Data->recordType == Pad0OptionType)
return 0;
Expand Down
Loading

0 comments on commit 7f191ee

Please sign in to comment.