why not choose another way to define the _IOC_xxxMASK related to the ioctl

RS tinyshrimp at 163.com
Sat Mar 30 01:47:15 EDT 2013


it defines in the kernel:  #define _IOC_NRMASK	((1 << _IOC_NRBITS)-1)   //define  ...  #define _IOC_NRSHIFT	0  ...  #define _IOC_DIR(nr)		(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)  //when decode

why not define it like this:
  #define _IOC_NRSHIFT	0
  ...
  #define _IOC_NRMASK ((_IOC_NRSHIFT >> _IOC_NRBITS) - _IOC_NRSHIFT)   //define
  ...
  #define _IOC_DIR(nr)        ((nr &  _IOC_DIRMASK) >> _IOC_DIRSHIFT)  // when decode


I think it is better for the word "mask" . 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130330/d0df0713/attachment.html 


More information about the Kernelnewbies mailing list