Skip to content

Commit a7e4d15

Browse files
committed
Specify C-ABI when packing
Clippy now warns about this: error: item uses `packed` representation without ABI-qualification Quote from clippy: > repr(packed) by default implies repr(Rust, packed). However, this > representation is not stable, which makes it less useful: the bulk of > repr(packed) use cases are for interfacing with certain binary formats > (where it needs to be repr(C, packed)) and for zero-copy deserialization > (which needs to be stable). The best use case for repr(Rust, packed) is > for reducing binary size Signed-off-by: Daniel Schaefer <[email protected]>
1 parent a2e4dd3 commit a7e4d15

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

framework_lib/src/audio_card.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum CapeCommand {
1515
GetVersion = 0x0103,
1616
}
1717

18-
#[repr(packed)]
18+
#[repr(C, packed)]
1919
#[derive(Clone, Copy)]
2020
struct CapeMessage {
2121
_len: i16,
@@ -25,7 +25,7 @@ struct CapeMessage {
2525
data: [u32; CAPE_DATA_LEN],
2626
}
2727

28-
#[repr(packed)]
28+
#[repr(C, packed)]
2929
#[derive(Clone, Copy)]
3030
struct HidCapeMessage {
3131
_report_id: u16,

framework_lib/src/ccgx/binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const FW_VERSION_OFFSET: usize = 0xE0;
4444
const SMALL_ROW: usize = 0x80;
4545
const LARGE_ROW: usize = 0x100;
4646

47-
#[repr(packed)]
47+
#[repr(C, packed)]
4848
#[derive(Debug, Copy, Clone)]
4949
struct VersionInfo {
5050
base_version: u32,

framework_lib/src/ccgx/hid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const FW2_START: usize = 0x0200;
2525
const FW1_METADATA: usize = 0x03FF;
2626
const FW2_METADATA: usize = 0x03FE;
2727

28-
#[repr(packed)]
28+
#[repr(C, packed)]
2929
#[derive(Debug, Copy, Clone)]
3030
struct HidFirmwareInfo {
3131
report_id: u8,

framework_lib/src/ccgx/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const CCG3_METADATA_OFFSET: usize = 0x40;
3030
const METADATA_MAGIC: u16 = u16::from_le_bytes([b'Y', b'C']); // CY (Cypress)
3131
const CCG8_METADATA_MAGIC: u16 = u16::from_le_bytes([b'F', b'I']); // IF (Infineon)
3232

33-
#[repr(packed)]
33+
#[repr(C, packed)]
3434
#[derive(Debug, Copy, Clone)]
3535
struct CyAcdMetadata {
3636
/// Offset 00: Single Byte FW Checksum
@@ -64,7 +64,7 @@ struct CyAcdMetadata {
6464
}
6565

6666
// TODO: Would be nice to check the checksums
67-
#[repr(packed)]
67+
#[repr(C, packed)]
6868
#[derive(Debug, Copy, Clone)]
6969
struct CyAcd2Metadata {
7070
/// Offset 00: App Firmware Start

framework_lib/src/esrt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn match_guid_kind(guid: &Guid) -> FrameworkGuidKind {
144144
}
145145
}
146146

147-
#[repr(packed)]
147+
#[repr(C, packed)]
148148
struct _Esrt {
149149
resource_count: u32,
150150
resource_count_max: u32,

framework_lib/src/smbios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub struct Smbios3 {
106106
}
107107

108108
#[cfg(target_os = "freebsd")]
109-
#[repr(packed)]
109+
#[repr(C, packed)]
110110
pub struct Smbios {
111111
pub anchor: [u8; 4],
112112
pub checksum: u8,

framework_lib/src/uefi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn enable_page_break() {
9999
}
100100
}
101101

102-
#[repr(packed)]
102+
#[repr(C, packed)]
103103
pub struct Smbios {
104104
pub anchor: [u8; 4],
105105
pub checksum: u8,

0 commit comments

Comments
 (0)