The Great Embooleanating

A large number of functions had return values and/or arguments changed
to use ``bool`` types instead of ``int``.
This commit is contained in:
Tim Wojtulewicz 2020-03-11 10:41:46 -07:00 committed by Robin Sommer
parent 3c470ffe13
commit fd5e15b116
145 changed files with 1288 additions and 1331 deletions

View file

@ -166,7 +166,7 @@ HashKey* AnalyzerSet::GetKey(const file_analysis::Tag& t, RecordVal* args) const
ListVal* lv = new ListVal(TYPE_ANY);
lv->Append(t.AsEnumVal()->Ref());
lv->Append(args->Ref());
HashKey* key = analyzer_hash->ComputeHash(lv, 1);
HashKey* key = analyzer_hash->ComputeHash(lv, true);
Unref(lv);
if ( ! key )
reporter->InternalError("AnalyzerArgs type mismatch");

View file

@ -301,7 +301,7 @@ bool File::SetMime(const string& mime_type)
auto meta = make_intrusive<RecordVal>(fa_metadata_type);
meta->Assign(meta_mime_type_idx, make_intrusive<StringVal>(mime_type));
meta->Assign(meta_inferred_idx, val_mgr->GetBool(0));
meta->Assign(meta_inferred_idx, val_mgr->GetFalse());
FileEvent(file_sniff, {IntrusivePtr{NewRef{}, val}, std::move(meta)});
return true;
@ -352,7 +352,7 @@ bool File::BufferBOF(const u_char* data, uint64_t len)
uint64_t desired_size = LookupFieldDefaultCount(bof_buffer_size_idx);
bof_buffer.chunks.push_back(new BroString(data, len, 0));
bof_buffer.chunks.push_back(new BroString(data, len, false));
bof_buffer.size += len;
if ( bof_buffer.size < desired_size )

View file

@ -13,7 +13,7 @@ FileTimer::FileTimer(double t, const string& id, double interval)
interval, file_id.c_str());
}
void FileTimer::Dispatch(double t, int is_expire)
void FileTimer::Dispatch(double t, bool is_expire)
{
File* file = file_mgr->LookupFile(file_id);

View file

@ -30,7 +30,7 @@ public:
* @param t current unix time
* @param is_expire true if all pending timers are being expired.
*/
void Dispatch(double t, int is_expire) override;
void Dispatch(double t, bool is_expire) override;
private:
string file_id;

View file

@ -44,7 +44,7 @@ bool DataEvent::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset)
mgr.Enqueue(chunk_event,
IntrusivePtr{NewRef{}, GetFile()->GetVal()},
make_intrusive<StringVal>(new BroString(data, len, 0)),
make_intrusive<StringVal>(new BroString(data, len, false)),
IntrusivePtr{AdoptRef{}, val_mgr->GetCount(offset)}
);
@ -57,7 +57,7 @@ bool DataEvent::DeliverStream(const u_char* data, uint64_t len)
mgr.Enqueue(stream_event,
IntrusivePtr{NewRef{}, GetFile()->GetVal()},
make_intrusive<StringVal>(new BroString(data, len, 0))
make_intrusive<StringVal>(new BroString(data, len, false))
);
return true;

View file

@ -290,7 +290,7 @@ void file_analysis::X509::ParseBasicConstraints(X509_EXTENSION* ex)
if ( x509_ext_basic_constraints )
{
auto pBasicConstraint = make_intrusive<RecordVal>(BifType::Record::X509::BasicConstraints);
pBasicConstraint->Assign(0, val_mgr->GetBool(constr->ca ? 1 : 0));
pBasicConstraint->Assign(0, val_mgr->GetBool(constr->ca));
if ( constr->pathlen )
pBasicConstraint->Assign(1, val_mgr->GetCount((int32_t) ASN1_INTEGER_get(constr->pathlen)));
@ -344,7 +344,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
VectorVal* uris = 0;
VectorVal* ips = 0;
unsigned int otherfields = 0;
bool otherfields = false;
for ( int i = 0; i < sk_GENERAL_NAME_num(altname); i++ )
{
@ -415,7 +415,7 @@ void file_analysis::X509::ParseSAN(X509_EXTENSION* ext)
{
// reporter->Error("Subject alternative name contained unsupported fields. fuid %s", GetFile()->GetID().c_str());
// This happens quite often - just mark it
otherfields = 1;
otherfields = true;
continue;
}
}

View file

@ -623,7 +623,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
if ( precert && issuer_key_hash->Len() != 32)
{
reporter->Error("Invalid issuer_key_hash length");
return val_mgr->GetBool(0);
return val_mgr->GetFalse();
}
std::string data;
@ -647,7 +647,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
if ( pos < 0 )
{
reporter->Error("NID_ct_precert_scts not found");
return val_mgr->GetBool(0);
return val_mgr->GetFalse();
}
#else
int num_ext = X509_get_ext_count(x);
@ -751,7 +751,7 @@ sct_verify_err:
EVP_PKEY_free(key);
reporter->Error("%s", errstr.c_str());
return val_mgr->GetBool(0);
return val_mgr->GetFalse();
%}