Skip to content

Commit ef7cb1f

Browse files
committed
queue: Ensure the use of Descriptor accessors
Ensure that we're using the Descriptor accessors everywhere, instead of accessing its fields directly. This is needed for the next commit, where we'll be fixing the endianess of each field on its accessor. Signed-off-by: Sergio Lopez <[email protected]>
1 parent 79f0c10 commit ef7cb1f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/virtio-queue/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl Descriptor {
138138
/// If this is false, this descriptor is read only.
139139
/// Write only means the the emulated device can write and the driver can read.
140140
pub fn is_write_only(&self) -> bool {
141-
self.flags & VIRTQ_DESC_F_WRITE != 0
141+
self.flags() & VIRTQ_DESC_F_WRITE != 0
142142
}
143143
}
144144

@@ -217,10 +217,10 @@ impl<M: GuestAddressSpace> DescriptorChain<M> {
217217
return Err(Error::InvalidIndirectDescriptor);
218218
}
219219

220-
let table_len = (desc.len as usize) / VIRTQ_DESCRIPTOR_SIZE;
220+
let table_len = (desc.len() as usize) / VIRTQ_DESCRIPTOR_SIZE;
221221
// Check the target indirect descriptor table is correctly aligned.
222222
if desc.addr().raw_value() & (VIRTQ_DESCRIPTOR_SIZE as u64 - 1) != 0
223-
|| (desc.len as usize) & (VIRTQ_DESCRIPTOR_SIZE - 1) != 0
223+
|| (desc.len() as usize) & (VIRTQ_DESCRIPTOR_SIZE - 1) != 0
224224
|| table_len > usize::from(u16::MAX)
225225
{
226226
return Err(Error::InvalidIndirectDescriptorTable);
@@ -1264,7 +1264,7 @@ mod tests {
12641264
assert!(c.is_indirect);
12651265
if i < 3 {
12661266
assert_eq!(desc.flags(), VIRTQ_DESC_F_NEXT);
1267-
assert_eq!(desc.next, i + 1);
1267+
assert_eq!(desc.next(), j + 1);
12681268
}
12691269
}
12701270
// Even though we added a new descriptor after the one that is pointing to the indirect

0 commit comments

Comments
 (0)