[PATCH v2] input: constify valuators passed in by input drivers.

Adam Jackson ajax at nwnk.net
Tue Aug 10 06:58:03 PDT 2010


On Tue, 2010-08-10 at 15:05 +1000, Daniel Stone wrote:
> On Tue, Aug 10, 2010 at 01:59:13PM +1000, Peter Hutterer wrote:
> > GPE modifies the valuators array passed in. Which means any driver using
> > e.g. xf86PostButtonEventP(..., valuators) twice to emulate a button click
> > will provide garbage data on the second run.
> > 
> > Constify the argument, and do the same for keyboard and proximity events.
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > Changes to v1:
> > - valuators array malloc'ed now instead of the previous 
> >   "int valuators[num_valuators]"
> 
> malloc() in a signal handler ftl - I guess you could just have a
> static int copied_valuators[MAX_VALUATORS].

No need for "static" keyword unless you actually want to have them stick
around across invocations.  I don't think you do.

I hate to ever recommend alloca(), but this is actually a reasonable
place to use it if you do

    valuators = alloca(sizeof(int) * min(num_valuators, MAX_VALUATORS));

If you're ever failing to allocate 144 bytes on the stack you're already
in a very bad place.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100810/b99298e7/attachment-0001.pgp>


More information about the xorg-devel mailing list