Skip to content

Commit 1dea869

Browse files
authored
various new 1.85 clippy lints (#864)
the packed structs almost certainly should be repr(C) (why does that default to repr(Rust)???) the indentation change is unfortunate and doc_overindented_list_items hasn't really convinced me that this *would* introduce broken spacing in rendered docs, but i don't have it in me to allow the lint for a few lines like this.
1 parent 98d0823 commit 1dea869

File tree

10 files changed

+33
-36
lines changed

10 files changed

+33
-36
lines changed

bin/propolis-server/src/lib/initializer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl MachineInitializer<'_> {
10201020
.map(|ident| {
10211021
match ident.eax & 0xf00 {
10221022
// If family ID is 0xf, extended family is added to it
1023-
0xf00 => (ident.eax >> 20 & 0xff) + 0xf,
1023+
0xf00 => ((ident.eax >> 20) & 0xff) + 0xf,
10241024
// ... otherwise base family ID is used
10251025
base => base >> 8,
10261026
}
@@ -1048,7 +1048,7 @@ impl MachineInitializer<'_> {
10481048
};
10491049

10501050
let proc_id = cpuid_ident
1051-
.map(|id| u64::from(id.eax) | u64::from(id.edx) << 32)
1051+
.map(|id| u64::from(id.eax) | (u64::from(id.edx) << 32))
10521052
.unwrap_or(0);
10531053

10541054
let proc_version = cpuid_procname

bin/propolis-server/src/lib/stats/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ impl Producer for ServerStats {
134134
///
135135
/// - `id`: The ID of the instance for whom this server is being started.
136136
/// - `config`: The metrics config options, including our address (on which we
137-
/// serve metrics for oximeter to collect), and the registration address (a
138-
/// Nexus instance through which we request registration as an oximeter
139-
/// producer).
137+
/// serve metrics for oximeter to collect), and the registration address (a
138+
/// Nexus instance through which we request registration as an oximeter
139+
/// producer).
140140
/// - `log`: A logger to use when logging from this routine.
141141
/// - `registry`: The oximeter [`ProducerRegistry`] that the spawned server will
142-
/// use to return metric data to oximeter on request.
142+
/// use to return metric data to oximeter on request.
143143
///
144144
/// The returned server will attempt to register with Nexus in a background
145145
/// task, and will periodically renew that registration. The returned server is

bin/propolis-standalone/src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ fn generate_smbios(params: SmbiosParams) -> anyhow::Result<smbios::TableBytes> {
875875
.unwrap_or_else(|| cpuid_utils::host::query(CpuidIdent::leaf(1)));
876876
let family = match cpuid_ident.eax & 0xf00 {
877877
// If family ID is 0xf, extended family is added to it
878-
0xf00 => (cpuid_ident.eax >> 20 & 0xff) + 0xf,
878+
0xf00 => ((cpuid_ident.eax >> 20) & 0xff) + 0xf,
879879
// ... otherwise base family ID is used
880880
base => base >> 8,
881881
};
@@ -894,7 +894,8 @@ fn generate_smbios(params: SmbiosParams) -> anyhow::Result<smbios::TableBytes> {
894894
//unknown
895895
_ => 0x2,
896896
};
897-
let proc_id = u64::from(cpuid_ident.eax) | u64::from(cpuid_ident.edx) << 32;
897+
let proc_id =
898+
u64::from(cpuid_ident.eax) | (u64::from(cpuid_ident.edx) << 32);
898899
let procname_entries = params.cpuid_procname.or_else(|| {
899900
if cpuid_utils::host::query(CpuidIdent::leaf(0x8000_0000)).eax
900901
>= 0x8000_0004

crates/rfb/src/proto.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mod raw {
637637

638638
#[allow(dead_code)]
639639
#[derive(Copy, Clone, FromBytes, FromZeroes, AsBytes)]
640-
#[repr(packed)]
640+
#[repr(C, packed)]
641641
pub(crate) struct PixelFormat {
642642
pub bits_per_pixel: u8,
643643
pub depth: u8,
@@ -653,30 +653,30 @@ mod raw {
653653
}
654654

655655
#[derive(Copy, Clone, FromBytes, FromZeroes)]
656-
#[repr(packed)]
656+
#[repr(C, packed)]
657657
pub(crate) struct FramebufferUpdateRequest {
658658
pub incremental: u8,
659659
pub position: Position,
660660
pub resolution: Resolution,
661661
}
662662

663663
#[derive(Copy, Clone, FromBytes, FromZeroes)]
664-
#[repr(packed)]
664+
#[repr(C, packed)]
665665
pub(crate) struct KeyEvent {
666666
pub down_flag: u8,
667667
pub _padding: [u8; 2],
668668
pub key: U32,
669669
}
670670

671671
#[derive(Copy, Clone, FromBytes, FromZeroes)]
672-
#[repr(packed)]
672+
#[repr(C, packed)]
673673
pub(crate) struct PointerEvent {
674674
pub button_mask: u8,
675675
pub position: Position,
676676
}
677677

678678
#[derive(Copy, Clone, FromBytes, FromZeroes)]
679-
#[repr(packed)]
679+
#[repr(C, packed)]
680680
pub(crate) struct Position {
681681
pub x: U16,
682682
pub y: U16,
@@ -688,7 +688,7 @@ mod raw {
688688
}
689689

690690
#[derive(Copy, Clone, FromBytes, FromZeroes)]
691-
#[repr(packed)]
691+
#[repr(C, packed)]
692692
pub(crate) struct Resolution {
693693
width: U16,
694694
height: U16,
@@ -700,7 +700,7 @@ mod raw {
700700
}
701701

702702
#[derive(Copy, Clone, AsBytes)]
703-
#[repr(packed)]
703+
#[repr(C, packed)]
704704
#[allow(dead_code)]
705705
pub(crate) struct FramebufferUpdateHeader {
706706
msg_type: u8,

lib/propolis/src/cpuid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Specializer {
165165
None => break,
166166
Some(vals) => {
167167
// bits 7:5 hold the cache level
168-
let visible_count = match (vals.eax & 0b11100000 >> 5) {
168+
let visible_count = match ((vals.eax & 0b11100000) >> 5) {
169169
0b001 | 0b010 => {
170170
// L1/L2 shared by SMT siblings
171171
if self.has_smt {

lib/propolis/src/hw/nvme/cmds.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl TryFrom<u32> for FeatNumberQueues {
614614
impl From<FeatNumberQueues> for u32 {
615615
fn from(value: FeatNumberQueues) -> Self {
616616
// Convert to 0's based DW0
617-
u32::from(value.ncq.saturating_sub(1)) << 16
617+
(u32::from(value.ncq.saturating_sub(1)) << 16)
618618
| u32::from(value.nsq.saturating_sub(1))
619619
}
620620
}
@@ -632,7 +632,7 @@ impl From<u32> for FeatInterruptVectorConfig {
632632
}
633633
impl From<FeatInterruptVectorConfig> for u32 {
634634
fn from(value: FeatInterruptVectorConfig) -> Self {
635-
u32::from(value.iv) | u32::from(value.cd) << 16
635+
u32::from(value.iv) | (u32::from(value.cd) << 16)
636636
}
637637
}
638638

@@ -664,14 +664,14 @@ impl NvmCmd {
664664
let cmd = match raw.opcode() {
665665
bits::NVM_OPC_FLUSH => NvmCmd::Flush,
666666
bits::NVM_OPC_WRITE => NvmCmd::Write(WriteCmd {
667-
slba: u64::from(raw.cdw11) << 32 | u64::from(raw.cdw10),
667+
slba: (u64::from(raw.cdw11) << 32) | u64::from(raw.cdw10),
668668
// Convert from 0's based value
669669
nlb: raw.cdw12 as u16 + 1,
670670
prp1: raw.prp1,
671671
prp2: raw.prp2,
672672
}),
673673
bits::NVM_OPC_READ => NvmCmd::Read(ReadCmd {
674-
slba: u64::from(raw.cdw11) << 32 | u64::from(raw.cdw10),
674+
slba: (u64::from(raw.cdw11) << 32) | u64::from(raw.cdw10),
675675
// Convert from 0's based value
676676
nlb: raw.cdw12 as u16 + 1,
677677
prp1: raw.prp1,
@@ -1014,8 +1014,8 @@ impl Completion {
10141014

10151015
/// Helper method to combine [StatusCodeType] and status code
10161016
const fn status_field(sct: StatusCodeType, sc: u8) -> u16 {
1017-
(sc as u16) << 1 | ((sct as u8) as u16) << 9
1018-
// (more as u16) << 14 | (dnr as u16) << 15
1017+
((sc as u16) << 1) | (((sct as u8) as u16) << 9)
1018+
// ((more as u16) << 14) | ((dnr as u16) << 15)
10191019
}
10201020
}
10211021

lib/propolis/src/hw/pci/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ fn pcie_decoder_multiple_bdfs() {
8383
});
8484

8585
let mut ro =
86-
ReadOp::from_buf(4_usize << 15 | 3_usize << 12 | 0x123, &mut buf);
86+
ReadOp::from_buf((4_usize << 15) | (3_usize << 12) | 0x123, &mut buf);
8787
pcie.service(RWOp::Read(&mut ro), |bdf, rwo| {
8888
assert_eq!(*bdf, Bdf::new(0, 4, 3).unwrap());
8989
assert_eq!(rwo.offset(), 0x123);
9090
Some(())
9191
});
9292

9393
let mut ro = ReadOp::from_buf(
94-
133_usize << 20 | 7_usize << 15 | 1_usize << 12 | 0x337,
94+
(133_usize << 20) | (7_usize << 15) | (1_usize << 12) | 0x337,
9595
&mut buf,
9696
);
9797
pcie.service(RWOp::Read(&mut ro), |bdf, rwo| {

lib/propolis/src/hw/qemu/fwcfg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ struct State {
258258
}
259259
impl State {
260260
fn dma_addr(&self) -> u64 {
261-
u64::from(self.dma_addr_high) << 32 | u64::from(self.dma_addr_low)
261+
(u64::from(self.dma_addr_high) << 32) | u64::from(self.dma_addr_low)
262262
}
263263
fn reset(&mut self) {
264264
self.selected = None;
@@ -987,7 +987,7 @@ mod test {
987987
&mem,
988988
req_addr,
989989
DmaReq {
990-
ctrl: u32::from(LegacyId::Signature as u16) << 16 | 0x000a,
990+
ctrl: (u32::from(LegacyId::Signature as u16) << 16) | 0x000a,
991991
len: 4,
992992
addr: dma_addr,
993993
},
@@ -1010,7 +1010,7 @@ mod test {
10101010
write_dma_req(
10111011
&mem,
10121012
req_addr,
1013-
DmaReq { ctrl: 0xfffe << 16 | 0x000a, len: 4, addr: dma_addr },
1013+
DmaReq { ctrl: (0xfffe << 16) | 0x000a, len: 4, addr: dma_addr },
10141014
);
10151015

10161016
// Put garbage at dma destination to confirm it gets overwritten

lib/propolis/src/vmm/mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl<T: Copy + FromBytes> Iterator for GuestData<MemMany<'_, T>> {
10611061
fn next(&mut self) -> Option<Self::Item> {
10621062
let res = self.get(self.pos);
10631063
self.pos += 1;
1064-
res.map(GuestData::from)
1064+
res
10651065
}
10661066
}
10671067

xtask/src/task_phd.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,8 @@ impl Cmd {
301301
}
302302
};
303303

304-
let artifact_dir = artifact_args
305-
.artifact_directory
306-
.map(Utf8PathBuf::from)
307-
.unwrap_or_else(|| {
304+
let artifact_dir =
305+
artifact_args.artifact_directory.unwrap_or_else(|| {
308306
// if there's no explicitly overridden `artifact_dir` path, use
309307
// `target/phd/artifacts`.
310308
phd_dir.join("artifacts")
@@ -332,10 +330,8 @@ impl Cmd {
332330

333331
mkdir(&tmp_dir, "temp directory")?;
334332

335-
let artifacts_toml = artifact_args
336-
.artifact_toml_path
337-
.map(Utf8PathBuf::from)
338-
.unwrap_or_else(|| {
333+
let artifacts_toml =
334+
artifact_args.artifact_toml_path.unwrap_or_else(|| {
339335
// if there's no explicitly overridden `artifacts.toml` path,
340336
// determine the default one from the workspace path.
341337
relativize(&meta.workspace_root)

0 commit comments

Comments
 (0)