12 /* Explicit cast of 0, legal */
13 static __be32 bar(void)
14 {
15 return (__be32)0;
16 }
17
18 /* Implicit casts of nonzero, bad */
19 static __be32 baz(void)
20 {
21 __be32 x = 0x2a;
22
23 return 99;
24 }
25
26 /* Explicit cast of nonzero, bad */
27 static __be32 quux(void)
28 {
29 return (__be32)1729;
30 }
31
32 /*
33 * check-name: conversions to bitwise types
34 * check-command: sparse -Wbitwise $file
35 * check-error-start
36 bitwise-cast.c:21:20: warning: incorrect type in initializer (different base types)
37 bitwise-cast.c:21:20: expected restricted __be32 [usertype] x
38 bitwise-cast.c:21:20: got int
39 bitwise-cast.c:23:16: warning: incorrect type in return expression (different base types)
40 bitwise-cast.c:23:16: expected restricted __be32
41 bitwise-cast.c:23:16: got int
42 bitwise-cast.c:29:17: warning: cast to restricted __be32
43 * check-error-end
44 */
|
12 /* Explicit cast of 0, legal */
13 static __be32 bar(void)
14 {
15 return (__be32)0;
16 }
17
18 /* Implicit casts of nonzero, bad */
19 static __be32 baz(void)
20 {
21 __be32 x = 0x2a;
22
23 return 99;
24 }
25
26 /* Explicit cast of nonzero, bad */
27 static __be32 quux(void)
28 {
29 return (__be32)1729;
30 }
31
32 /* Explicit case of nonzero forced, legal */
33 static __be32 quuy(void)
34 {
35 return (__attribute__((force)) __be32) 1730;
36 }
37
38 /*
39 * check-name: conversions to bitwise types
40 * check-command: sparse -Wbitwise $file
41 * check-error-start
42 bitwise-cast.c:21:20: warning: incorrect type in initializer (different base types)
43 bitwise-cast.c:21:20: expected restricted __be32 [usertype] x
44 bitwise-cast.c:21:20: got int
45 bitwise-cast.c:23:16: warning: incorrect type in return expression (different base types)
46 bitwise-cast.c:23:16: expected restricted __be32
47 bitwise-cast.c:23:16: got int
48 bitwise-cast.c:29:17: warning: cast to restricted __be32
49 * check-error-end
50 */
|