mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Fix clang-tidy readability-isolate-declaration warnings
I missed one of these in review so a machine is probably better at catching them. I fixed the existing instances which where largely in code which look dated. Where possible I slightly reorganized the code so we do not have to leave values uninitialized, but did not touch up anything else.
This commit is contained in:
parent
c725311d07
commit
627c3ad726
32 changed files with 142 additions and 81 deletions
|
@ -250,13 +250,17 @@ TransportProto ICMPAnalyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32_t*
|
|||
}
|
||||
|
||||
zeek::RecordValPtr ICMPAnalyzer::ExtractICMP4Context(int len, const u_char*& data) {
|
||||
uint32_t ip_len, frag_offset;
|
||||
uint32_t ip_len;
|
||||
uint32_t frag_offset;
|
||||
bool bad_hdr_len = false;
|
||||
bool bad_checksum = false;
|
||||
TransportProto proto = TRANSPORT_UNKNOWN;
|
||||
int DF, MF;
|
||||
IPAddr src_addr, dst_addr;
|
||||
uint32_t src_port, dst_port;
|
||||
int DF;
|
||||
int MF;
|
||||
IPAddr src_addr;
|
||||
IPAddr dst_addr;
|
||||
uint32_t src_port;
|
||||
uint32_t dst_port;
|
||||
|
||||
if ( len < (int)sizeof(struct ip) ) {
|
||||
// We don't have an entire IP header.
|
||||
|
@ -322,13 +326,17 @@ zeek::RecordValPtr ICMPAnalyzer::ExtractICMP4Context(int len, const u_char*& dat
|
|||
}
|
||||
|
||||
zeek::RecordValPtr ICMPAnalyzer::ExtractICMP6Context(int len, const u_char*& data) {
|
||||
int DF = 0, MF = 0, bad_hdr_len = 0;
|
||||
int DF = 0;
|
||||
int MF = 0;
|
||||
int bad_hdr_len = 0;
|
||||
TransportProto proto = TRANSPORT_UNKNOWN;
|
||||
|
||||
IPAddr src_addr;
|
||||
IPAddr dst_addr;
|
||||
uint32_t ip_len, frag_offset = 0;
|
||||
uint32_t src_port, dst_port;
|
||||
uint32_t ip_len;
|
||||
uint32_t frag_offset = 0;
|
||||
uint32_t src_port;
|
||||
uint32_t dst_port;
|
||||
|
||||
if ( len < (int)sizeof(struct ip6_hdr) ) {
|
||||
bad_hdr_len = 1;
|
||||
|
@ -408,7 +416,8 @@ void ICMPAnalyzer::RouterAdvert(double t, const struct icmp* icmpp, int len, int
|
|||
if ( ! f )
|
||||
return;
|
||||
|
||||
uint32_t reachable = 0, retrans = 0;
|
||||
uint32_t reachable = 0;
|
||||
uint32_t retrans = 0;
|
||||
|
||||
if ( caplen >= (int)sizeof(reachable) )
|
||||
memcpy(&reachable, data, sizeof(reachable));
|
||||
|
@ -480,7 +489,8 @@ void ICMPAnalyzer::Redirect(double t, const struct icmp* icmpp, int len, int cap
|
|||
if ( ! f )
|
||||
return;
|
||||
|
||||
IPAddr tgtaddr, dstaddr;
|
||||
IPAddr tgtaddr;
|
||||
IPAddr dstaddr;
|
||||
|
||||
if ( caplen >= (int)sizeof(in6_addr) )
|
||||
tgtaddr = IPAddr(*((const in6_addr*)data));
|
||||
|
|
|
@ -25,7 +25,11 @@ zeek::expected<zeek::ConnKeyPtr, std::string> Factory::DoConnKeyFromVal(const ze
|
|||
auto vl = v.AsRecordVal();
|
||||
|
||||
// Indices into conn_id's record field value list:
|
||||
int orig_h = 0, orig_p = 1, resp_h = 2, resp_p = 3, proto = 4;
|
||||
int orig_h = 0;
|
||||
int orig_p = 1;
|
||||
int resp_h = 2;
|
||||
int resp_p = 3;
|
||||
int proto = 4;
|
||||
|
||||
if ( vr != id::conn_id ) {
|
||||
// While it's not a conn_id, it may have equivalent fields.
|
||||
|
|
|
@ -54,7 +54,8 @@ protected:
|
|||
};
|
||||
|
||||
std::pair<int, int> GetConnIdFieldOffsets() {
|
||||
static int vlan_offset = -2, inner_vlan_offset = -2;
|
||||
static int vlan_offset = -2;
|
||||
static int inner_vlan_offset = -2;
|
||||
|
||||
if ( vlan_offset == -2 && inner_vlan_offset == -2 ) {
|
||||
vlan_offset = id::conn_id->FieldOffset("vlan");
|
||||
|
@ -101,7 +102,8 @@ zeek::expected<zeek::ConnKeyPtr, std::string> Factory::DoConnKeyFromVal(const ze
|
|||
auto rt = v.GetType()->AsRecordType();
|
||||
auto vl = v.AsRecordVal();
|
||||
|
||||
int vlan_offset, inner_vlan_offset;
|
||||
int vlan_offset;
|
||||
int inner_vlan_offset;
|
||||
if ( rt == id::conn_id ) {
|
||||
std::tie(vlan_offset, inner_vlan_offset) = k->GetConnIdFieldOffsets();
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ bool IPTunnelAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* pa
|
|||
bool IPTunnelAnalyzer::ProcessEncapsulatedPacket(double t, Packet* pkt, const std::shared_ptr<IP_Hdr>& inner,
|
||||
std::shared_ptr<EncapsulationStack> prev,
|
||||
const EncapsulatingConn& ec) {
|
||||
uint32_t caplen, len;
|
||||
caplen = len = inner->TotalLen();
|
||||
uint32_t caplen = inner->TotalLen();
|
||||
uint32_t len = caplen;
|
||||
|
||||
pkt_timeval ts;
|
||||
int link_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue