Andrew please drop
        introduce-strtol_check_range-fix.patch
        introduce-strtol_check_range.patch
from -mm.

strtol_check_range() semantics is broken, because caller can't distinguish
-E from valid negative number if he wants to negative integers. Comment
mentions this, but we don't want to such horrible and not well thought
out function to lib/ .

If anything it should be strtonum() with additional trailing '\n' check.

+ * Do not use this to convert numbers that are allowed to be negative.
+ */
+long strtol_check_range(const char *cp, long min, long max, unsigned int base)
+{
+       long ret;
+       char *p = (char *) cp;
+
+       WARN_ON(min < 0);
+       WARN_ON(max < min);
+
+       ret = simple_strtol(p, &p, base);
+
+       if (*p && (*p != '\n'))
+               return -EINVAL;
+       if ((ret < min) || (ret > max))
+               return -EINVAL;
+
+       return ret;
+}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to