Add new string functions strict_strto* and convert kernel params to use them
[linux-2.6.git] / kernel / params.c
index e28c706..afc46a2 100644 (file)
@@ -180,12 +180,12 @@ int parse_args(const char *name,
 #define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn)              \
        int param_set_##name(const char *val, struct kernel_param *kp)  \
        {                                                               \
-               char *endp;                                             \
                tmptype l;                                              \
+               int ret;                                                \
                                                                        \
                if (!val) return -EINVAL;                               \
-               l = strtolfn(val, &endp, 0);                            \
-               if (endp == val || ((type)l != l))                      \
+               ret = strtolfn(val, 0, &l);                             \
+               if (ret == -EINVAL || ((type)l != l))                   \
                        return -EINVAL;                                 \
                *((type *)kp->arg) = l;                                 \
                return 0;                                               \
@@ -195,13 +195,13 @@ int parse_args(const char *name,
                return sprintf(buffer, format, *((type *)kp->arg));     \
        }
 
-STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, simple_strtoul);
-STANDARD_PARAM_DEF(short, short, "%hi", long, simple_strtol);
-STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, simple_strtoul);
-STANDARD_PARAM_DEF(int, int, "%i", long, simple_strtol);
-STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, simple_strtoul);
-STANDARD_PARAM_DEF(long, long, "%li", long, simple_strtol);
-STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, simple_strtoul);
+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);
 
 int param_set_charp(const char *val, struct kernel_param *kp)
 {