Skip to content

Commit c1299d2

Browse files
ahmadstmnashif
authored andcommitted
STM32WBA6: nv_counter: fix build warnings
Fix build warnings (see the build trace messages below) emitted when building STM platforms b_u585i_iot02a, nucleo_l552ze_q, stm32h573i_dk and stm32l562e_dk. All these are due to comparison between an unsigned and a signed values. .../trusted-firmware-m/platform/ext/target/stm/common/hal/Native_Driver/nv_counters.c:108:13: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'long int'} and 'unsigned int' [-Wsign-compare] 108 | if (ret != (sizeof(struct nv_counters_t) / data_width)) { | ^~ .../trusted-firmware-m/platform/ext/target/stm/common/hal/Native_Driver/nv_counters.c:120:13: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'long int'} and 'unsigned int' [-Wsign-compare] 120 | if (ret != (sizeof(struct nv_counters_t) / data_width)) { | ^~ .../trusted-firmware-m/platform/ext/target/stm/common/hal/Native_Driver/nv_counters.c:135:17: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'long int'} and 'unsigned int' [-Wsign-compare] 135 | if (ret != (sizeof(struct nv_counters_t) / data_width)) { | ^~ Signed-off-by: Ahmad EL JOUAID <ahmad.eljouaid@st.com> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Change-Id: Ief59f8ba9b91cec0185c2621ff314dfc9565dde5 (cherry picked from commit 93d4badf44bed0bcbfa1dc4944a232086f02fef8)
1 parent f4896bd commit c1299d2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

platform/ext/target/stm/common/hal/Native_Driver/nv_counters.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ enum tfm_plat_err_t tfm_plat_init_nv_counter(void)
105105
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ReadData(VALID_ADDRESS,
106106
&nv_counters,
107107
sizeof(struct nv_counters_t) / data_width);
108-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
108+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
109109
return TFM_PLAT_ERR_SYSTEM_ERR;
110110
}
111111

@@ -117,7 +117,7 @@ enum tfm_plat_err_t tfm_plat_init_nv_counter(void)
117117
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ReadData(BACKUP_ADDRESS,
118118
&nv_counters,
119119
sizeof(struct nv_counters_t) / data_width);
120-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
120+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
121121
return TFM_PLAT_ERR_SYSTEM_ERR;
122122
}
123123

@@ -132,7 +132,7 @@ enum tfm_plat_err_t tfm_plat_init_nv_counter(void)
132132
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ProgramData(VALID_ADDRESS,
133133
&nv_counters,
134134
sizeof(struct nv_counters_t) / data_width);
135-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
135+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
136136
return TFM_PLAT_ERR_SYSTEM_ERR;
137137
}
138138

@@ -153,7 +153,7 @@ enum tfm_plat_err_t tfm_plat_init_nv_counter(void)
153153
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ProgramData(VALID_ADDRESS,
154154
&nv_counters,
155155
sizeof(struct nv_counters_t) / data_width);
156-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
156+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
157157
return TFM_PLAT_ERR_SYSTEM_ERR;
158158
}
159159

@@ -185,7 +185,7 @@ enum tfm_plat_err_t tfm_plat_read_nv_counter(enum tfm_nv_counter_t counter_id,
185185
data_width = data_width_byte[DriverCapabilities.data_width];
186186

187187
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ReadData(flash_addr, val, NV_COUNTER_SIZE / data_width);
188-
if (ret != (NV_COUNTER_SIZE / data_width)) {
188+
if (ret != (int32_t)(NV_COUNTER_SIZE / data_width)) {
189189
return TFM_PLAT_ERR_SYSTEM_ERR;
190190
}
191191

@@ -205,16 +205,16 @@ enum tfm_plat_err_t tfm_plat_set_nv_counter(enum tfm_nv_counter_t counter_id,
205205
sizeof(uint16_t),
206206
sizeof(uint32_t),
207207
};
208-
208+
209209
DriverCapabilities = DEVICE_NV_COUNTERS_FLASH_NAME.GetCapabilities();
210210
/* Since struct nv_counter is aligned on 32 bits , a single read /write is possible */
211211
data_width = data_width_byte[DriverCapabilities.data_width];
212-
212+
213213
/* Read the whole sector so we can write it back to flash later */
214214
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ReadData(VALID_ADDRESS,
215215
&nv_counters,
216216
sizeof(struct nv_counters_t) / data_width);
217-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
217+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
218218
return TFM_PLAT_ERR_SYSTEM_ERR;
219219
}
220220

@@ -238,7 +238,7 @@ enum tfm_plat_err_t tfm_plat_set_nv_counter(enum tfm_nv_counter_t counter_id,
238238
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ProgramData(BACKUP_ADDRESS,
239239
&nv_counters,
240240
sizeof(struct nv_counters_t) / data_width);
241-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
241+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
242242
return TFM_PLAT_ERR_SYSTEM_ERR;
243243
}
244244

@@ -252,7 +252,7 @@ enum tfm_plat_err_t tfm_plat_set_nv_counter(enum tfm_nv_counter_t counter_id,
252252
ret = DEVICE_NV_COUNTERS_FLASH_NAME.ProgramData(VALID_ADDRESS,
253253
&nv_counters,
254254
sizeof(struct nv_counters_t) / data_width);
255-
if (ret != (sizeof(struct nv_counters_t) / data_width)) {
255+
if (ret != (int32_t)(sizeof(struct nv_counters_t) / data_width)) {
256256
return TFM_PLAT_ERR_SYSTEM_ERR;
257257
}
258258
}

0 commit comments

Comments
 (0)