kstrto*: convert kernel/params.c
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(-)
kernel/params.c +11 -13
@@ -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) {
Signature · 1 line
1.6.4.4