lkml.org 
[lkml]   [2007]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v3 -mm 9/9] netconsole: Support dynamic reconfiguration using configfs


    On Mon, 30 Jul 2007, Andrew Morton wrote:

    > On Mon, 30 Jul 2007 08:19:10 +0530
    > Satyam Sharma <satyam@infradead.org> wrote:
    >
    > > +/*
    > > + * Wrapper over simple_strtol (base 10) with sanity and range checking.
    > > + * We return (signed) long only because we may want to return errors.
    > > + * Do not use this to convert numbers that are allowed to be negative.
    > > + */
    > > +static long strtol10_check_range(const char *cp, long min, long max)
    > > +{
    > > + long ret;
    > > + char *p = (char *) cp;
    > > +
    > > + WARN_ON(min < 0);
    > > + WARN_ON(max < min);
    > > +
    > > + ret = simple_strtol(p, &p, 10);
    > > +
    > > + if (*p && (*p != '\n')) {
    > > + printk(KERN_ERR "netconsole: invalid input\n");
    > > + return -EINVAL;
    > > + }
    > > + if ((ret < min) || (ret > max)) {
    > > + printk(KERN_ERR "netconsole: input %ld must be between "
    > > + "%ld and %ld\n", ret, min, max);
    > > + return -EINVAL;
    > > + }
    > > +
    > > + return ret;
    > > +}
    >
    > There's probably other code around the place which does this. It might
    > be worth making this function a general-purpose thing.

    Probably, yes, I thought along similar lines.

    [ BTW somewhere in the 9/9 patch I remember having to define a
    __U16_MAX as well. That could be pushed out to some generic
    or appropriate header as well, possibly. ]


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

    \
     
     \ /
      Last update: 2007-07-31 02:31    [W:5.862 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site