Skip to content

Commit a1a2fea

Browse files
ahmadstmnashif
authored andcommitted
STM32WBA6: common: nv_counter backend: fix build warnings
Fix build warnings due to defined but unused variables and to declared but not defined functions. .../trusted-firmware-m/platform/ext/common/template/flash_otp_nv_counters_backend.c:172:14: warning: unused variable 'backup_swap_count' [-Wunused-variable] 172 | uint32_t backup_swap_count; | ^~~~~~~~~~~~~~~~~ .../trusted-firmware-m/platform/ext/common/template/flash_otp_nv_counters_backend.c:22:28: warning: 'create_or_restore_layout' declared 'static' but never defined [-Wunused-function] 22 | static enum tfm_plat_err_t create_or_restore_layout(void); | ^~~~~~~~~~~~~~~~~~~~~~~~ .../trusted-firmware-m/platform/ext/common/template/flash_otp_nv_counters_backend.c:122:16: warning: 'block' defined but not used [-Wunused-variable] 122 | static uint8_t block[OTP_NV_COUNTERS_WRITE_BLOCK_SIZE]; | ^~~~~ Also rename copy_data_into_block() argument 'block' to 'block_ptr' to disambiguous it with the source file global variable 'block". Signed-off-by: Ahmad EL JOUAID <ahmad.eljouaid@st.com> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Change-Id: Ifd56ecf53536a559e8034571eb7e2988aee444d9 (cherry picked from commit b5bb3ae59230a5662e65363543da8b8efa4644de)
1 parent c1299d2 commit a1a2fea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

platform/ext/common/template/flash_otp_nv_counters_backend.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
#include <string.h>
2121

22+
#if defined(OTP_WRITEABLE)
2223
static enum tfm_plat_err_t create_or_restore_layout(void);
24+
#endif
2325

2426
#if OTP_NV_COUNTERS_RAM_EMULATION
2527

@@ -119,7 +121,9 @@ static enum tfm_plat_err_t make_backup(void);
119121
#endif
120122
/* End of compilation time checks to be sure the defines are well defined */
121123

124+
#if defined(OTP_WRITEABLE)
122125
static uint8_t block[OTP_NV_COUNTERS_WRITE_BLOCK_SIZE];
126+
#endif
123127

124128
/* Import the CMSIS flash device driver */
125129
extern ARM_DRIVER_FLASH OTP_NV_COUNTERS_FLASH_DEV;
@@ -169,7 +173,6 @@ enum tfm_plat_err_t init_otp_nv_counters_flash(void)
169173
enum tfm_plat_err_t err = TFM_PLAT_ERR_SUCCESS;
170174
uint32_t init_value;
171175
uint32_t swap_count;
172-
uint32_t backup_swap_count;
173176

174177
if ((TFM_OTP_NV_COUNTERS_AREA_SIZE) < sizeof(struct flash_otp_nv_counters_region_t)) {
175178
return TFM_PLAT_ERR_SYSTEM_ERR;
@@ -200,6 +203,8 @@ enum tfm_plat_err_t init_otp_nv_counters_flash(void)
200203
}
201204
else
202205
{
206+
uint32_t backup_swap_count;
207+
203208
err = read_otp_nv_counters_flash(offsetof(struct flash_otp_nv_counters_region_t, swap_count)
204209
+ TFM_OTP_NV_COUNTERS_AREA_SIZE,
205210
&backup_swap_count, sizeof(backup_swap_count));
@@ -307,7 +312,7 @@ static enum tfm_plat_err_t copy_data_into_block(uint32_t data_offset,
307312
const uint8_t *data,
308313
uint32_t block_offset,
309314
size_t block_size,
310-
uint8_t *block)
315+
uint8_t *block_ptr)
311316
{
312317
uint32_t copy_start_offset;
313318
uint32_t copy_end_offset;
@@ -327,7 +332,7 @@ static enum tfm_plat_err_t copy_data_into_block(uint32_t data_offset,
327332
copy_end_offset = data_offset + data_size;
328333
}
329334

330-
memcpy(block + (copy_start_offset - block_offset),
335+
memcpy(block_ptr + (copy_start_offset - block_offset),
331336
data + (copy_start_offset - data_offset),
332337
copy_end_offset - copy_start_offset);
333338
}

0 commit comments

Comments
 (0)