Skip to content

Commit adfd39f

Browse files
jinankjainrussell-islam
authored andcommitted
clippy: Fix unaligned-format-args clippy warning
Error: --> vfio-ioctls/src/vfio_device.rs:267:21 | error!("Could not delete VFIO group: {:?}", e); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | error!("Could not delete VFIO group: {:?}", e); error!("Could not delete VFIO group: {e:?}"); Signed-off-by: Jinank Jain <[email protected]>
1 parent d1b788e commit adfd39f

File tree

4 files changed

+45
-60
lines changed

4 files changed

+45
-60
lines changed

vfio-ioctls/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ mod tests {
151151
fn test_vfio_error_fmt() {
152152
let e = VfioError::GetGroupStatus;
153153
let e2 = VfioError::OpenContainer(std::io::Error::from(std::io::ErrorKind::Other));
154-
let str = format!("{}", e);
154+
let str = format!("{e}");
155155

156156
assert_eq!(&str, "failed to get Group Status");
157157
assert!(e2.source().is_some());

vfio-ioctls/src/vfio_device.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl VfioContainer {
264264
match self.device_del_group(&group) {
265265
Ok(_) => {}
266266
Err(e) => {
267-
error!("Could not delete VFIO group: {:?}", e);
267+
error!("Could not delete VFIO group: {e:?}");
268268
return;
269269
}
270270
}
@@ -628,7 +628,7 @@ impl VfioDeviceInfo {
628628
};
629629

630630
if vfio_syscall::get_device_irq_info(self, &mut irq_info).is_err() {
631-
warn!("Could not get VFIO IRQ info for index {:}", index);
631+
warn!("Could not get VFIO IRQ info for index {index:}");
632632
continue;
633633
}
634634

@@ -638,7 +638,7 @@ impl VfioDeviceInfo {
638638
count: irq_info.count,
639639
};
640640

641-
debug!("IRQ #{}", index);
641+
debug!("IRQ #{index}");
642642
debug!("\tflag 0x{:x}", irq.flags);
643643
debug!("\tindex {}", irq.index);
644644
debug!("\tcount {}", irq.count);
@@ -780,7 +780,7 @@ impl VfioDeviceInfo {
780780
continue;
781781
}
782782
_ => {
783-
error!("Could not get region #{} info {}", i, e);
783+
error!("Could not get region #{i} info {e}");
784784
continue;
785785
}
786786
}
@@ -793,11 +793,11 @@ impl VfioDeviceInfo {
793793
caps: Vec::new(),
794794
};
795795
if let Err(e) = self.get_region_map(&mut region, &reg_info) {
796-
error!("Could not get region #{} map {}", i, e);
796+
error!("Could not get region #{i} map {e}");
797797
continue;
798798
}
799799

800-
debug!("Region #{}", i);
800+
debug!("Region #{i}");
801801
debug!("\tflag 0x{:x}", region.flags);
802802
debug!("\tsize 0x{:x}", region.size);
803803
debug!("\toffset 0x{:x}", region.offset);
@@ -1104,7 +1104,7 @@ impl VfioDevice {
11041104
match self.regions.get(index as usize) {
11051105
Some(v) => v.size,
11061106
None => {
1107-
warn!("get_region_size with invalid index: {}", index);
1107+
warn!("get_region_size with invalid index: {index}");
11081108
0
11091109
}
11101110
}
@@ -1118,7 +1118,7 @@ impl VfioDevice {
11181118
match self.regions.get(index as usize) {
11191119
Some(v) => v.caps.clone(),
11201120
None => {
1121-
warn!("get_region_caps with invalid index: {}", index);
1121+
warn!("get_region_caps with invalid index: {index}");
11221122
Vec::new()
11231123
}
11241124
}
@@ -1134,25 +1134,19 @@ impl VfioDevice {
11341134
let region: &VfioRegion = match self.regions.get(index as usize) {
11351135
Some(v) => v,
11361136
None => {
1137-
warn!("region read with invalid index: {}", index);
1137+
warn!("region read with invalid index: {index}");
11381138
return;
11391139
}
11401140
};
11411141

11421142
let size = buf.len() as u64;
11431143
if size > region.size || addr + size > region.size {
1144-
warn!(
1145-
"region read with invalid parameter, add: {}, size: {}",
1146-
addr, size
1147-
);
1144+
warn!("region read with invalid parameter, add: {addr}, size: {size}");
11481145
return;
11491146
}
11501147

11511148
if let Err(e) = self.device.read_exact_at(buf, region.offset + addr) {
1152-
warn!(
1153-
"Failed to read region in index: {}, addr: {}, error: {}",
1154-
index, addr, e
1155-
);
1149+
warn!("Failed to read region in index: {index}, addr: {addr}, error: {e}");
11561150
}
11571151
}
11581152

@@ -1166,7 +1160,7 @@ impl VfioDevice {
11661160
let stub: &VfioRegion = match self.regions.get(index as usize) {
11671161
Some(v) => v,
11681162
None => {
1169-
warn!("region write with invalid index: {}", index);
1163+
warn!("region write with invalid index: {index}");
11701164
return;
11711165
}
11721166
};
@@ -1176,18 +1170,12 @@ impl VfioDevice {
11761170
|| addr + size > stub.size
11771171
|| (stub.flags & VFIO_REGION_INFO_FLAG_WRITE) == 0
11781172
{
1179-
warn!(
1180-
"region write with invalid parameter, add: {}, size: {}",
1181-
addr, size
1182-
);
1173+
warn!("region write with invalid parameter, add: {addr}, size: {size}");
11831174
return;
11841175
}
11851176

11861177
if let Err(e) = self.device.write_all_at(buf, stub.offset + addr) {
1187-
warn!(
1188-
"Failed to write region in index: {}, addr: {}, error: {}",
1189-
index, addr, e
1190-
);
1178+
warn!("Failed to write region in index: {index}, addr: {addr}, error: {e}");
11911179
}
11921180
}
11931181

vfio-user/examples/gpio/pci.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ impl PciConfiguration {
404404
/// Writes a 32bit dword to `offset`. `offset` must be 32bit aligned.
405405
fn write_dword(&mut self, offset: usize, value: u32) {
406406
if offset % 4 != 0 {
407-
warn!("bad PCI config dword write offset {}", offset);
407+
warn!("bad PCI config dword write offset {offset}");
408408
return;
409409
}
410410
let reg_idx = offset / 4;
411411
if let Some(r) = self.registers.get_mut(reg_idx) {
412412
*r = (*r & !self.writable_bits[reg_idx]) | (value & self.writable_bits[reg_idx]);
413413
} else {
414-
warn!("bad PCI dword write {}", offset);
414+
warn!("bad PCI dword write {offset}");
415415
}
416416
}
417417

@@ -421,7 +421,7 @@ impl PciConfiguration {
421421
0 => 0,
422422
2 => 16,
423423
_ => {
424-
warn!("bad PCI config word write offset {}", offset);
424+
warn!("bad PCI config word write offset {offset}");
425425
return;
426426
}
427427
};
@@ -433,7 +433,7 @@ impl PciConfiguration {
433433
let shifted_value = (u32::from(value) << shift) & writable_mask;
434434
*r = *r & !mask | shifted_value;
435435
} else {
436-
warn!("bad PCI config word write offset {}", offset);
436+
warn!("bad PCI config word write offset {offset}");
437437
}
438438
}
439439

@@ -457,7 +457,7 @@ impl PciConfiguration {
457457
let shifted_value = (u32::from(value) << shift) & writable_mask;
458458
*r = *r & !mask | shifted_value;
459459
} else {
460-
warn!("bad PCI config byte write offset {}", offset);
460+
warn!("bad PCI config byte write offset {offset}");
461461
}
462462
}
463463

0 commit comments

Comments
 (0)