mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] i.MX: HABv4: Hide NULL pointers from optimizer
@ 2023-05-16  8:22 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2023-05-16  8:22 UTC (permalink / raw)
  To: Barebox List

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().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/hab/habv4.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
index 252e38f655..ca26773bf8 100644
--- a/drivers/hab/habv4.c
+++ b/drivers/hab/habv4.c
@@ -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);
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-16  8:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16  8:22 [PATCH] i.MX: HABv4: Hide NULL pointers from optimizer Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox