Linus Torvalds writes: (Summary) wrote:
I don't know if clang actually already gets this right or not, but as an example of a case where we have a semantic difference between "is this a constant or not", a much simpler case is in this a constant or not", a much simpler case is in - arch/x86/include/asm/uaccess.h:
- arch/x86/include/asm/uaccess.h:
[...]
keep our compiler folks (halfway) sane?I don't know if clang actually already gets this right or not, but as an example of a case where we have a semantic difference between "is this a constant or not", a much simpler case is in this a constant or not", a much simpler case is in - arch/x86/include/asm/uaccess.h:
- arch/x86/include/asm/uaccess.h:
/* * Test whether a block of memory is a valid user space address. */ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, unsigned long limit) { /* * If we have used "sizeof()" for the size, * we know it won't overflow the limit (but * it might overflow the 'addr', so it's * important to subtract the size from the * limit, not add it to the address).