Skip to content

Commit 0a3950c

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 <slp@redhat.com>
1 parent df6f87c commit 0a3950c

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
@@ -137,7 +137,7 @@ impl Descriptor {
137137
/// If this is false, this descriptor is read only.
138138
/// Write only means the the emulated device can write and the driver can read.
139139
pub fn is_write_only(&self) -> bool {
140-
self.flags & VIRTQ_DESC_F_WRITE != 0
140+
self.flags() & VIRTQ_DESC_F_WRITE != 0
141141
}
142142
}
143143

@@ -220,10 +220,10 @@ where
220220
return Err(Error::InvalidIndirectDescriptor);
221221
}
222222

223-
let table_len = (desc.len as usize) / VIRTQ_DESCRIPTOR_SIZE;
223+
let table_len = (desc.len() as usize) / VIRTQ_DESCRIPTOR_SIZE;
224224
// Check the target indirect descriptor table is correctly aligned.
225225
if desc.addr().raw_value() & (VIRTQ_DESCRIPTOR_SIZE as u64 - 1) != 0
226-
|| (desc.len as usize) & (VIRTQ_DESCRIPTOR_SIZE - 1) != 0
226+
|| (desc.len() as usize) & (VIRTQ_DESCRIPTOR_SIZE - 1) != 0
227227
|| table_len > usize::from(u16::MAX)
228228
{
229229
return Err(Error::InvalidIndirectDescriptorTable);
@@ -1302,7 +1302,7 @@ mod tests {
13021302
assert!(c.is_indirect);
13031303
if i < 3 {
13041304
assert_eq!(desc.flags(), VIRTQ_DESC_F_NEXT);
1305-
assert_eq!(desc.next, i + 1);
1305+
assert_eq!(desc.next(), i + 1);
13061306
}
13071307
}
13081308
// Even though we added a new descriptor after the one that is pointing to the indirect

0 commit comments

Comments
 (0)