Skip to content

Commit

Permalink
vhost-user-backend: fix clippy warnings
Browse files Browse the repository at this point in the history
New clippy version in the CI highlighted some code to improve.
This patch is generated using `clippy --fix ...`.

Fixed 2 type of warnings:
1 - error: the following explicit lifetimes could be elided: 'a
       --> vhost-user-backend/src/bitmap.rs:109:6
        |
    109 | impl<'a> WithBitmapSlice<'a> for BitmapMmapRegion {

2 - error: unnecessary closure used to substitute value for `Option::None`
       --> vhost-user-backend/src/handler.rs:356:21
        |
    356 |           let vring = self
        |  _____________________^
    357 | |             .vrings
    358 | |             .get(index as usize)
    359 | |             .ok_or_else(|| VhostUserError::InvalidParam)?;

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
  • Loading branch information
stefano-garzarella committed Dec 17, 2024
1 parent 4f33b98 commit f936944
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vhost-user-backend/src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl BitmapReplace for BitmapMmapRegion {

impl BitmapSlice for BitmapMmapRegion {}

impl<'a> WithBitmapSlice<'a> for BitmapMmapRegion {
impl WithBitmapSlice<'_> for BitmapMmapRegion {
type S = Self;
}

Expand Down
16 changes: 8 additions & 8 deletions vhost-user-backend/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

if num == 0 || num as usize > self.max_queue_size {
return Err(VhostUserError::InvalidParam);
Expand All @@ -377,7 +377,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

if !self.mappings.is_empty() {
let desc_table = self.vmm_va_to_gpa(descriptor).map_err(|e| {
Expand Down Expand Up @@ -418,7 +418,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

vring.set_queue_next_avail(base as u16);

Expand All @@ -429,7 +429,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

// Quote from vhost-user specification:
// Client must start ring upon receiving a kick (that is, detecting
Expand Down Expand Up @@ -463,7 +463,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

// SAFETY: EventFd requires that it has sole ownership of its fd. So
// does File, so this is safe.
Expand All @@ -482,7 +482,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

vring.set_call(file);

Expand All @@ -497,7 +497,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

vring.set_err(file);

Expand Down Expand Up @@ -528,7 +528,7 @@ where
let vring = self
.vrings
.get(index as usize)
.ok_or_else(|| VhostUserError::InvalidParam)?;
.ok_or(VhostUserError::InvalidParam)?;

// Backend must not pass data to/from the backend until ring is
// enabled by VHOST_USER_SET_VRING_ENABLE with parameter 1,
Expand Down

0 comments on commit f936944

Please sign in to comment.