Skip to contentSkip to conversation

efi_selftest: efi_selftest_snp: Fix warning when building with clang

PATCH In review Tom Rini 2 participants 2 messages Nov 6, 2025 – Nov 12, 2025

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 efi_selftest: efi_selftest_snp: Fix warning when building with clang

When building with clang, we see a warning:
lib/efi_selftest/efi_selftest_snp.c:63:18: error: field dhcp_hdr within 'struct dhcp' is less aligned than 'struct dhcp_hdr' and is usually due to 'struct dhcp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
when building lib/efi_selftest/efi_selftest_snp.c. Resolve this error by packing struct dhcp_hdr as well, as the only place it is used also is packed.

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Adriano Cordova <[email protected]>

---
 lib/efi_selftest/efi_selftest_snp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_selftest/efi_selftest_snp.c +1 -1
index b00c76c2f172..290ed3a28f2c 100644
@@ -43,7 +43,7 @@ struct dhcp_hdr {
 	u8 chaddr[16];
 	u8 sname[64];
 	u8 file[128];
-};
+} __packed;
 
 /*
  * Message type option.
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tom Rini

When building with clang, we see a warning:
lib/efi_selftest/efi_selftest_snp.c:63:18: error: field dhcp_hdr within 'struct dhcp' is less aligned than 'struct dhcp_hdr' and is usually due to 'struct dhcp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
when building lib/efi_selftest/efi_selftest_snp.c. Resolve this error by packing struct dhcp_hdr as well, as the only place it is used also is packed.

Quoted 24 lines

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Adriano Cordova <[email protected]>

---
 lib/efi_selftest/efi_selftest_snp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_selftest/efi_selftest_snp.c +1 -2
index b00c76c2f172..290ed3a28f2c 100644
@@ -43,7 +43,7 @@ struct dhcp_hdr {
        u8 chaddr[16];
        u8 sname[64];
        u8 file[128];
-};
+} __packed;
 
 /*
  * Message type option.
--

2.43.0