Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07a55615 authored by Martin Geisler's avatar Martin Geisler Committed by Cherrypicker Worker
Browse files

pdl: Fix parsing of reserved fields

We did not advance correctly past the reserved field in the case where
the field is _not_ part of a chunk.

The change is reflected in the unit tests here. In addition, Henri
will add a test for this to the canonical tests.

Tag: #feature
Bug: 233340330
Test: atest --host libuwb_core_tests
(cherry picked from https://android-review.googlesource.com/q/commit:300b2896802750626233bb23014affbda2932664)
Merged-In: I8784b439976509822ecd42d217fcf10d54abde5e
Change-Id: I8784b439976509822ecd42d217fcf10d54abde5e
parent 0526d50b
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -165,9 +165,19 @@ impl<'a> FieldParser<'a> {
                    }
                }
                ast::FieldDesc::Reserved { .. } => {
                    // Nothing to do here.
                    if single_value {
                        let span = self.span;
                        let size = proc_macro2::Literal::usize_unsuffixed(size);
                        quote! {
                            #span.get_mut().advance(#size);
                        }
                    } else {
                        //  Otherwise we don't need anything: we will
                        //  have advanced past the reserved field when
                        //  reading the chunk above.
                        quote! {}
                    }
                }
                ast::FieldDesc::Size { field_id, .. } => {
                    let id = size_field_ident(field_id);
                    quote! {
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ impl FooData {
                got: bytes.get().remaining(),
            });
        }
        bytes.get_mut().advance(5);
        Ok(Self {})
    }
    fn write_to(&self, buffer: &mut BytesMut) {
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ impl FooData {
                got: bytes.get().remaining(),
            });
        }
        bytes.get_mut().advance(5);
        Ok(Self {})
    }
    fn write_to(&self, buffer: &mut BytesMut) {