On Tue, Sep 16, 2014 at 10:17:18AM +0800, Fengguang Wu wrote: > I could disable this warning in my reports, but CC sparse authors > first to check if there are more elegant solutions. int main(void) { printf("%x\n", (unsigned short)~(0xc00)); // <-- ok printf("%x\n", (unsigned short)~(0xc000)); // <-- complains return 0; } test.c:10:40: warning: cast truncates bits from constant value (ffff3fff becomes 3fff) The reason the first one is ok is because we don't complain if the truncated bits are purely sign bits. I feel like it should apply to the second statement as well. If we're only masking out 0xffff then don't complain. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html