mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix/simplify some if statement comparisons
This commit is contained in:
parent
103b381874
commit
5bfd84a903
7 changed files with 13 additions and 12 deletions
|
@ -276,11 +276,12 @@ AnonymizeIPAddr_A50::Node* AnonymizeIPAddr_A50::make_peer(ipaddr32_t a, Node* n)
|
||||||
// the parent of the two new ones.
|
// the parent of the two new ones.
|
||||||
|
|
||||||
Node* down[2];
|
Node* down[2];
|
||||||
|
down[0] = new_node();
|
||||||
if ( ! (down[0] = new_node()) )
|
if ( ! down[0] )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if ( ! (down[1] = new_node()) )
|
down[1] = new_node();
|
||||||
|
if ( ! down[1] )
|
||||||
{
|
{
|
||||||
free_node(down[0]);
|
free_node(down[0]);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -2066,7 +2066,7 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
||||||
|
|
||||||
// If one is a set and one isn't, they shouldn't
|
// If one is a set and one isn't, they shouldn't
|
||||||
// be considered the same type.
|
// be considered the same type.
|
||||||
if ( (t1->IsSet() && ! t2->IsSet()) || (t2->IsSet() && ! t1->IsSet()) )
|
if ( t1->IsSet() != t2->IsSet() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto& y1 = t1->Yield();
|
const auto& y1 = t1->Yield();
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ bool TableVal::Assign(ValPtr index, std::unique_ptr<detail::HashKey> k, ValPtr n
|
||||||
{
|
{
|
||||||
bool is_set = table_type->IsSet();
|
bool is_set = table_type->IsSet();
|
||||||
|
|
||||||
if ( (is_set && new_val) || (! is_set && ! new_val) )
|
if ( is_set == (bool)new_val )
|
||||||
InternalWarning("bad set/table in TableVal::Assign");
|
InternalWarning("bad set/table in TableVal::Assign");
|
||||||
|
|
||||||
TableEntryVal* new_entry_val = new TableEntryVal(std::move(new_val));
|
TableEntryVal* new_entry_val = new TableEntryVal(std::move(new_val));
|
||||||
|
|
|
@ -148,7 +148,7 @@ void String::Set(std::string_view str)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
if ( str.data() )
|
if ( ! str.empty() )
|
||||||
{
|
{
|
||||||
n = str.size();
|
n = str.size();
|
||||||
b = new u_char[n + 1];
|
b = new u_char[n + 1];
|
||||||
|
|
|
@ -436,7 +436,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
// Remove nick name.
|
// Remove nick name.
|
||||||
parts.erase(parts.begin());
|
parts.erase(parts.begin());
|
||||||
|
|
||||||
if ( parts.size() > 0 && parts[0][0] == ':' )
|
if ( parts[0][0] == ':' )
|
||||||
parts[0] = parts[0].substr(1);
|
parts[0] = parts[0].substr(1);
|
||||||
|
|
||||||
auto set = make_intrusive<TableVal>(id::string_set);
|
auto set = make_intrusive<TableVal>(id::string_set);
|
||||||
|
@ -586,7 +586,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
|
||||||
// Check for DCC messages.
|
// Check for DCC messages.
|
||||||
if ( message.size() > 3 && message.substr(0, 3) == "DCC" )
|
if ( message.size() > 3 && message.substr(0, 3) == "DCC" )
|
||||||
{
|
{
|
||||||
if ( message.size() > 0 && message[message.size() - 1] == 1 )
|
if ( message[message.size() - 1] == 1 )
|
||||||
message = message.substr(0, message.size() - 1);
|
message = message.substr(0, message.size() - 1);
|
||||||
|
|
||||||
vector<string> parts = SplitWords(message, ' ');
|
vector<string> parts = SplitWords(message, ' ');
|
||||||
|
|
|
@ -187,7 +187,7 @@ void NetbiosSSN_Interpreter::ParseMessageUDP(const u_char* data, int len, bool i
|
||||||
|
|
||||||
void NetbiosSSN_Interpreter::ParseSessionMsg(const u_char* data, int len, bool is_query)
|
void NetbiosSSN_Interpreter::ParseSessionMsg(const u_char* data, int len, bool is_query)
|
||||||
{
|
{
|
||||||
if ( len < 4 || strncmp((const char*)data, "\xffSMB", 4) )
|
if ( len < 4 || strncmp((const char*)data, "\xffSMB", 4) != 0 )
|
||||||
{
|
{
|
||||||
// This should be an event, too.
|
// This should be an event, too.
|
||||||
analyzer->Weird("netbios_raw_session_msg");
|
analyzer->Weird("netbios_raw_session_msg");
|
||||||
|
|
|
@ -3006,7 +3006,7 @@ function bytestring_to_count%(s: string, is_le: bool &default=F%): count
|
||||||
{
|
{
|
||||||
uint16_t value = 0;
|
uint16_t value = 0;
|
||||||
|
|
||||||
if ( (host_bigendian && is_le) || (! host_bigendian && ! is_le) )
|
if ( host_bigendian == is_le )
|
||||||
{
|
{
|
||||||
char buf[sizeof(uint16_t)];
|
char buf[sizeof(uint16_t)];
|
||||||
memset(buf, 0, sizeof(uint16_t));
|
memset(buf, 0, sizeof(uint16_t));
|
||||||
|
@ -3031,7 +3031,7 @@ function bytestring_to_count%(s: string, is_le: bool &default=F%): count
|
||||||
char buf[sizeof(uint32_t)];
|
char buf[sizeof(uint32_t)];
|
||||||
memset(buf, 0, sizeof(uint32_t));
|
memset(buf, 0, sizeof(uint32_t));
|
||||||
|
|
||||||
if ( (host_bigendian && is_le) || (! host_bigendian && ! is_le) )
|
if ( host_bigendian == is_le )
|
||||||
{
|
{
|
||||||
char *d = &buf[sizeof(uint32_t)-1];
|
char *d = &buf[sizeof(uint32_t)-1];
|
||||||
|
|
||||||
|
@ -3061,7 +3061,7 @@ function bytestring_to_count%(s: string, is_le: bool &default=F%): count
|
||||||
char buf[sizeof(uint64_t)];
|
char buf[sizeof(uint64_t)];
|
||||||
memset(buf, 0, sizeof(uint64_t));
|
memset(buf, 0, sizeof(uint64_t));
|
||||||
|
|
||||||
if ( (host_bigendian && is_le) || (! host_bigendian && ! is_le) )
|
if ( host_bigendian == is_le )
|
||||||
{
|
{
|
||||||
char *d = &buf[sizeof(uint64_t)-1];
|
char *d = &buf[sizeof(uint64_t)-1];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue