Messages in this thread | | | Subject | Re: [PATCH] staging: comedi: cast to (unsigned int *) | From | Ian Abbott <> | Date | Fri, 19 Feb 2021 09:31:16 +0000 |
| |
On 19/02/2021 09:03, David Laight wrote: >> It's kind of moot anyway because the patch is outdated. But the reason >> for the ___force is that the same `struct comedi_cmd` is used in both >> user and kernel contexts. In user contexts, the `chanlist` member >> points to user memory and in kernel contexts it points to kernel memory >> (copied from userspace). > > Can't you use a union of the user and kernel pointers? > (Possibly even anonymous?) > Although, ideally, keeping them in separate fields is better. > 8 bytes for a pointer isn't going make a fat lot of difference.
This is for a UAPI header (eventually), so cannot add a new field. For an anonymous union, one tagged with __user and one not, the __user tag would be removed during conversion from UAPI headers to /usr/include/linux headers, leaving a union of two identically typed members, which would look a bit odd. The union also kind of hides the problem.
-- -=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company )=- -=( registered in England & Wales. Regd. number: 02862268. )=- -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=- -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
| |