On Thu, 2002-11-07 at 12:52, Ville Syrj�l� wrote: > On Thu, Nov 07, 2002 at 11:05:28AM +0800, Antonino Daplas wrote: > > On Thu, 2002-11-07 at 06:56, Ville Syrj�l� wrote: > > > The matroxfb patch that is included in DirectFB is broken. Here's a new > > > patch. get_user() usage was apparently wrong. So I threw it out and things > > > work a lot better. > > > > > > > Is there anything wrong with the following? > > > > int c > > > > if (get_user(c, (u32 *) arg) > > return -EFAULT; > > That's exactly what the patch had. But it needs a pointer as argument > which means an additional variable for simply passing a single number. > The DirectFB code simply calls ioctl(fd, FBIO_WAITFORVSYNC, 1) and since > the ioctl handler doesn't dereference the argument things shouldn't > explode right? If no argument is passed it will simply be some random
Pardon me, yes, you are correct that you can pass parameters by value via ioctl. However, passing a pointer and using the user access macros will give you defined behavior. If parameter is illegal, exit with an error, else proceed. If you pass by value and do not utilize the user access macros, you don't get any protection and you will get undefined behavior if an old application happen to not pass any. So (int) or (int *) are both correct depending on your usage. Note that using the ioctl macros will always default to pointers. Tony -- Info: To unsubscribe send a mail to [EMAIL PROTECTED] with "unsubscribe directfb-dev" as subject.
