OSDN Git Service

rusty-gd: Use entire slice during packet parsing
authorQasim Javed <qasimj@google.com>
Thu, 28 Jan 2021 03:08:57 +0000 (19:08 -0800)
committerQasim Javed <qasimj@google.com>
Thu, 28 Jan 2021 03:12:15 +0000 (19:12 -0800)
The field offsets for the child packets are relative to the parent
packet so we do not need to use specify a starting offset when calling
the child packet's parse method.

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost

Change-Id: I472f3365259c653143a973c4412d685c20f62808

gd/packet/parser/packet_def.cc

index 0073db3..0bcec9e 100644 (file)
@@ -945,10 +945,10 @@ void PacketDef::GenRustStructImpls(std::ostream& s) const {
         s << name_ << "DataChild::";
         s << desc_path[0]->name_ << "(Arc::new(";
         if (desc_path[0]->parent_constraints_.empty()) {
-          s << desc_path[0]->name_ << "Data::parse(&bytes[" << payload_offset.bytes() << "..]";
+          s << desc_path[0]->name_ << "Data::parse(&bytes[..]";
           s << ", " << enum_variant << ")?))";
         } else {
-          s << desc_path[0]->name_ << "Data::parse(&bytes[" << payload_offset.bytes() << "..])?))";
+          s << desc_path[0]->name_ << "Data::parse(&bytes[..])?))";
         }
       } else if (constraint_type == ScalarField::kFieldType) {
         s << std::get<int64_t>(desc.second) << " => {";