migrate to using RecordVal's new Remove() method

This commit is contained in:
Vern Paxson 2021-02-25 15:28:37 -08:00
parent c757db2714
commit b6f4f897c6
5 changed files with 5 additions and 23 deletions

View file

@ -3921,7 +3921,7 @@ ValPtr RecordCoerceExpr::Fold(Val* v) const
if ( ! rhs ) if ( ! rhs )
{ {
// Optional field is missing. // Optional field is missing.
val->Assign(i, nullptr); val->Remove(i);
continue; continue;
} }
@ -3968,7 +3968,7 @@ ValPtr RecordCoerceExpr::Fold(Val* v) const
val->Assign(i, std::move(def_val)); val->Assign(i, std::move(def_val));
} }
else else
val->Assign(i, nullptr); val->Remove(i);
} }
} }

View file

@ -272,11 +272,6 @@ RecordValPtr MOUNT_Interp::mount3_mnt_reply(const u_char*& buf, int& n,
rep->Assign(1, std::move(auth_flavors)); rep->Assign(1, std::move(auth_flavors));
} }
else
{
rep->Assign(0, nullptr);
rep->Assign(1, nullptr);
}
return rep; return rep;
} }

View file

@ -353,22 +353,18 @@ RecordValPtr NFS_Interp::nfs3_sattr(const u_char*& buf, int& n)
{ {
auto attrs = make_intrusive<RecordVal>(BifType::Record::NFS3::sattr_t); auto attrs = make_intrusive<RecordVal>(BifType::Record::NFS3::sattr_t);
attrs->Assign(0, nullptr); // mode
int mode_set_it = extract_XDR_uint32(buf, n); int mode_set_it = extract_XDR_uint32(buf, n);
if ( mode_set_it ) if ( mode_set_it )
attrs->Assign(0, ExtractUint32(buf, n)); // mode attrs->Assign(0, ExtractUint32(buf, n)); // mode
attrs->Assign(1, nullptr); // uid
int uid_set_it = extract_XDR_uint32(buf, n); int uid_set_it = extract_XDR_uint32(buf, n);
if ( uid_set_it ) if ( uid_set_it )
attrs->Assign(1, ExtractUint32(buf, n)); // uid attrs->Assign(1, ExtractUint32(buf, n)); // uid
attrs->Assign(2, nullptr); // gid
int gid_set_it = extract_XDR_uint32(buf, n); int gid_set_it = extract_XDR_uint32(buf, n);
if ( gid_set_it ) if ( gid_set_it )
attrs->Assign(2, ExtractUint32(buf, n)); // gid attrs->Assign(2, ExtractUint32(buf, n)); // gid
attrs->Assign(3, nullptr); // size
int size_set_it = extract_XDR_uint32(buf, n); int size_set_it = extract_XDR_uint32(buf, n);
if ( size_set_it ) if ( size_set_it )
attrs->Assign(3, ExtractTime(buf, n)); // size attrs->Assign(3, ExtractTime(buf, n)); // size
@ -389,11 +385,6 @@ RecordValPtr NFS_Interp::nfs3_sattr_reply(const u_char*& buf, int& n, BifEnum::N
rep->Assign(0, nfs3_pre_op_attr(buf, n)); rep->Assign(0, nfs3_pre_op_attr(buf, n));
rep->Assign(1, nfs3_post_op_attr(buf, n)); rep->Assign(1, nfs3_post_op_attr(buf, n));
} }
else
{
rep->Assign(1, nullptr);
rep->Assign(2, nullptr);
}
return rep; return rep;
} }
@ -536,8 +527,6 @@ RecordValPtr NFS_Interp::nfs3_lookup_reply(const u_char*& buf, int& n, BifEnum::
} }
else else
{ {
rep->Assign(0, nullptr);
rep->Assign(1, nullptr);
rep->Assign(2, nfs3_post_op_attr(buf, n)); rep->Assign(2, nfs3_post_op_attr(buf, n));
} }
return rep; return rep;
@ -698,8 +687,6 @@ RecordValPtr NFS_Interp::nfs3_newobj_reply(const u_char*& buf, int& n, BifEnum::
} }
else else
{ {
rep->Assign(0, nullptr);
rep->Assign(1, nullptr);
rep->Assign(2, nfs3_pre_op_attr(buf, n)); rep->Assign(2, nfs3_pre_op_attr(buf, n));
rep->Assign(3, nfs3_post_op_attr(buf, n)); rep->Assign(3, nfs3_post_op_attr(buf, n));
} }

View file

@ -430,7 +430,7 @@ struct val_converter {
if ( caf::get_if<broker::none>(&a[idx]) != nullptr ) if ( caf::get_if<broker::none>(&a[idx]) != nullptr )
{ {
rval->Assign(i, nullptr); rval->Remove(i);
++idx; ++idx;
continue; continue;
} }

View file

@ -793,7 +793,7 @@ RecordVal* Manager::MakeEvent(ValPList* args, zeek::detail::Frame* frame)
if ( ! same_type(got_type, expected_type) ) if ( ! same_type(got_type, expected_type) )
{ {
rval->Assign(0, nullptr); rval->Remove(0);
Error("event parameter #%d type mismatch, got %s, expect %s", i, Error("event parameter #%d type mismatch, got %s, expect %s", i,
type_name(got_type->Tag()), type_name(got_type->Tag()),
type_name(expected_type->Tag())); type_name(expected_type->Tag()));
@ -809,7 +809,7 @@ RecordVal* Manager::MakeEvent(ValPList* args, zeek::detail::Frame* frame)
if ( ! data_val->HasField(0) ) if ( ! data_val->HasField(0) )
{ {
rval->Assign(0, nullptr); rval->Remove(0);
Error("failed to convert param #%d of type %s to broker data", Error("failed to convert param #%d of type %s to broker data",
i, type_name(got_type->Tag())); i, type_name(got_type->Tag()));
return rval; return rval;