This is an automated email from the ASF dual-hosted git repository.
simbit18 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 069ceab9c53 lzf: prevent lzf header struct optimization
069ceab9c53 is described below
commit 069ceab9c531dafb1fcb3259b6ec813b2710fc3a
Author: zhangyuan29 <[email protected]>
AuthorDate: Wed Apr 30 14:39:41 2025 +0800
lzf: prevent lzf header struct optimization
Add packed attribute to lzf header structs to prevent the compiler
from optimizing lzf_magic array initialization into wider store
instructions (e.g. st.h), which can cause misaligned access
exceptions on architectures that do not support unaligned memory access.
Signed-off-by: zhangyuan29 <[email protected]>
---
include/lzf.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/lzf.h b/include/lzf.h
index 81ba13762c8..42cd26ca693 100644
--- a/include/lzf.h
+++ b/include/lzf.h
@@ -64,26 +64,26 @@
/* LZF headers */
-struct lzf_header_s /* Common data header */
+begin_packed_struct struct lzf_header_s /* Common data header */
{
uint8_t lzf_magic[2]; /* [0]='Z', [1]='V' */
uint8_t lzf_type; /* LZF_TYPE0_HDR or LZF_TYPE1_HDR */
-};
+} end_packed_struct;
-struct lzf_type0_header_s /* Uncompressed data header */
+begin_packed_struct struct lzf_type0_header_s /* Uncompressed data header */
{
uint8_t lzf_magic[2]; /* [0]='Z', [1]='V' */
uint8_t lzf_type; /* LZF_TYPE0_HDR */
uint8_t lzf_len[2]; /* Data length (big-endian) */
-};
+} end_packed_struct;
-struct lzf_type1_header_s /* Compressed data header */
+begin_packed_struct struct lzf_type1_header_s /* Compressed data header */
{
uint8_t lzf_magic[2]; /* [0]='Z', [1]='V' */
uint8_t lzf_type; /* LZF_TYPE1_HDR */
uint8_t lzf_clen[2]; /* Compressed data length (big-endian) */
uint8_t lzf_ulen[2]; /* Uncompressed data length (big-endian) */
-};
+} end_packed_struct;
/* LZF hash table */