mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] param: don't use bobject_t in function pointer signatures
Date: Mon,  1 Sep 2025 17:29:36 +0200	[thread overview]
Message-ID: <20250901152940.2472959-1-a.fatoum@pengutronix.de> (raw)

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




                 reply	other threads:[~2025-09-01 23:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250901152940.2472959-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox