Merge remote-tracking branch 'origin/topic/jsiwek/superfluous-nullptr-checks'

* origin/topic/jsiwek/superfluous-nullptr-checks:
  Remove superfluous nullptr checks in Val/RecordVal methods
This commit is contained in:
Tim Wojtulewicz 2021-01-18 19:14:30 -07:00
commit 5bc9c818ad
3 changed files with 5 additions and 13 deletions

View file

@ -1,3 +1,6 @@
4.1.0-dev.118 | 2021-01-18 19:14:30 -0700
* Remove superfluous nullptr checks in Val/RecordVal methods (Jon Siwek, Corelight)
4.1.0-dev.116 | 2021-01-14 19:29:58 -0800

View file

@ -1 +1 @@
4.1.0-dev.116
4.1.0-dev.118

View file

@ -213,12 +213,7 @@ UNDERLYING_ACCESSOR_DECL(TypeVal, zeek::Type*, AsType)
{
// Since we're converting from "this", make sure the type requested is a pointer.
static_assert(std::is_pointer<T>());
auto v = static_cast<T>(this);
if ( ! v )
reporter->InternalError("Failed dynamic_cast between Val types");
return v;
return static_cast<T>(this);
}
protected:
@ -1262,9 +1257,6 @@ public:
{
auto& field_ptr = GetField(field);
auto field_val_ptr = static_cast<T*>(field_ptr.get());
if ( ! field_val_ptr )
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
return field_val_ptr->Get();
}
@ -1273,9 +1265,6 @@ public:
{
auto& field_ptr = GetField(field);
auto field_val_ptr = static_cast<T*>(field_ptr.get());
if ( ! field_val_ptr )
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
return field_val_ptr->Get();
}