summaryrefslogtreecommitdiffstats
path: root/lib/parameter.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-13 12:43:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-14 08:35:54 +0200
commit6188685091c58c9772b990cf0ca6ac522f97a9d0 (patch)
treeff994e79773e3bab5abe1b79129cbb08ddf9f754 /lib/parameter.c
parent2f05b6925676e5f3263e0d51ed2f0a92201400d8 (diff)
downloadbarebox-6188685091c58c9772b990cf0ca6ac522f97a9d0.tar.gz
barebox-6188685091c58c9772b990cf0ca6ac522f97a9d0.tar.xz
Make errno a positive value
Normally errno contains a positive error value. A certain unnamed developer mixed this up while implementing U-Boot-v2. Also, normally errno is never set to zero by any library function. This patch fixes this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/parameter.c')
-rw-r--r--lib/parameter.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/parameter.c b/lib/parameter.c
index c75c21e768..b2b8d945a6 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -54,7 +54,7 @@ const char *dev_get_param(struct device_d *dev, const char *name)
struct param_d *param = get_param_by_name(dev, name);
if (!param) {
- errno = -EINVAL;
+ errno = EINVAL;
return NULL;
}
@@ -87,26 +87,30 @@ int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip)
int dev_set_param(struct device_d *dev, const char *name, const char *val)
{
struct param_d *param;
+ int ret;
if (!dev) {
- errno = -ENODEV;
+ errno = ENODEV;
return -ENODEV;
}
param = get_param_by_name(dev, name);
if (!param) {
- errno = -EINVAL;
+ errno = EINVAL;
return -EINVAL;
}
if (param->flags & PARAM_FLAG_RO) {
- errno = -EACCES;
+ errno = EACCES;
return -EACCES;
}
- errno = param->set(dev, param, val);
- return errno;
+ ret = param->set(dev, param, val);
+ if (ret)
+ errno = -ret;
+
+ return ret;
}
/**