Merge remote-tracking branch 'MaxKellermann/eliminate_code

* MaxKellermann/eliminate_code:
  RE: make the RE_Matcher destructor non-virtual
  analyzer/protocol/smtp: remove unnecessary nullptr check
  analyzer/Manager: remove unnecessary clear() calls from destructor
  analyzer/protocol/http: remove unnecessary empty destructor
  iosource/pcap/Source: remove unused fields `last_hdr`, `last_data`
  iosource/Manager: eliminate two std::string copies
This commit is contained in:
Tim Wojtulewicz 2020-02-14 16:16:54 -07:00
commit 47d813badc
9 changed files with 21 additions and 19 deletions

15
CHANGES
View file

@ -1,4 +1,19 @@
3.2.0-dev.44 | 2020-02-14 16:16:54 -0700
* RE: make the RE_Matcher destructor non-virtual (Max Kellermann)
* analyzer/protocol/smtp: remove unnecessary nullptr check (Max Kellermann)
* analyzer/Manager: remove unnecessary clear() calls from destructor (Max Kellermann)
* analyzer/protocol/http: remove unnecessary empty destructor (Max Kellermann)
* iosource/pcap/Source: remove unused fields `last_hdr`, `last_data` (Max Kellermann)
* iosource/Manager: eliminate two std::string copies (Max Kellermann)
3.2.0-dev.37 | 2020-02-14 11:09:50 -0800
* Fix various format specifiers (Jon Siwek, Corelight)

View file

@ -1 +1 @@
3.2.0-dev.37
3.2.0-dev.44

View file

@ -174,12 +174,12 @@ protected:
int current_pos;
};
class RE_Matcher {
class RE_Matcher final {
public:
RE_Matcher();
explicit RE_Matcher(const char* pat);
RE_Matcher(const char* exact_pat, const char* anywhere_pat);
virtual ~RE_Matcher();
~RE_Matcher();
void AddPat(const char* pat);

View file

@ -70,9 +70,6 @@ Manager::~Manager()
for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_udp.begin(); i != analyzers_by_port_udp.end(); i++ )
delete i->second;
analyzers_by_port_udp.clear();
analyzers_by_port_tcp.clear();
// Clean up expected-connection table.
while ( conns_by_timeout.size() )
{

View file

@ -176,7 +176,6 @@ void HTTP_Entity::Deliver(int len, const char* data, int trailing_CRLF)
class HTTP_Entity::UncompressedOutput : public analyzer::OutputHandler {
public:
UncompressedOutput(HTTP_Entity* e) { entity = e; }
virtual ~UncompressedOutput() { }
virtual void DeliverStream(int len, const u_char* data, bool orig)
{
entity->DeliverBodyClear(len, (char*) data, false);

View file

@ -180,8 +180,7 @@ void SMTP_Analyzer::ProcessLine(int length, const char* line, bool orig)
{
// Don't know whether it is a command line or
// a data line.
if ( line_after_gap )
delete line_after_gap;
delete line_after_gap;
line_after_gap =
new BroString((const u_char *) line, length, 1);

View file

@ -325,8 +325,8 @@ static std::pair<std::string, std::string> split_prefix(std::string path)
PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live)
{
std::pair<std::string, std::string> t = split_prefix(path);
std::string prefix = t.first;
std::string npath = t.second;
const auto& prefix = t.first;
const auto& npath = t.second;
// Find the component providing packet sources of the requested prefix.

View file

@ -27,8 +27,6 @@ PcapSource::PcapSource(const std::string& path, bool is_live)
props.is_live = is_live;
pd = nullptr;
memset(&current_hdr, 0, sizeof(current_hdr));
memset(&last_hdr, 0, sizeof(last_hdr));
last_data = nullptr;
}
void PcapSource::Open()
@ -46,7 +44,6 @@ void PcapSource::Close()
pcap_close(pd);
pd = nullptr;
last_data = nullptr;
Closed();
@ -213,7 +210,6 @@ bool PcapSource::ExtractNextPacket(Packet* pkt)
return false;
}
last_data = data;
pkt->Init(props.link_type, &current_hdr.ts, current_hdr.caplen, current_hdr.len, data);
if ( current_hdr.len == 0 || current_hdr.caplen == 0 )
@ -222,8 +218,6 @@ bool PcapSource::ExtractNextPacket(Packet* pkt)
return false;
}
last_hdr = current_hdr;
last_data = data;
++stats.received;
stats.bytes_received += current_hdr.len;

View file

@ -41,8 +41,6 @@ private:
pcap_t *pd;
struct pcap_pkthdr current_hdr;
struct pcap_pkthdr last_hdr;
const u_char* last_data;
};
}