On 7/31/2020 8:44 AM, Xiang Xiao wrote:
Macro version still evaluate the argument more than once regardless you name it 
kisdigit or isdigit. I am fine with any following combination:
1.lookup table for both userspace and kernel
2.normal function for both userspace and kernel
3.lookup table for userspace and normal function for kernel
But Macro which can't guarantee to evaluate the argument only once isn't a good 
candidate even it is just used in kernel space.

#3 seems fine.  Personally, I am not opposed to the allowing the argument to be re-evaluated within the kernel.  It is not an environment for the casual user and there are are only a half dozen or so uses of ctype functions.  And we already have dozens of other cases:

This definitions appears in 107 files:

   #define MIN(a,b) (((a) < (b)) ? (a) : (b))

And this appears in 85 files:

   #define MAX(a,b) (((a) > (b)) ? (a) : (b))

I do want to make the user environment as safe and as usable as possible, but programming within the OS is not for the weak at heart.  But #3 seems fine to me also.


Reply via email to