blob: 77927f49b51aa53d70fac921eb973a95c7f7aa6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#define __bitwise __attribute__((bitwise))
#define __force __attribute__((force))
typedef unsigned int u32;
typedef unsigned int __bitwise __be32;
static __be32* tobi(u32 *x)
{
return x; // should warn, implicit cast
}
static __be32* tobe(u32 *x)
{
return (__be32 *) x; // should warn, explicit cast
}
static __be32* tobf(u32 *x)
{
return (__force __be32 *) x; // should not warn, forced cast
return (__be32 __force *) x; // should not warn, forced cast
}
/*
* check-name: cast of bitwise pointers
* check-command: sparse -Wbitwise -Wbitwise-pointer $file
*
* check-error-start
bitwise-cast-ptr.c:9:16: warning: incorrect type in return expression (different base types)
bitwise-cast-ptr.c:9:16: expected restricted __be32 [usertype] *
bitwise-cast-ptr.c:9:16: got unsigned int [usertype] *x
bitwise-cast-ptr.c:14:17: warning: cast to restricted __be32 [usertype] *
* check-error-end
*/
|