From 02c0f080605443a70d13b96ae4dd9ae8ffb19691 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 18 Jan 2021 13:50:48 +0100 Subject: [PATCH] flashfs: fix alignment ambiguity Instead of ignoring the warnings. Thanks to @Ole2mail and @yuhaim for the suggestions. --- src/lib/parameters/flashparams/CMakeLists.txt | 1 - src/lib/parameters/flashparams/flashfs.c | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/parameters/flashparams/CMakeLists.txt b/src/lib/parameters/flashparams/CMakeLists.txt index 86b63bf6ce..a971cacd47 100644 --- a/src/lib/parameters/flashparams/CMakeLists.txt +++ b/src/lib/parameters/flashparams/CMakeLists.txt @@ -42,7 +42,6 @@ target_compile_options(flashparams PRIVATE -Wno-sign-compare # TODO: fix this -Wno-cast-align # TODO: fix and enable - -Wno-address-of-packed-member # TODO: fix this ) target_link_libraries(flashparams PRIVATE nuttx_arch) diff --git a/src/lib/parameters/flashparams/flashfs.c b/src/lib/parameters/flashparams/flashfs.c index 6ed9114c9e..1da457e5f3 100644 --- a/src/lib/parameters/flashparams/flashfs.c +++ b/src/lib/parameters/flashparams/flashfs.c @@ -86,11 +86,10 @@ typedef enum flash_flags_t { } flash_flags_t; -/* File flash_entry_header_t will be sizeof(h_magic_t) aligned +/* The struct flash_entry_header_t will be sizeof(uint32_t) aligned * The Size will be the actual length of the header plus the data * and any padding needed to have the size be an even multiple of - * sizeof(h_magic_t) - * The + * sizeof(uint32_t) */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wattributes" @@ -102,7 +101,7 @@ typedef begin_packed_struct struct flash_entry_header_t { * Will result the offset of the next active file or * free space. */ flash_file_token_t file_token; /* file token type - essentially the name/type */ -} end_packed_struct flash_entry_header_t; +} end_packed_struct flash_entry_header_t __attribute__((aligned(sizeof(uint32_t)))); #pragma GCC diagnostic pop /****************************************************************************