mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] param: don't use bobject_t in function pointer signatures
@ 2025-09-01 15:29 Ahmad Fatoum
  0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-09-01 15:29 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

UndefinedBehaviorSanitizier for clang-21 complains about calling
functions through function pointers with bobject_t in their signatures
when the original arguments use struct device * or struct bobject *.

Let's migrate all function pointers to use struct bobject * instead to
fix this.

Fixes: feef2e053ea4 ("param: operate on bobjects instead of full devices")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/globalvar.c | 15 +++++++--------
 include/param.h    |  4 ++--
 lib/parameter.c    |  8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index cca1ac9b39f5..77af6733a6a0 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -177,8 +177,7 @@ static int nvvar_device_dispatch(const char *name, struct device **dev,
 	return 1;
 }
 
-static int nv_set(struct device *dev, struct param_d *p, const char *name,
-		  const char *val)
+static int nv_set(struct param_d *p, const char *name, const char *val)
 {
 	int ret;
 
@@ -196,17 +195,17 @@ static int nv_set(struct device *dev, struct param_d *p, const char *name,
 	return 0;
 }
 
-static const char *nv_param_get(struct device *dev, struct param_d *p)
+static const char *nv_param_get(struct bobject *bobj, struct param_d *p)
 {
 	return p->value ? p->value : "";
 }
 
-static int nv_param_set(struct device *dev, struct param_d *p,
+static int nv_param_set(struct bobject *bobj, struct param_d *p,
 			const char *val)
 {
 	int ret;
 
-	ret = nv_set(dev, p, p->name, val);
+	ret = nv_set(p, p->name, val);
 	if (ret)
 		return ret;
 
@@ -237,7 +236,7 @@ static int __nvvar_add(const char *name, const char *value)
 		return ret;
 
 	if (value)
-		return nv_set(&nv_device, p, name, value);
+		return nv_set(p, name, value);
 
 	ret = nvvar_device_dispatch(name, &dev, &pname);
 	if (ret > 0)
@@ -455,7 +454,7 @@ void globalvar_set(const char *name, const char *val)
 	dev_set_param(&global_device, name, val);
 }
 
-static int globalvar_simple_set(struct device *dev, struct param_d *p,
+static int globalvar_simple_set(struct bobject *bobj, struct param_d *p,
 				const char *val)
 {
 	struct device *rdev;
@@ -474,7 +473,7 @@ static int globalvar_simple_set(struct device *dev, struct param_d *p,
 	}
 
 	/* Pass to the generic function we have overwritten */
-	return dev_param_set_generic(dev, p, val);
+	return dev_param_set_generic(bobj, p, val);
 }
 
 /*
diff --git a/include/param.h b/include/param.h
index c12151134752..a15e064ddec2 100644
--- a/include/param.h
+++ b/include/param.h
@@ -30,8 +30,8 @@ enum param_type {
 };
 
 struct param_d {
-	const char* (*get)(bobject_t, struct param_d *param);
-	int (*set)(bobject_t, struct param_d *param, const char *val);
+	const char* (*get)(struct bobject *, struct param_d *param);
+	int (*set)(struct bobject *, struct param_d *param, const char *val);
 	void (*info)(struct param_d *param);
 	unsigned int flags;
 	const char *name;
diff --git a/lib/parameter.c b/lib/parameter.c
index 0f9164386c6d..274e6fcb8376 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -155,8 +155,8 @@ static int compare(struct list_head *a, struct list_head *b)
 
 static int __bobject_add_param(struct param_d *param, struct bobject *bobj,
 			   const char *name,
-			   int (*set)(bobject_t _bobj, struct param_d *p, const char *val),
-			   const char *(*get)(bobject_t _bobj, struct param_d *p),
+			   int (*set)(struct bobject *, struct param_d *p, const char *val),
+			   const char *(*get)(struct bobject *, struct param_d *p),
 			   unsigned long flags)
 {
 	if (get_param_by_name(bobj, name))
@@ -199,8 +199,8 @@ static int __bobject_add_param(struct param_d *param, struct bobject *bobj,
  * not use static arrays when using the generic functions.
  */
 struct param_d *bobject_add_param(bobject_t _bobj, const char *name,
-			      int (*set)(bobject_t _bobj, struct param_d *p, const char *val),
-			      const char *(*get)(bobject_t _bobj, struct param_d *param),
+			      int (*set)(struct bobject *, struct param_d *p, const char *val),
+			      const char *(*get)(struct bobject *, struct param_d *param),
 			      unsigned long flags)
 {
 	struct bobject *bobj = _bobj.bobj;
-- 
2.47.2




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

only message in thread, other threads:[~2025-09-01 23:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-01 15:29 [PATCH master] param: don't use bobject_t in function pointer signatures Ahmad Fatoum

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