Skip to content

Commit 2d3147b

Browse files
authored
Merge pull request #792 from mkroening/inline-fmt
Inline format strings variables
2 parents 16edea6 + f1d183e commit 2d3147b

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

src/arch/aarch64/mm/paging.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ impl PageTableEntry {
152152
assert_eq!(
153153
physical_address % BasePageSize::SIZE,
154154
0,
155-
"Physical address is not on a 4 KiB page boundary (physical_address = {:p})",
156-
physical_address
155+
"Physical address is not on a 4 KiB page boundary (physical_address = {physical_address:p})"
157156
);
158157

159158
let mut flags_to_set = flags;
@@ -256,8 +255,7 @@ impl<S: PageSize> Page<S> {
256255
fn including_address(virtual_address: VirtAddr) -> Self {
257256
assert!(
258257
Self::is_valid_address(virtual_address),
259-
"Virtual address {:p} is invalid",
260-
virtual_address
258+
"Virtual address {virtual_address:p} is invalid"
261259
);
262260

263261
Self {

src/arch/aarch64/mm/physicalmem.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, Alloc
6767
assert_eq!(
6868
size % alignment,
6969
0,
70-
"Size {:#X} is not a multiple of the given alignment {:#X}",
71-
size,
72-
alignment
70+
"Size {size:#X} is not a multiple of the given alignment {alignment:#X}"
7371
);
7472
assert_eq!(
7573
alignment % BasePageSize::SIZE as usize,
@@ -93,8 +91,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, Alloc
9391
pub fn deallocate(physical_address: PhysAddr, size: usize) {
9492
assert!(
9593
physical_address >= PhysAddr(mm::kernel_end_address().as_u64()),
96-
"Physical address {:p} is not >= KERNEL_END_ADDRESS",
97-
physical_address
94+
"Physical address {physical_address:p} is not >= KERNEL_END_ADDRESS"
9895
);
9996
assert!(size > 0);
10097
assert_eq!(

src/arch/aarch64/mm/virtualmem.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, Alloc
5757
assert_eq!(
5858
size % alignment,
5959
0,
60-
"Size {:#X} is not a multiple of the given alignment {:#X}",
61-
size,
62-
alignment
60+
"Size {size:#X} is not a multiple of the given alignment {alignment:#X}"
6361
);
6462
assert_eq!(
6563
alignment % BasePageSize::SIZE as usize,
@@ -81,13 +79,11 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, Alloc
8179
pub fn deallocate(virtual_address: VirtAddr, size: usize) {
8280
assert!(
8381
virtual_address >= mm::kernel_end_address() || virtual_address < mm::kernel_start_address(),
84-
"Virtual address {:p} belongs to the kernel",
85-
virtual_address
82+
"Virtual address {virtual_address:p} belongs to the kernel"
8683
);
8784
assert!(
8885
virtual_address < KERNEL_VIRTUAL_MEMORY_END,
89-
"Virtual address {:p} is not < KERNEL_VIRTUAL_MEMORY_END",
90-
virtual_address
86+
"Virtual address {virtual_address:p} is not < KERNEL_VIRTUAL_MEMORY_END"
9187
);
9288
assert_eq!(
9389
virtual_address % BasePageSize::SIZE,

src/drivers/pci.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<T: ConfigRegionAccess> fmt::Display for PciDevice<T> {
397397
// If the devices uses an IRQ, output this one as well.
398398
let (_, irq) = endpoint.interrupt(&self.access);
399399
if irq != 0 && irq != u8::MAX {
400-
write!(f, ", IRQ {}", irq)?;
400+
write!(f, ", IRQ {irq}")?;
401401
}
402402

403403
let mut slot: u8 = 0;
@@ -409,18 +409,18 @@ impl<T: ConfigRegionAccess> fmt::Display for PciDevice<T> {
409409
size,
410410
prefetchable,
411411
} => {
412-
write!(f, ", BAR{} Memory64 {{ address: {:#X}, size: {:#X}, prefetchable: {} }}", slot, address, size, prefetchable)?;
412+
write!(f, ", BAR{slot} Memory64 {{ address: {address:#X}, size: {size:#X}, prefetchable: {prefetchable} }}")?;
413413
slot += 1;
414414
}
415415
Bar::Memory32 {
416416
address,
417417
size,
418418
prefetchable,
419419
} => {
420-
write!(f, ", BAR{} Memory32 {{ address: {:#X}, size: {:#X}, prefetchable: {} }}", slot, address, size, prefetchable)?;
420+
write!(f, ", BAR{slot} Memory32 {{ address: {address:#X}, size: {size:#X}, prefetchable: {prefetchable} }}")?;
421421
}
422422
Bar::Io { port } => {
423-
write!(f, ", BAR{} IO {{ port: {:#X} }}", slot, port)?;
423+
write!(f, ", BAR{slot} IO {{ port: {port:#X} }}")?;
424424
}
425425
}
426426
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
#![warn(rust_2018_idioms)]
66
#![warn(unsafe_op_in_unsafe_fn)]
7+
#![warn(clippy::uninlined_format_args)]
78
#![warn(clippy::transmute_ptr_to_ptr)]
89
#![allow(clippy::missing_safety_doc)]
910
#![cfg_attr(target_arch = "aarch64", allow(incomplete_features))]

0 commit comments

Comments
 (0)