db/fixup_kernel.sh: update vfs_write() code
[smatch.git] / validation / bitwise-cast-ptr.c
blob77927f49b51aa53d70fac921eb973a95c7f7aa6c
1 #define __bitwise __attribute__((bitwise))
2 #define __force __attribute__((force))
4 typedef unsigned int u32;
5 typedef unsigned int __bitwise __be32;
7 static __be32* tobi(u32 *x)
9 return x; // should warn, implicit cast
12 static __be32* tobe(u32 *x)
14 return (__be32 *) x; // should warn, explicit cast
17 static __be32* tobf(u32 *x)
19 return (__force __be32 *) x; // should not warn, forced cast
20 return (__be32 __force *) x; // should not warn, forced cast
24 * check-name: cast of bitwise pointers
25 * check-command: sparse -Wbitwise -Wbitwise-pointer $file
27 * check-error-start
28 bitwise-cast-ptr.c:9:16: warning: incorrect type in return expression (different base types)
29 bitwise-cast-ptr.c:9:16: expected restricted __be32 [usertype] *
30 bitwise-cast-ptr.c:9:16: got unsigned int [usertype] *x
31 bitwise-cast-ptr.c:14:17: warning: cast to restricted __be32 [usertype] *
32 * check-error-end