Re: [PATCH resend 2] x86, olpc-xo15-sci: Enable lid close wakeup control through sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 04 Dec 2011 11:50:08 +0000 Alan Jenkins <alan.christopher.jenkins@xxxxxxxxxxxxxx> wrote:

> On 01/-10/37 20:59, Andrew Morton wrote:
> > Let me fix that for you.
> >
> > --- a/arch/x86/platform/olpc/olpc-xo15-sci.c~x86-olpc-xo15-sci-enable-lid-close-wakeup-control-through-sysfs-fix
> > +++ a/arch/x86/platform/olpc/olpc-xo15-sci.c
> > @@ -58,7 +58,8 @@ static ssize_t lid_wake_on_close_store(s
> >   				       const char *buf, size_t n)
> >   {
> >   	unsigned int val;
> > -	if (!sscanf(buf, "%u",&val) == 1)
> > +
> > +	if (sscanf(buf, "%u",&val) != 1)
> >   		return -EINVAL;
> >
> >   	set_lid_wake_behavior(!!val);
> >
> > It's kinda irritating that this will cheerfully accept bogus input of
> > the form "42foo".  This happens about eleven billion times in sysfs
> > write() handlers but afaik we've never implemented a nice
> > sysfs_int_from_buffer() thingy which handles all the possible errors.
> 
> I thought there was.
> 
> strict_strtoul() ?
> 

(that was replaced by kstrto*())

I was more thinking of the trailing \n problem.  But ksrtto*() appears
to treat "42\n" as "42" so yup, that's good.

(One could argue that a sysfs string handler should also strip leading
and trailing white space.  I'd disagree!)

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux