[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20100609214744.GB31340@x200>
Date: Thu, 10 Jun 2010 00:47:44 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org, yi.y.yang@...el.com
Subject: [PATCH 2/2] kstrto*: convert kernel/params.c
Remove proxy variable and checking that casting to a type doesn't change
value -- kstrto* do all of this inside.
---
kernel/params.c | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/kernel/params.c b/kernel/params.c
index 0b30ecd..0e5c4ad 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -175,17 +175,15 @@ int parse_args(const char *name,
}
/* Lazy bastard, eh? */
-#define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn) \
+#define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
int param_set_##name(const char *val, struct kernel_param *kp) \
{ \
- tmptype l; \
int ret; \
\
if (!val) return -EINVAL; \
- ret = strtolfn(val, 0, &l); \
- if (ret == -EINVAL || ((type)l != l)) \
- return -EINVAL; \
- *((type *)kp->arg) = l; \
+ ret = strtolfn(val, 0, (type *)kp->arg); \
+ if (ret < 0) \
+ return ret; \
return 0; \
} \
int param_get_##name(char *buffer, struct kernel_param *kp) \
@@ -193,13 +191,13 @@ int parse_args(const char *name,
return sprintf(buffer, format, *((type *)kp->arg)); \
}
-STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(short, short, "%hi", long, strict_strtol);
-STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(int, int, "%i", long, strict_strtol);
-STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(long, long, "%li", long, strict_strtol);
-STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, strict_strtoul);
+STANDARD_PARAM_DEF(byte, u8, "%c", kstrtou8);
+STANDARD_PARAM_DEF(short, s16, "%hi", kstrtos16);
+STANDARD_PARAM_DEF(ushort, u16, "%hu", kstrtou16);
+STANDARD_PARAM_DEF(int, int, "%i", kstrtoint);
+STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
+STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
+STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
int param_set_charp(const char *val, struct kernel_param *kp)
{
--
1.6.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists