mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] param: make return value of param getter function const
Date: Tue, 24 Apr 2012 11:21:17 +0200	[thread overview]
Message-ID: <1335259279-25353-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1335259279-25353-1-git-send-email-s.hauer@pengutronix.de>

The string returned by the getter function should not be
changed. Make it const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/param.h |    6 +++---
 lib/parameter.c |   10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/param.h b/include/param.h
index 4a39dc7..e7b66a4 100644
--- a/include/param.h
+++ b/include/param.h
@@ -10,7 +10,7 @@ struct device_d;
 typedef unsigned long          IPaddr_t;
 
 struct param_d {
-	char* (*get)(struct device_d *, struct param_d *param);
+	const char* (*get)(struct device_d *, struct param_d *param);
 	int (*set)(struct device_d *, struct param_d *param, const char *val);
 	unsigned int flags;
 	char *name;
@@ -24,9 +24,9 @@ const char *dev_get_param(struct device_d *dev, const char *name);
 int dev_set_param(struct device_d *dev, const char *name, const char *val);
 struct param_d *get_param_by_name(struct device_d *dev, const char *name);
 
-int dev_add_param(struct device_d *dev, char *name,
+int dev_add_param(struct device_d *dev, const char *name,
 		int (*set)(struct device_d *dev, struct param_d *p, const char *val),
-		char *(*get)(struct device_d *, struct param_d *p),
+		const char *(*get)(struct device_d *, struct param_d *p),
 		unsigned long flags);
 
 int dev_add_param_fixed(struct device_d *dev, char *name, char *value);
diff --git a/lib/parameter.c b/lib/parameter.c
index 5a7ae1a..e746467 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -133,14 +133,14 @@ int dev_param_set_generic(struct device_d *dev, struct param_d *p,
 	return 0;
 }
 
-static char *param_get_generic(struct device_d *dev, struct param_d *p)
+static const char *param_get_generic(struct device_d *dev, struct param_d *p)
 {
 	return p->value;
 }
 
-static struct param_d *__dev_add_param(struct device_d *dev, char *name,
+static struct param_d *__dev_add_param(struct device_d *dev, const char *name,
 		int (*set)(struct device_d *dev, struct param_d *p, const char *val),
-		char *(*get)(struct device_d *dev, struct param_d *p),
+		const char *(*get)(struct device_d *dev, struct param_d *p),
 		unsigned long flags)
 {
 	struct param_d *param;
@@ -176,9 +176,9 @@ static struct param_d *__dev_add_param(struct device_d *dev, char *name,
  * expect the parameter value to be a string which can be freed with free(). Do
  * not use static arrays when using the generic functions.
  */
-int dev_add_param(struct device_d *dev, char *name,
+int dev_add_param(struct device_d *dev, const char *name,
 		int (*set)(struct device_d *dev, struct param_d *p, const char *val),
-		char *(*get)(struct device_d *dev, struct param_d *param),
+		const char *(*get)(struct device_d *dev, struct param_d *param),
 		unsigned long flags)
 {
 	struct param_d *param;
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-04-24  9:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24  9:21 device parameter patches Sascha Hauer
2012-04-24  9:21 ` Sascha Hauer [this message]
2012-04-24  9:21 ` [PATCH 2/3] devinfo: use accessor function for parameters Sascha Hauer
2012-04-24  9:21 ` [PATCH 3/3] dev_add_param: check if param exists already Sascha Hauer

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=1335259279-25353-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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