Skip to contentSkip to conversation

i.MX: HABv4: Hide NULL pointers from optimizer

PATCH New Sascha Hauer 1 participant 1 message May 16, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i.MX: HABv4: Hide NULL pointers from optimizer

We are derefencing pointers which are in the zero page, consequently gcc warns us with:

drivers/hab/habv4.c: In function 'imx6_hab_get_status':
drivers/hab/habv4.c:580:16: warning: array subscript 0 is outside array bounds of 'const struct habv4_rvt[0]' [-Warray-bounds]

Yes, we really want to derefence these pointers, so silence the warning with OPTIMIZER_HIDE_VAR().

---
 drivers/hab/habv4.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/hab/habv4.c +3 -0
index 252e38f655..ca26773bf8 100644
@@ -564,14 +564,17 @@ int imx6_hab_get_status(void)
 	const struct habv4_rvt *rvt;
 
 	rvt = (void *)HABV4_RVT_IMX6_OLD;
+	OPTIMIZER_HIDE_VAR(rvt);
 	if (rvt->header.tag == HAB_TAG_RVT)
 		return habv4_get_status(rvt);
 
 	rvt = (void *)HABV4_RVT_IMX6_NEW;
+	OPTIMIZER_HIDE_VAR(rvt);
 	if (rvt->header.tag == HAB_TAG_RVT)
 		return habv4_get_status(rvt);
 
 	rvt = (void *)HABV4_RVT_IMX6UL;
+	OPTIMIZER_HIDE_VAR(rvt);
 	if (rvt->header.tag == HAB_TAG_RVT)
 		return habv4_get_status(rvt);
 
Signature · 1 line
2.39.2