iosource/threading/input/logging: Replace nulls with nullptr

This commit is contained in:
Tim Wojtulewicz 2020-04-01 16:52:03 -07:00
parent 4ee84b69f2
commit cb01e098df
27 changed files with 154 additions and 156 deletions

View file

@ -166,13 +166,13 @@ Manager::TableStream::~TableStream()
if ( rtype ) // can be 0 for sets if ( rtype ) // can be 0 for sets
Unref(rtype); Unref(rtype);
if ( currDict != 0 ) if ( currDict )
{ {
currDict->Clear(); currDict->Clear();
delete currDict; delete currDict;
} }
if ( lastDict != 0 ) if ( lastDict )
{ {
lastDict->Clear();; lastDict->Clear();;
delete lastDict; delete lastDict;
@ -211,7 +211,7 @@ ReaderBackend* Manager::CreateBackend(ReaderFrontend* frontend, EnumVal* tag)
if ( ! c ) if ( ! c )
{ {
reporter->Error("The reader that was requested was not found and could not be initialized."); reporter->Error("The reader that was requested was not found and could not be initialized.");
return 0; return nullptr;
} }
ReaderBackend* backend = (*c->Factory())(frontend); ReaderBackend* backend = (*c->Factory())(frontend);
@ -234,8 +234,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
string name = description->Lookup("name", true)->AsString()->CheckString(); string name = description->Lookup("name", true)->AsString()->CheckString();
Stream *i = FindStream(name); if ( Stream *i = FindStream(name) )
if ( i != 0 )
{ {
reporter->Error("Trying create already existing input stream %s", reporter->Error("Trying create already existing input stream %s",
name.c_str()); name.c_str());
@ -551,7 +550,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
} }
auto event_val = fval->Lookup("ev", true); auto event_val = fval->Lookup("ev", true);
Func* event = event_val ? event_val->AsFunc() : 0; Func* event = event_val ? event_val->AsFunc() : nullptr;
if ( event ) if ( event )
{ {
@ -672,13 +671,13 @@ bool Manager::CreateTableStream(RecordVal* fval)
for ( unsigned int i = 0; i < fieldsV.size(); i++ ) for ( unsigned int i = 0; i < fieldsV.size(); i++ )
fields[i] = fieldsV[i]; fields[i] = fieldsV[i];
stream->pred = pred ? pred->AsFunc() : 0; stream->pred = pred ? pred->AsFunc() : nullptr;
stream->num_idx_fields = idxfields; stream->num_idx_fields = idxfields;
stream->num_val_fields = valfields; stream->num_val_fields = valfields;
stream->tab = dst.release()->AsTableVal(); stream->tab = dst.release()->AsTableVal();
stream->rtype = val.release(); stream->rtype = val.release();
stream->itype = idx->Ref()->AsRecordType(); stream->itype = idx->Ref()->AsRecordType();
stream->event = event ? event_registry->Lookup(event->Name()) : 0; stream->event = event ? event_registry->Lookup(event->Name()) : nullptr;
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr; stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
stream->currDict = new PDict<InputHash>; stream->currDict = new PDict<InputHash>;
stream->currDict->SetDeleteFunc(input_hash_delete_func); stream->currDict->SetDeleteFunc(input_hash_delete_func);
@ -769,7 +768,7 @@ bool Manager::CreateAnalysisStream(RecordVal* fval)
// reader takes in a byte stream as the only field // reader takes in a byte stream as the only field
Field** fields = new Field*[1]; Field** fields = new Field*[1];
fields[0] = new Field("bytestream", 0, TYPE_STRING, TYPE_VOID, false); fields[0] = new Field("bytestream", nullptr, TYPE_STRING, TYPE_VOID, false);
stream->reader->Init(1, fields); stream->reader->Init(1, fields);
readers[stream->reader] = stream; readers[stream->reader] = stream;
@ -833,7 +832,7 @@ bool Manager::IsCompatibleType(BroType* t, bool atomic_only)
bool Manager::RemoveStream(Stream *i) bool Manager::RemoveStream(Stream *i)
{ {
if ( i == 0 ) if ( i == nullptr )
return false; // not found return false; // not found
if ( i->removed ) if ( i->removed )
@ -868,7 +867,7 @@ bool Manager::RemoveStreamContinuation(ReaderFrontend* reader)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->Error("Stream not found in RemoveStreamContinuation"); reporter->Error("Stream not found in RemoveStreamContinuation");
return false; return false;
@ -934,7 +933,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
else else
{ {
string name = nameprepend + rec->FieldName(i); string name = nameprepend + rec->FieldName(i);
const char* secondary = 0; const char* secondary = nullptr;
IntrusivePtr<Val> c; IntrusivePtr<Val> c;
TypeTag ty = rec->FieldType(i)->Tag(); TypeTag ty = rec->FieldType(i)->Tag();
TypeTag st = TYPE_VOID; TypeTag st = TYPE_VOID;
@ -951,7 +950,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
{ {
// we have an annotation for the second column // we have an annotation for the second column
c = rec->FieldDecl(i)->FindAttr(ATTR_TYPE_COLUMN)->AttrExpr()->Eval(0); c = rec->FieldDecl(i)->FindAttr(ATTR_TYPE_COLUMN)->AttrExpr()->Eval(nullptr);
assert(c); assert(c);
assert(c->Type()->Tag() == TYPE_STRING); assert(c->Type()->Tag() == TYPE_STRING);
@ -973,7 +972,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
bool Manager::ForceUpdate(const string &name) bool Manager::ForceUpdate(const string &name)
{ {
Stream *i = FindStream(name); Stream *i = FindStream(name);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->Error("Stream %s not found", name.c_str()); reporter->Error("Stream %s not found", name.c_str());
return false; return false;
@ -1057,7 +1056,7 @@ Val* Manager::ValueToIndexVal(const Stream* i, int num_fields, const RecordType
void Manager::SendEntry(ReaderFrontend* reader, Value* *vals) void Manager::SendEntry(ReaderFrontend* reader, Value* *vals)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in SendEntry", reporter->InternalWarning("Unknown reader %s in SendEntry",
reader->Name()); reader->Name());
@ -1101,7 +1100,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
HashKey* idxhash = HashValues(stream->num_idx_fields, vals); HashKey* idxhash = HashValues(stream->num_idx_fields, vals);
if ( idxhash == 0 ) if ( idxhash == nullptr )
{ {
Warning(i, "Could not hash line. Ignoring"); Warning(i, "Could not hash line. Ignoring");
return stream->num_val_fields + stream->num_idx_fields; return stream->num_val_fields + stream->num_idx_fields;
@ -1110,21 +1109,20 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
hash_t valhash = 0; hash_t valhash = 0;
if ( stream->num_val_fields > 0 ) if ( stream->num_val_fields > 0 )
{ {
HashKey* valhashkey = HashValues(stream->num_val_fields, vals+stream->num_idx_fields); if ( HashKey* valhashkey = HashValues(stream->num_val_fields, vals+stream->num_idx_fields) )
if ( valhashkey == 0 )
{
// empty line. index, but no values.
// hence we also have no hash value...
}
else
{ {
valhash = valhashkey->Hash(); valhash = valhashkey->Hash();
delete(valhashkey); delete(valhashkey);
} }
else
{
// empty line. index, but no values.
// hence we also have no hash value...
}
} }
InputHash *h = stream->lastDict->Lookup(idxhash); InputHash *h = stream->lastDict->Lookup(idxhash);
if ( h != 0 ) if ( h )
{ {
// seen before // seen before
if ( stream->num_val_fields == 0 || h->valhash == valhash ) if ( stream->num_val_fields == 0 || h->valhash == valhash )
@ -1148,14 +1146,14 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
} }
Val* valval; Val* valval;
RecordVal* predidx = 0; RecordVal* predidx = nullptr;
int position = stream->num_idx_fields; int position = stream->num_idx_fields;
bool convert_error = false; // this will be set to true by ValueTo* on Error bool convert_error = false; // this will be set to true by ValueTo* on Error
if ( stream->num_val_fields == 0 ) if ( stream->num_val_fields == 0 )
valval = 0; valval = nullptr;
else if ( stream->num_val_fields == 1 && !stream->want_record ) else if ( stream->num_val_fields == 1 && !stream->want_record )
valval = ValueToVal(i, vals[position], stream->rtype->FieldType(0), convert_error); valval = ValueToVal(i, vals[position], stream->rtype->FieldType(0), convert_error);
@ -1213,10 +1211,10 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
// now we don't need h anymore - if we are here, the entry is updated and a new h is created. // now we don't need h anymore - if we are here, the entry is updated and a new h is created.
delete h; delete h;
h = 0; h = nullptr;
Val* idxval; Val* idxval;
if ( predidx != 0 ) if ( predidx != nullptr )
{ {
idxval = RecordValToIndexVal(predidx); idxval = RecordValToIndexVal(predidx);
// I think there is an unref missing here. But if I insert is, it crashes :) // I think there is an unref missing here. But if I insert is, it crashes :)
@ -1256,7 +1254,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
stream->tab->Assign(idxval, k, valval); stream->tab->Assign(idxval, k, valval);
Unref(idxval); // asssign does not consume idxval. Unref(idxval); // asssign does not consume idxval.
if ( predidx != 0 ) if ( predidx != nullptr )
Unref(predidx); Unref(predidx);
auto prev = stream->currDict->Insert(idxhash, ih); auto prev = stream->currDict->Insert(idxhash, ih);
@ -1279,7 +1277,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
{ // in case of update send back the old value. { // in case of update send back the old value.
assert ( stream->num_val_fields > 0 ); assert ( stream->num_val_fields > 0 );
ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_CHANGED).release(); ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_CHANGED).release();
assert ( oldval != 0 ); assert ( oldval != nullptr );
SendEvent(stream->event, 4, stream->description->Ref(), ev, predidx, oldval.release()); SendEvent(stream->event, 4, stream->description->Ref(), ev, predidx, oldval.release());
} }
else else
@ -1302,7 +1300,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in EndCurrentSend", reporter->InternalWarning("Unknown reader %s in EndCurrentSend",
reader->Name()); reader->Name());
@ -1336,8 +1334,8 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
{ {
IntrusivePtr<Val> val; IntrusivePtr<Val> val;
Val* predidx = 0; Val* predidx = nullptr;
EnumVal* ev = 0; EnumVal* ev = nullptr;
int startpos = 0; int startpos = 0;
if ( stream->pred || stream->event ) if ( stream->pred || stream->event )
@ -1345,7 +1343,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
auto idx = stream->tab->RecoverIndex(ih->idxkey); auto idx = stream->tab->RecoverIndex(ih->idxkey);
assert(idx != nullptr); assert(idx != nullptr);
val = stream->tab->Lookup(idx.get()); val = stream->tab->Lookup(idx.get());
assert(val != 0); assert(val != nullptr);
predidx = ListValToRecordVal(idx.get(), stream->itype, &startpos); predidx = ListValToRecordVal(idx.get(), stream->itype, &startpos);
ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_REMOVED).release(); ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_REMOVED).release();
} }
@ -1409,7 +1407,7 @@ void Manager::SendEndOfData(ReaderFrontend* reader)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in SendEndOfData", reporter->InternalWarning("Unknown reader %s in SendEndOfData",
reader->Name()); reader->Name());
@ -1436,7 +1434,7 @@ void Manager::SendEndOfData(const Stream *i)
void Manager::Put(ReaderFrontend* reader, Value* *vals) void Manager::Put(ReaderFrontend* reader, Value* *vals)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Put", reader->Name()); reporter->InternalWarning("Unknown reader %s in Put", reader->Name());
return; return;
@ -1500,7 +1498,7 @@ int Manager::SendEventStreamEvent(Stream* i, EnumVal* type, const Value* const *
{ {
for ( int j = 0; j < stream->fields->NumFields(); j++) for ( int j = 0; j < stream->fields->NumFields(); j++)
{ {
Val* val = 0; Val* val = nullptr;
if ( stream->fields->FieldType(j)->Tag() == TYPE_RECORD ) if ( stream->fields->FieldType(j)->Tag() == TYPE_RECORD )
val = ValueToRecordVal(i, vals, val = ValueToRecordVal(i, vals,
@ -1544,7 +1542,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
int position = stream->num_idx_fields; int position = stream->num_idx_fields;
if ( stream->num_val_fields == 0 ) if ( stream->num_val_fields == 0 )
valval = 0; valval = nullptr;
else if ( stream->num_val_fields == 1 && stream->want_record == 0 ) else if ( stream->num_val_fields == 1 && stream->want_record == 0 )
valval = ValueToVal(i, vals[position], stream->rtype->FieldType(0), convert_error); valval = ValueToVal(i, vals[position], stream->rtype->FieldType(0), convert_error);
@ -1571,7 +1569,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
oldval = stream->tab->Lookup(idxval, false); oldval = stream->tab->Lookup(idxval, false);
} }
if ( oldval != 0 ) if ( oldval != nullptr )
{ {
// it is an update // it is an update
updated = true; updated = true;
@ -1633,7 +1631,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
// in case of update send back the old value. // in case of update send back the old value.
assert ( stream->num_val_fields > 0 ); assert ( stream->num_val_fields > 0 );
ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_CHANGED).release(); ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_CHANGED).release();
assert ( oldval != 0 ); assert ( oldval != nullptr );
SendEvent(stream->event, 4, stream->description->Ref(), SendEvent(stream->event, 4, stream->description->Ref(),
ev, predidx, oldval.release()); ev, predidx, oldval.release());
} }
@ -1665,7 +1663,7 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
void Manager::Clear(ReaderFrontend* reader) void Manager::Clear(ReaderFrontend* reader)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Clear", reporter->InternalWarning("Unknown reader %s in Clear",
reader->Name()); reader->Name());
@ -1687,7 +1685,7 @@ void Manager::Clear(ReaderFrontend* reader)
bool Manager::Delete(ReaderFrontend* reader, Value* *vals) bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in Delete", reader->Name()); reporter->InternalWarning("Unknown reader %s in Delete", reader->Name());
return false; return false;
@ -1701,7 +1699,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
TableStream* stream = (TableStream*) i; TableStream* stream = (TableStream*) i;
bool convert_error = false; bool convert_error = false;
Val* idxval = ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals, convert_error); Val* idxval = ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals, convert_error);
assert(idxval != 0); assert(idxval != nullptr);
readVals = stream->num_idx_fields + stream->num_val_fields; readVals = stream->num_idx_fields + stream->num_val_fields;
bool streamresult = true; bool streamresult = true;
@ -1742,7 +1740,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
if ( streamresult && stream->event ) if ( streamresult && stream->event )
{ {
Ref(idxval); Ref(idxval);
assert(val != 0); assert(val != nullptr);
EnumVal* ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_REMOVED).release(); EnumVal* ev = BifType::Enum::Input::Event->GetVal(BifEnum::Input::EVENT_REMOVED).release();
SendEvent(stream->event, 4, stream->description->Ref(), ev, idxval, IntrusivePtr{val}.release()); SendEvent(stream->event, 4, stream->description->Ref(), ev, idxval, IntrusivePtr{val}.release());
} }
@ -1806,7 +1804,7 @@ bool Manager::CallPred(Func* pred_func, const int numvals, ...) const
bool Manager::SendEvent(ReaderFrontend* reader, const string& name, const int num_vals, Value* *vals) const bool Manager::SendEvent(ReaderFrontend* reader, const string& name, const int num_vals, Value* *vals) const
{ {
Stream *i = FindStream(reader); Stream *i = FindStream(reader);
if ( i == 0 ) if ( i == nullptr )
{ {
reporter->InternalWarning("Unknown reader %s in SendEvent for event %s", reader->Name(), name.c_str()); reporter->InternalWarning("Unknown reader %s in SendEvent for event %s", reader->Name(), name.c_str());
delete_value_ptr_array(vals, num_vals); delete_value_ptr_array(vals, num_vals);
@ -1814,7 +1812,7 @@ bool Manager::SendEvent(ReaderFrontend* reader, const string& name, const int nu
} }
EventHandler* handler = event_registry->Lookup(name); EventHandler* handler = event_registry->Lookup(name);
if ( handler == 0 ) if ( handler == nullptr )
{ {
Warning(i, "Event %s not found", name.c_str()); Warning(i, "Event %s not found", name.c_str());
delete_value_ptr_array(vals, num_vals); delete_value_ptr_array(vals, num_vals);
@ -1904,18 +1902,18 @@ void Manager::SendEvent(EventHandlerPtr ev, list<Val*> events) const
// I / we could think about moving this functionality to val.cc // I / we could think about moving this functionality to val.cc
RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type, int* position) const RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type, int* position) const
{ {
assert(position != 0 ); // we need the pointer to point to data; assert(position != nullptr); // we need the pointer to point to data;
RecordVal* rec = new RecordVal(request_type->AsRecordType()); RecordVal* rec = new RecordVal(request_type->AsRecordType());
assert(list != 0); assert(list != nullptr);
int maxpos = list->Length(); int maxpos = list->Length();
for ( int i = 0; i < request_type->NumFields(); i++ ) for ( int i = 0; i < request_type->NumFields(); i++ )
{ {
assert ( (*position) <= maxpos ); assert ( (*position) <= maxpos );
Val* fieldVal = 0; Val* fieldVal = nullptr;
if ( request_type->FieldType(i)->Tag() == TYPE_RECORD ) if ( request_type->FieldType(i)->Tag() == TYPE_RECORD )
fieldVal = ListValToRecordVal(list, request_type->FieldType(i)->AsRecordType(), position); fieldVal = ListValToRecordVal(list, request_type->FieldType(i)->AsRecordType(), position);
else else
@ -1934,12 +1932,12 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType *request_type,
RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *vals, RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *vals,
RecordType *request_type, int* position, bool& have_error) const RecordType *request_type, int* position, bool& have_error) const
{ {
assert(position != 0); // we need the pointer to point to data. assert(position != nullptr); // we need the pointer to point to data.
RecordVal* rec = new RecordVal(request_type->AsRecordType()); RecordVal* rec = new RecordVal(request_type->AsRecordType());
for ( int i = 0; i < request_type->NumFields(); i++ ) for ( int i = 0; i < request_type->NumFields(); i++ )
{ {
Val* fieldVal = 0; Val* fieldVal = nullptr;
if ( request_type->FieldType(i)->Tag() == TYPE_RECORD ) if ( request_type->FieldType(i)->Tag() == TYPE_RECORD )
fieldVal = ValueToRecordVal(stream, vals, request_type->FieldType(i)->AsRecordType(), position, have_error); fieldVal = ValueToRecordVal(stream, vals, request_type->FieldType(i)->AsRecordType(), position, have_error);
else if ( request_type->FieldType(i)->Tag() == TYPE_FILE || else if ( request_type->FieldType(i)->Tag() == TYPE_FILE ||
@ -2215,7 +2213,7 @@ HashKey* Manager::HashValues(const int num_elements, const Value* const *vals) c
assert ( length >= num_elements ); assert ( length >= num_elements );
if ( length == num_elements ) if ( length == num_elements )
return NULL; return nullptr;
int position = 0; int position = 0;
char *data = new char[length]; char *data = new char[length];
@ -2285,7 +2283,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
case TYPE_ADDR: case TYPE_ADDR:
{ {
IPAddr* addr = 0; IPAddr* addr = nullptr;
switch ( val->val.addr_val.family ) { switch ( val->val.addr_val.family ) {
case IPv4: case IPv4:
addr = new IPAddr(val->val.addr_val.in.in4); addr = new IPAddr(val->val.addr_val.in.in4);
@ -2344,7 +2342,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
{ {
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type, have_error); Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type, have_error);
t->Assign(assignval, 0); t->Assign(assignval, nullptr);
Unref(assignval); // index is not consumed by assign. Unref(assignval); // index is not consumed by assign.
} }
@ -2395,7 +2393,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ
} }
assert(false); assert(false);
return NULL; return nullptr;
} }
Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) const Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) const
@ -2433,7 +2431,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
case TYPE_ADDR: case TYPE_ADDR:
{ {
IPAddr* addr = 0; IPAddr* addr = nullptr;
switch ( val->val.addr_val.family ) { switch ( val->val.addr_val.family ) {
case IPv4: case IPv4:
addr = new IPAddr(val->val.addr_val.in.in4); addr = new IPAddr(val->val.addr_val.in.in4);
@ -2526,7 +2524,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
{ {
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], have_error); Val* assignval = ValueToVal(i, val->val.set_val.vals[j], have_error);
t->Assign(assignval, 0); t->Assign(assignval, nullptr);
Unref(assignval); // index is not consumed by assign. Unref(assignval); // index is not consumed by assign.
} }
@ -2593,7 +2591,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co
} }
assert(false); assert(false);
return NULL; return nullptr;
} }
Manager::Stream* Manager::FindStream(const string &name) const Manager::Stream* Manager::FindStream(const string &name) const
@ -2604,7 +2602,7 @@ Manager::Stream* Manager::FindStream(const string &name) const
return (*s).second; return (*s).second;
} }
return 0; return nullptr;
} }
Manager::Stream* Manager::FindStream(ReaderFrontend* reader) const Manager::Stream* Manager::FindStream(ReaderFrontend* reader) const
@ -2613,7 +2611,7 @@ Manager::Stream* Manager::FindStream(ReaderFrontend* reader) const
if ( s != readers.end() ) if ( s != readers.end() )
return s->second; return s->second;
return 0; return nullptr;
} }
// Function is called on Bro shutdown. // Function is called on Bro shutdown.

View file

@ -204,7 +204,7 @@ ReaderBackend::ReaderBackend(ReaderFrontend* arg_frontend) : MsgThread()
frontend = arg_frontend; frontend = arg_frontend;
info = new ReaderInfo(frontend->Info()); info = new ReaderInfo(frontend->Info());
num_fields = 0; num_fields = 0;
fields = 0; fields = nullptr;
SetName(frontend->Name()); SetName(frontend->Name());
} }
@ -282,13 +282,13 @@ bool ReaderBackend::OnFinish(double network_time)
disabled = true; // frontend disables itself when it gets the Close-message. disabled = true; // frontend disables itself when it gets the Close-message.
SendOut(new ReaderClosedMessage(frontend)); SendOut(new ReaderClosedMessage(frontend));
if ( fields != 0 ) if ( fields )
{ {
for ( unsigned int i = 0; i < num_fields; i++ ) for ( unsigned int i = 0; i < num_fields; i++ )
delete(fields[i]); delete(fields[i]);
delete [] (fields); delete [] (fields);
fields = 0; fields = nullptr;
} }
return true; return true;

View file

@ -104,15 +104,15 @@ public:
ReaderInfo() ReaderInfo()
{ {
source = 0; source = nullptr;
name = 0; name = nullptr;
mode = MODE_NONE; mode = MODE_NONE;
} }
ReaderInfo(const ReaderInfo& other) ReaderInfo(const ReaderInfo& other)
{ {
source = other.source ? copy_string(other.source) : 0; source = other.source ? copy_string(other.source) : nullptr;
name = other.name ? copy_string(other.name) : 0; name = other.name ? copy_string(other.name) : nullptr;
mode = other.mode; mode = other.mode;
for ( config_map::const_iterator i = other.config.begin(); i != other.config.end(); i++ ) for ( config_map::const_iterator i = other.config.begin(); i != other.config.end(); i++ )

View file

@ -52,7 +52,7 @@ void ReaderFrontend::Stop()
if ( backend ) if ( backend )
{ {
backend->SignalStop(); backend->SignalStop();
backend = 0; // Thread manager will clean it up once it finishes. backend = nullptr; // Thread manager will clean it up once it finishes.
} }
} }

View file

@ -396,7 +396,7 @@ bool Ascii::DoUpdate()
Value* val = formatter->ParseValue(stringfields[(*fit).position], (*fit).name, (*fit).type, (*fit).subtype); Value* val = formatter->ParseValue(stringfields[(*fit).position], (*fit).name, (*fit).type, (*fit).subtype);
if ( val == 0 ) if ( ! val )
{ {
Warning(Fmt("Could not convert line '%s' of %s to Val. Ignoring line.", line.c_str(), fname.c_str())); Warning(Fmt("Could not convert line '%s' of %s to Val. Ignoring line.", line.c_str(), fname.c_str()));
error = true; error = true;

View file

@ -210,11 +210,11 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
for ( unsigned int pos = 0; pos < length; pos++ ) for ( unsigned int pos = 0; pos < length; pos++ )
{ {
Value* newval = EntryToVal(subtype, TYPE_ENUM); Value* newval = EntryToVal(subtype, TYPE_ENUM);
if ( newval == 0 ) if ( newval == nullptr )
{ {
Error("Error while reading set"); Error("Error while reading set");
delete val; delete val;
return 0; return nullptr;
} }
lvals[pos] = newval; lvals[pos] = newval;
} }
@ -226,7 +226,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
default: default:
Error(Fmt("unsupported field format %d", type)); Error(Fmt("unsupported field format %d", type));
delete val; delete val;
return 0; return nullptr;
} }
return val; return val;
@ -265,7 +265,7 @@ bool Benchmark::DoHeartbeat(double network_time, double current_time)
Update(); // call update and not DoUpdate, because update actually checks disabled. Update(); // call update and not DoUpdate, because update actually checks disabled.
SendEvent("HeartbeatDone", 0, 0); SendEvent("HeartbeatDone", 0, nullptr);
break; break;
default: default:

View file

@ -14,7 +14,7 @@ using threading::Field;
streamsize Binary::chunk_size = 0; streamsize Binary::chunk_size = 0;
Binary::Binary(ReaderFrontend *frontend) Binary::Binary(ReaderFrontend *frontend)
: ReaderBackend(frontend), in(0), mtime(0), ino(0), firstrun(true) : ReaderBackend(frontend), in(nullptr), mtime(0), ino(0), firstrun(true)
{ {
if ( ! chunk_size ) if ( ! chunk_size )
{ {
@ -64,7 +64,7 @@ bool Binary::CloseInput()
in->close(); in->close();
delete in; delete in;
in = 0; in = nullptr;
#ifdef DEBUG #ifdef DEBUG
Debug(DBG_INPUT, "Binary reader finished close"); Debug(DBG_INPUT, "Binary reader finished close");
@ -76,7 +76,7 @@ bool Binary::CloseInput()
bool Binary::DoInit(const ReaderInfo& info, int num_fields, bool Binary::DoInit(const ReaderInfo& info, int num_fields,
const Field* const* fields) const Field* const* fields)
{ {
in = 0; in = nullptr;
mtime = 0; mtime = 0;
ino = 0; ino = 0;
firstrun = true; firstrun = true;
@ -158,7 +158,7 @@ streamsize Binary::GetChunk(char** chunk)
if ( ! bytes_read ) if ( ! bytes_read )
{ {
delete [] *chunk; delete [] *chunk;
*chunk = 0; *chunk = nullptr;
return 0; return 0;
} }
@ -231,7 +231,7 @@ bool Binary::DoUpdate()
} }
} }
char* chunk = 0; char* chunk = nullptr;
streamsize size = 0; streamsize size = 0;
while ( (size = GetChunk(&chunk)) ) while ( (size = GetChunk(&chunk)) )
{ {

View file

@ -156,7 +156,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
{ {
Error("Invalid data type for boolean - expected Integer"); Error("Invalid data type for boolean - expected Integer");
delete val; delete val;
return 0; return nullptr;
} }
int res = sqlite3_column_int(st, pos); int res = sqlite3_column_int(st, pos);
@ -167,7 +167,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
{ {
Error(Fmt("Invalid value for boolean: %d", res)); Error(Fmt("Invalid value for boolean: %d", res));
delete val; delete val;
return 0; return nullptr;
} }
break; break;
} }
@ -240,7 +240,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
default: default:
Error(Fmt("unsupported field format %d", field->type)); Error(Fmt("unsupported field format %d", field->type));
delete val; delete val;
return 0; return nullptr;
} }
return val; return val;
@ -279,7 +279,7 @@ bool SQLite::DoUpdate()
mapping[j] = i; mapping[j] = i;
} }
if ( fields[j]->secondary_name != 0 && strcmp(fields[j]->secondary_name, name) == 0 ) if ( fields[j]->secondary_name != nullptr && strcmp(fields[j]->secondary_name, name) == 0 )
{ {
assert(fields[j]->type == TYPE_PORT); assert(fields[j]->type == TYPE_PORT);
if ( submapping[j] != -1 ) if ( submapping[j] != -1 )
@ -314,7 +314,7 @@ bool SQLite::DoUpdate()
for ( unsigned int j = 0; j < num_fields; ++j) for ( unsigned int j = 0; j < num_fields; ++j)
{ {
ofields[j] = EntryToVal(st, fields[j], mapping[j], submapping[j]); ofields[j] = EntryToVal(st, fields[j], mapping[j], submapping[j]);
if ( ofields[j] == 0 ) if ( ! ofields[j] )
{ {
for ( unsigned int k = 0; k < j; ++k ) for ( unsigned int k = 0; k < j; ++k )
delete ofields[k]; delete ofields[k];

View file

@ -143,7 +143,7 @@ bool BPF_Program::Compile(int snaplen, int linktype, const char* filter,
bpf_program* BPF_Program::GetProgram() bpf_program* BPF_Program::GetProgram()
{ {
return m_compiled ? &m_program : 0; return m_compiled ? &m_program : nullptr;
} }
void BPF_Program::FreeCode() void BPF_Program::FreeCode()

View file

@ -22,14 +22,14 @@ public:
// Parameters are like in pcap_compile(). Returns true // Parameters are like in pcap_compile(). Returns true
// for successful compilation, false otherwise. // for successful compilation, false otherwise.
bool Compile(pcap_t* pcap, const char* filter, uint32_t netmask, bool Compile(pcap_t* pcap, const char* filter, uint32_t netmask,
char* errbuf = 0, unsigned int errbuf_len = 0, char* errbuf = nullptr, unsigned int errbuf_len = 0,
bool optimize = true); bool optimize = true);
// Creates a BPF program when no pcap handle is around, // Creates a BPF program when no pcap handle is around,
// similarly to pcap_compile_nopcap(). Parameters are // similarly to pcap_compile_nopcap(). Parameters are
// similar. Returns true on success. // similar. Returns true on success.
bool Compile(int snaplen, int linktype, const char* filter, bool Compile(int snaplen, int linktype, const char* filter,
uint32_t netmask, char* errbuf = 0, unsigned int errbuf_len = 0, uint32_t netmask, char* errbuf = nullptr, unsigned int errbuf_len = 0,
bool optimize = true); bool optimize = true);
// Returns true if this program currently contains compiled // Returns true if this program currently contains compiled

View file

@ -330,7 +330,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live)
// Find the component providing packet sources of the requested prefix. // Find the component providing packet sources of the requested prefix.
PktSrcComponent* component = 0; PktSrcComponent* component = nullptr;
std::list<PktSrcComponent*> all_components = plugin_mgr->Components<PktSrcComponent>(); std::list<PktSrcComponent*> all_components = plugin_mgr->Components<PktSrcComponent>();
for ( const auto& c : all_components ) for ( const auto& c : all_components )
@ -372,7 +372,7 @@ PktDumper* Manager::OpenPktDumper(const string& path, bool append)
// Find the component providing packet dumpers of the requested prefix. // Find the component providing packet dumpers of the requested prefix.
PktDumperComponent* component = 0; PktDumperComponent* component = nullptr;
std::list<PktDumperComponent*> all_components = plugin_mgr->Components<PktDumperComponent>(); std::list<PktDumperComponent*> all_components = plugin_mgr->Components<PktDumperComponent>();
for ( const auto& c : all_components ) for ( const auto& c : all_components )

View file

@ -59,7 +59,7 @@ public:
Packet(int link_type, pkt_timeval *ts, uint32_t caplen, Packet(int link_type, pkt_timeval *ts, uint32_t caplen,
uint32_t len, const u_char *data, bool copy = false, uint32_t len, const u_char *data, bool copy = false,
std::string tag = std::string("")) std::string tag = std::string(""))
: data(0), l2_src(0), l2_dst(0) : data(nullptr), l2_src(nullptr), l2_dst(nullptr)
{ {
Init(link_type, ts, caplen, len, data, copy, tag); Init(link_type, ts, caplen, len, data, copy, tag);
} }
@ -67,10 +67,10 @@ public:
/** /**
* Default constructor. For internal use only. * Default constructor. For internal use only.
*/ */
Packet() : data(0), l2_src(0), l2_dst(0) Packet() : data(nullptr), l2_src(nullptr), l2_dst(nullptr)
{ {
pkt_timeval ts = {0, 0}; pkt_timeval ts = {0, 0};
Init(0, &ts, 0, 0, 0); Init(0, &ts, 0, 0, nullptr);
} }
/** /**

View file

@ -45,12 +45,12 @@ double PktDumper::OpenTime() const
bool PktDumper::IsError() const bool PktDumper::IsError() const
{ {
return errmsg.size(); return ! errmsg.empty();
} }
const char* PktDumper::ErrorMsg() const const char* PktDumper::ErrorMsg() const
{ {
return errmsg.size() ? errmsg.c_str() : 0; return errmsg.size() ? errmsg.c_str() : nullptr;
} }
int PktDumper::HdrSize() const int PktDumper::HdrSize() const

View file

@ -51,7 +51,7 @@ const std::string& PktSrc::Path() const
const char* PktSrc::ErrorMsg() const const char* PktSrc::ErrorMsg() const
{ {
return errbuf.size() ? errbuf.c_str() : 0; return errbuf.size() ? errbuf.c_str() : nullptr;
} }
int PktSrc::LinkType() const int PktSrc::LinkType() const
@ -66,7 +66,7 @@ uint32_t PktSrc::Netmask() const
bool PktSrc::IsError() const bool PktSrc::IsError() const
{ {
return ErrorMsg(); return ! errbuf.empty();
} }
bool PktSrc::IsLive() const bool PktSrc::IsLive() const
@ -153,7 +153,7 @@ void PktSrc::Info(const std::string& msg)
void PktSrc::Weird(const std::string& msg, const Packet* p) void PktSrc::Weird(const std::string& msg, const Packet* p)
{ {
sessions->Weird(msg.c_str(), p, 0); sessions->Weird(msg.c_str(), p, nullptr);
} }
void PktSrc::InternalError(const std::string& msg) void PktSrc::InternalError(const std::string& msg)
@ -299,9 +299,9 @@ bool PktSrc::PrecompileBPFFilter(int index, const std::string& filter)
BPF_Program* PktSrc::GetBPFFilter(int index) BPF_Program* PktSrc::GetBPFFilter(int index)
{ {
if ( index < 0 ) if ( index < 0 )
return 0; return nullptr;
return (static_cast<int>(filters.size()) > index ? filters[index] : 0); return (static_cast<int>(filters.size()) > index ? filters[index] : nullptr);
} }
bool PktSrc::ApplyBPFFilter(int index, const struct pcap_pkthdr *hdr, const u_char *pkt) bool PktSrc::ApplyBPFFilter(int index, const struct pcap_pkthdr *hdr, const u_char *pkt)

View file

@ -15,8 +15,8 @@ PcapDumper::PcapDumper(const std::string& path, bool arg_append)
{ {
append = arg_append; append = arg_append;
props.path = path; props.path = path;
dumper = 0; dumper = nullptr;
pd = 0; pd = nullptr;
} }
PcapDumper::~PcapDumper() PcapDumper::~PcapDumper()
@ -93,8 +93,8 @@ void PcapDumper::Close()
pcap_dump_close(dumper); pcap_dump_close(dumper);
pcap_close(pd); pcap_close(pd);
dumper = 0; dumper = nullptr;
pd = 0; pd = nullptr;
Closed(); Closed();
} }

View file

@ -33,7 +33,7 @@ protected:
private: private:
void OpenLive(); void OpenLive();
void OpenOffline(); void OpenOffline();
void PcapError(const char* where = 0); void PcapError(const char* where = nullptr);
Properties props; Properties props;
Stats stats; Stats stats;

View file

@ -147,7 +147,7 @@ WriterBackend* Manager::CreateBackend(WriterFrontend* frontend, EnumVal* tag)
if ( ! c ) if ( ! c )
{ {
reporter->Error("unknown writer type requested"); reporter->Error("unknown writer type requested");
return 0; return nullptr;
} }
WriterBackend* backend = (*c->Factory())(frontend); WriterBackend* backend = (*c->Factory())(frontend);
@ -161,7 +161,7 @@ Manager::Stream* Manager::FindStream(EnumVal* id)
unsigned int idx = id->AsEnum(); unsigned int idx = id->AsEnum();
if ( idx >= streams.size() || ! streams[idx] ) if ( idx >= streams.size() || ! streams[idx] )
return 0; return nullptr;
return streams[idx]; return streams[idx];
} }
@ -182,7 +182,7 @@ Manager::WriterInfo* Manager::FindWriter(WriterFrontend* writer)
} }
} }
return 0; return nullptr;
} }
bool Manager::CompareFields(const Filter* filter, const WriterFrontend* writer) bool Manager::CompareFields(const Filter* filter, const WriterFrontend* writer)
@ -264,7 +264,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
} }
auto event_val = sval->Lookup("ev"); auto event_val = sval->Lookup("ev");
Func* event = event_val ? event_val->AsFunc() : 0; Func* event = event_val ? event_val->AsFunc() : nullptr;
if ( event ) if ( event )
{ {
@ -298,7 +298,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
unsigned int idx = id->AsEnum(); unsigned int idx = id->AsEnum();
while ( idx >= streams.size() ) while ( idx >= streams.size() )
streams.push_back(0); streams.push_back(nullptr);
if ( streams[idx] ) if ( streams[idx] )
// We already know this one, delete the previous definition. // We already know this one, delete the previous definition.
@ -309,7 +309,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
streams[idx]->id = id->Ref()->AsEnumVal(); streams[idx]->id = id->Ref()->AsEnumVal();
streams[idx]->enabled = true; streams[idx]->enabled = true;
streams[idx]->name = id->Type()->AsEnumType()->Lookup(idx); streams[idx]->name = id->Type()->AsEnumType()->Lookup(idx);
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : 0; streams[idx]->event = event ? event_registry->Lookup(event->Name()) : nullptr;
streams[idx]->columns = columns->Ref()->AsRecordType(); streams[idx]->columns = columns->Ref()->AsRecordType();
streams[idx]->enable_remote = internal_val("Log::enable_remote_logging")->AsBool(); streams[idx]->enable_remote = internal_val("Log::enable_remote_logging")->AsBool();
@ -347,7 +347,7 @@ bool Manager::RemoveStream(EnumVal* id)
stream->writers.clear(); stream->writers.clear();
string sname(stream->name); string sname(stream->name);
delete stream; delete stream;
streams[idx] = 0; streams[idx] = nullptr;
DBG_LOG(DBG_LOGGING, "Removed logging stream '%s'", sname.c_str()); DBG_LOG(DBG_LOGGING, "Removed logging stream '%s'", sname.c_str());
return true; return true;
@ -523,7 +523,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
bool optional = rtype->FieldDecl(i)->FindAttr(ATTR_OPTIONAL); bool optional = rtype->FieldDecl(i)->FindAttr(ATTR_OPTIONAL);
filter->fields[filter->num_fields - 1] = new threading::Field(new_path.c_str(), 0, t->Tag(), st, optional); filter->fields[filter->num_fields - 1] = new threading::Field(new_path.c_str(), nullptr, t->Tag(), st, optional);
} }
return true; return true;
@ -565,18 +565,18 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
filter->fval = fval->Ref(); filter->fval = fval->Ref();
filter->name = name->AsString()->CheckString(); filter->name = name->AsString()->CheckString();
filter->id = id->Ref()->AsEnumVal(); filter->id = id->Ref()->AsEnumVal();
filter->pred = pred ? pred->AsFunc() : 0; filter->pred = pred ? pred->AsFunc() : nullptr;
filter->path_func = path_func ? path_func->AsFunc() : 0; filter->path_func = path_func ? path_func->AsFunc() : nullptr;
filter->writer = writer->Ref()->AsEnumVal(); filter->writer = writer->Ref()->AsEnumVal();
filter->local = log_local->AsBool(); filter->local = log_local->AsBool();
filter->remote = log_remote->AsBool(); filter->remote = log_remote->AsBool();
filter->interval = interv->AsInterval(); filter->interval = interv->AsInterval();
filter->postprocessor = postprocessor ? postprocessor->AsFunc() : 0; filter->postprocessor = postprocessor ? postprocessor->AsFunc() : nullptr;
filter->config = config->Ref()->AsTableVal(); filter->config = config->Ref()->AsTableVal();
filter->field_name_map = field_name_map->Ref()->AsTableVal(); filter->field_name_map = field_name_map->Ref()->AsTableVal();
filter->scope_sep = scope_sep->AsString()->CheckString(); filter->scope_sep = scope_sep->AsString()->CheckString();
filter->ext_prefix = ext_prefix->AsString()->CheckString(); filter->ext_prefix = ext_prefix->AsString()->CheckString();
filter->ext_func = ext_func ? ext_func->AsFunc() : 0; filter->ext_func = ext_func ? ext_func->AsFunc() : nullptr;
// Build the list of fields that the filter wants included, including // Build the list of fields that the filter wants included, including
// potentially rolling out fields. // potentially rolling out fields.
@ -604,7 +604,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
} }
filter->num_fields = 0; filter->num_fields = 0;
filter->fields = 0; filter->fields = nullptr;
if ( ! TraverseRecord(stream, filter, stream->columns, if ( ! TraverseRecord(stream, filter, stream->columns,
include ? include->AsTableVal() : nullptr, include ? include->AsTableVal() : nullptr,
exclude ? exclude->AsTableVal() : nullptr, exclude ? exclude->AsTableVal() : nullptr,
@ -627,7 +627,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
{ {
// If no path is given, it's derived based upon the value returned by // If no path is given, it's derived based upon the value returned by
// the first call to the filter's path_func (during first write). // the first call to the filter's path_func (during first write).
filter->path_val = 0; filter->path_val = nullptr;
} }
// Remove any filter with the same name we might already have. // Remove any filter with the same name we might already have.
@ -811,8 +811,8 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
path = filter->path = filter->path_val->AsString()->CheckString(); path = filter->path = filter->path_val->AsString()->CheckString();
} }
WriterBackend::WriterInfo* info = 0; WriterBackend::WriterInfo* info = nullptr;
WriterFrontend* writer = 0; WriterFrontend* writer = nullptr;
if ( w != stream->writers.end() ) if ( w != stream->writers.end() )
{ {
@ -1125,7 +1125,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
int num_fields, const threading::Field* const* fields, bool local, bool remote, bool from_remote, int num_fields, const threading::Field* const* fields, bool local, bool remote, bool from_remote,
const string& instantiating_filter) const string& instantiating_filter)
{ {
WriterFrontend* result = 0; WriterFrontend* result = nullptr;
Stream* stream = FindStream(id); Stream* stream = FindStream(id);
@ -1133,7 +1133,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
{ {
// Don't know this stream. // Don't know this stream.
delete_info_and_fields(info, num_fields, fields); delete_info_and_fields(info, num_fields, fields);
return 0; return nullptr;
} }
Stream::WriterMap::iterator w = Stream::WriterMap::iterator w =
@ -1149,11 +1149,11 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
WriterInfo* winfo = new WriterInfo; WriterInfo* winfo = new WriterInfo;
winfo->type = writer->Ref()->AsEnumVal(); winfo->type = writer->Ref()->AsEnumVal();
winfo->writer = 0; winfo->writer = nullptr;
winfo->open_time = network_time; winfo->open_time = network_time;
winfo->rotation_timer = 0; winfo->rotation_timer = nullptr;
winfo->interval = 0; winfo->interval = 0;
winfo->postprocessor = 0; winfo->postprocessor = nullptr;
winfo->info = info; winfo->info = info;
winfo->from_remote = from_remote; winfo->from_remote = from_remote;
winfo->hook_initialized = false; winfo->hook_initialized = false;
@ -1194,7 +1194,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
// Still need to set the WriterInfo's rotation parameters, which we // Still need to set the WriterInfo's rotation parameters, which we
// computed above. // computed above.
const char* base_time = log_rotate_base_time ? const char* base_time = log_rotate_base_time ?
log_rotate_base_time->AsString()->CheckString() : 0; log_rotate_base_time->AsString()->CheckString() : nullptr;
winfo->info->rotation_interval = winfo->interval; winfo->info->rotation_interval = winfo->interval;
winfo->info->rotation_base = parse_rotate_base_time(base_time); winfo->info->rotation_base = parse_rotate_base_time(base_time);
@ -1411,12 +1411,12 @@ protected:
RotationTimer::~RotationTimer() RotationTimer::~RotationTimer()
{ {
if ( winfo->rotation_timer == this ) if ( winfo->rotation_timer == this )
winfo->rotation_timer = 0; winfo->rotation_timer = nullptr;
} }
void RotationTimer::Dispatch(double t, bool is_expire) void RotationTimer::Dispatch(double t, bool is_expire)
{ {
winfo->rotation_timer = 0; winfo->rotation_timer = nullptr;
if ( rotate ) if ( rotate )
log_mgr->Rotate(winfo); log_mgr->Rotate(winfo);
@ -1436,7 +1436,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
if ( winfo->rotation_timer ) if ( winfo->rotation_timer )
{ {
timer_mgr->Cancel(winfo->rotation_timer); timer_mgr->Cancel(winfo->rotation_timer);
winfo->rotation_timer = 0; winfo->rotation_timer = nullptr;
} }
double rotation_interval = winfo->interval; double rotation_interval = winfo->interval;
@ -1454,7 +1454,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
winfo->open_time = network_time; winfo->open_time = network_time;
const char* base_time = log_rotate_base_time ? const char* base_time = log_rotate_base_time ?
log_rotate_base_time->AsString()->CheckString() : 0; log_rotate_base_time->AsString()->CheckString() : nullptr;
double base = parse_rotate_base_time(base_time); double base = parse_rotate_base_time(base_time);
double delta_t = double delta_t =

View file

@ -261,7 +261,7 @@ private:
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter, threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
RecordVal* columns); RecordVal* columns);
threading::Value* ValToLogVal(Val* val, BroType* ty = 0); threading::Value* ValToLogVal(Val* val, BroType* ty = nullptr);
Stream* FindStream(EnumVal* id); Stream* FindStream(EnumVal* id);
void RemoveDisabledWriters(Stream* stream); void RemoveDisabledWriters(Stream* stream);
void InstallRotationTimer(WriterInfo* winfo); void InstallRotationTimer(WriterInfo* winfo);

View file

@ -121,7 +121,7 @@ bool WriterBackend::WriterInfo::FromBroker(broker::data d)
WriterBackend::WriterBackend(WriterFrontend* arg_frontend) : MsgThread() WriterBackend::WriterBackend(WriterFrontend* arg_frontend) : MsgThread()
{ {
num_fields = 0; num_fields = 0;
fields = 0; fields = nullptr;
buffering = true; buffering = true;
frontend = arg_frontend; frontend = arg_frontend;
info = new WriterInfo(frontend->Info()); info = new WriterInfo(frontend->Info());
@ -168,7 +168,7 @@ bool WriterBackend::FinishedRotation(const char* new_name, const char* old_name,
bool WriterBackend::FinishedRotation() bool WriterBackend::FinishedRotation()
{ {
--rotation_counter; --rotation_counter;
SendOut(new RotationFinishedMessage(frontend, 0, 0, 0, 0, false, false)); SendOut(new RotationFinishedMessage(frontend, nullptr, nullptr, 0, 0, false, false));
return true; return true;
} }

View file

@ -82,14 +82,14 @@ public:
*/ */
config_map config; config_map config;
WriterInfo() : path(0), rotation_interval(0.0), rotation_base(0.0), WriterInfo() : path(nullptr), rotation_interval(0.0), rotation_base(0.0),
network_time(0.0) network_time(0.0)
{ {
} }
WriterInfo(const WriterInfo& other) WriterInfo(const WriterInfo& other)
{ {
path = other.path ? copy_string(other.path) : 0; path = other.path ? copy_string(other.path) : nullptr;
rotation_interval = other.rotation_interval; rotation_interval = other.rotation_interval;
rotation_base = other.rotation_base; rotation_base = other.rotation_base;
network_time = other.network_time; network_time = other.network_time;

View file

@ -109,12 +109,12 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
buf = true; buf = true;
local = arg_local; local = arg_local;
remote = arg_remote; remote = arg_remote;
write_buffer = 0; write_buffer = nullptr;
write_buffer_pos = 0; write_buffer_pos = 0;
info = new WriterBackend::WriterInfo(arg_info); info = new WriterBackend::WriterInfo(arg_info);
num_fields = 0; num_fields = 0;
fields = 0; fields = nullptr;
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt()); const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
name = copy_string(fmt("%s/%s", arg_info.path, w)); name = copy_string(fmt("%s/%s", arg_info.path, w));
@ -128,7 +128,7 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
} }
else else
backend = 0; backend = nullptr;
} }
WriterFrontend::~WriterFrontend() WriterFrontend::~WriterFrontend()
@ -152,7 +152,7 @@ void WriterFrontend::Stop()
if ( backend ) if ( backend )
{ {
backend->SignalStop(); backend->SignalStop();
backend = 0; // Thread manager will clean it up once it finishes. backend = nullptr; // Thread manager will clean it up once it finishes.
} }
} }
@ -245,7 +245,7 @@ void WriterFrontend::FlushWriteBuffer()
backend->SendIn(new WriteMessage(backend, num_fields, write_buffer_pos, write_buffer)); backend->SendIn(new WriteMessage(backend, num_fields, write_buffer_pos, write_buffer));
// Clear buffer (no delete, we pass ownership to child thread.) // Clear buffer (no delete, we pass ownership to child thread.)
write_buffer = 0; write_buffer = nullptr;
write_buffer_pos = 0; write_buffer_pos = 0;
} }
@ -286,7 +286,7 @@ void WriterFrontend::Rotate(const char* rotated_path, double open, double close,
backend->SendIn(new RotateMessage(backend, this, rotated_path, open, close, terminating)); backend->SendIn(new RotateMessage(backend, this, rotated_path, open, close, terminating));
else else
// Still signal log manager that we're done. // Still signal log manager that we're done.
log_mgr->FinishedRotation(this, 0, 0, 0, 0, false, terminating); log_mgr->FinishedRotation(this, nullptr, nullptr, 0, 0, false, terminating);
} }
void WriterFrontend::DeleteVals(int num_fields, Value** vals) void WriterFrontend::DeleteVals(int num_fields, Value** vals)

View file

@ -24,7 +24,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
tsv = false; tsv = false;
use_json = false; use_json = false;
enable_utf_8 = false; enable_utf_8 = false;
formatter = 0; formatter = nullptr;
gzip_level = 0; gzip_level = 0;
gzfile = nullptr; gzfile = nullptr;
@ -179,7 +179,7 @@ bool Ascii::InitFilterOptions()
bool Ascii::InitFormatter() bool Ascii::InitFormatter()
{ {
delete formatter; delete formatter;
formatter = 0; formatter = nullptr;
if ( use_json ) if ( use_json )
{ {

View file

@ -22,7 +22,7 @@ BasicThread::BasicThread()
buf_len = STD_FMT_BUF_LEN; buf_len = STD_FMT_BUF_LEN;
buf = (char*) safe_malloc(buf_len); buf = (char*) safe_malloc(buf_len);
strerr_buffer = 0; strerr_buffer = nullptr;
name = copy_string(fmt("thread-%" PRIu64, ++thread_counter)); name = copy_string(fmt("thread-%" PRIu64, ++thread_counter));
@ -191,5 +191,5 @@ void* BasicThread::launcher(void *arg)
thread->Done(); thread->Done();
return 0; return nullptr;
} }

View file

@ -172,7 +172,7 @@ bool ReporterMessage::Process()
return true; return true;
} }
MsgThread::MsgThread() : BasicThread(), queue_in(this, 0), queue_out(0, this) MsgThread::MsgThread() : BasicThread(), queue_in(this, nullptr), queue_out(nullptr, this)
{ {
cnt_sent_in = cnt_sent_out = 0; cnt_sent_in = cnt_sent_out = 0;
main_finished = false; main_finished = false;
@ -367,7 +367,7 @@ BasicOutputMessage* MsgThread::RetrieveOut()
{ {
BasicOutputMessage* msg = queue_out.Get(); BasicOutputMessage* msg = queue_out.Get();
if ( ! msg ) if ( ! msg )
return 0; return nullptr;
DBG_LOG(DBG_THREADING, "Retrieved '%s' from %s", msg->Name(), Name()); DBG_LOG(DBG_THREADING, "Retrieved '%s' from %s", msg->Name(), Name());
@ -379,7 +379,7 @@ BasicInputMessage* MsgThread::RetrieveIn()
BasicInputMessage* msg = queue_in.Get(); BasicInputMessage* msg = queue_in.Get();
if ( ! msg ) if ( ! msg )
return 0; return nullptr;
#ifdef DEBUG #ifdef DEBUG
string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name()); string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name());

View file

@ -26,7 +26,7 @@ bool Field::Read(SerializationFormat* fmt)
secondary_name = copy_string(tmp_secondary_name.c_str()); secondary_name = copy_string(tmp_secondary_name.c_str());
} }
else else
secondary_name = 0; secondary_name = nullptr;
bool success = (fmt->Read(&tmp_name, "name") bool success = (fmt->Read(&tmp_name, "name")
&& fmt->Read(&t, "type") && fmt->Read(&t, "type")

View file

@ -31,16 +31,16 @@ struct Field {
* Constructor. * Constructor.
*/ */
Field(const char* name, const char* secondary_name, TypeTag type, TypeTag subtype, bool optional) Field(const char* name, const char* secondary_name, TypeTag type, TypeTag subtype, bool optional)
: name(name ? copy_string(name) : 0), : name(name ? copy_string(name) : nullptr),
secondary_name(secondary_name ? copy_string(secondary_name) : 0), secondary_name(secondary_name ? copy_string(secondary_name) : nullptr),
type(type), subtype(subtype), optional(optional) { } type(type), subtype(subtype), optional(optional) { }
/** /**
* Copy constructor. * Copy constructor.
*/ */
Field(const Field& other) Field(const Field& other)
: name(other.name ? copy_string(other.name) : 0), : name(other.name ? copy_string(other.name) : nullptr),
secondary_name(other.secondary_name ? copy_string(other.secondary_name) : 0), secondary_name(other.secondary_name ? copy_string(other.secondary_name) : nullptr),
type(other.type), subtype(other.subtype), optional(other.optional) { } type(other.type), subtype(other.subtype), optional(other.optional) { }
~Field() ~Field()

View file

@ -214,7 +214,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
threading::Value* val = new threading::Value(type, subtype, true); threading::Value* val = new threading::Value(type, subtype, true);
const char* start = s.c_str(); const char* start = s.c_str();
char* end = 0; char* end = nullptr;
errno = 0; errno = 0;
size_t pos; size_t pos;
@ -411,7 +411,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
} }
threading::Value* newval = ParseValue(element, name, subtype); threading::Value* newval = ParseValue(element, name, subtype);
if ( newval == 0 ) if ( newval == nullptr )
{ {
GetThread()->Warning("Error while reading set or vector"); GetThread()->Warning("Error while reading set or vector");
error = true; error = true;
@ -429,7 +429,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
if ( ! error && (s.empty() || *s.rbegin() == separators.set_separator[0]) ) if ( ! error && (s.empty() || *s.rbegin() == separators.set_separator[0]) )
{ {
lvals[pos] = ParseValue("", name, subtype); lvals[pos] = ParseValue("", name, subtype);
if ( lvals[pos] == 0 ) if ( lvals[pos] == nullptr )
{ {
GetThread()->Warning("Error while trying to add empty set element"); GetThread()->Warning("Error while trying to add empty set element");
goto parse_error; goto parse_error;
@ -470,7 +470,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
parse_error: parse_error:
delete val; delete val;
return 0; return nullptr;
} }
bool Ascii::CheckNumberError(const char* start, const char* end) const bool Ascii::CheckNumberError(const char* start, const char* end) const