* [PATCH 2/2] kstrto*: convert kernel/params.c
@ 2010-06-09 21:47 Alexey Dobriyan
0 siblings, 0 replies; only message in thread
From: Alexey Dobriyan @ 2010-06-09 21:47 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, yi.y.yang
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-09 21:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-09 21:47 [PATCH 2/2] kstrto*: convert kernel/params.c Alexey Dobriyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®