lkml.org 
[lkml]   [2010]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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


\
 
 \ /
  Last update: 2010-06-09 23:51    [W:1.285 / U:0.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site