summaryrefslogtreecommitdiffstats
path: root/src/seastar/dpdk/devtools/cocci/mtod-offset.cocci
blob: 13134e9dffbb623c64f231cbca033f90f83158c6 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().
//
@disable paren@
typedef uint8_t;
expression M, O;
@@
(
- rte_pktmbuf_mtod(M, char *) + O
+ rte_pktmbuf_mtod_offset(M, char *, O)
|
- rte_pktmbuf_mtod(M, char *) - O
+ rte_pktmbuf_mtod_offset(M, char *, -O)
|
- rte_pktmbuf_mtod(M, unsigned char *) + O
+ rte_pktmbuf_mtod_offset(M, unsigned char *, O)
|
- rte_pktmbuf_mtod(M, unsigned char *) - O
+ rte_pktmbuf_mtod_offset(M, unsigned char *, -O)
|
- rte_pktmbuf_mtod(M, uint8_t *) + O
+ rte_pktmbuf_mtod_offset(M, uint8_t *, O)
|
- rte_pktmbuf_mtod(M, uint8_t *) - O
+ rte_pktmbuf_mtod_offset(M, uint8_t *, -O)
)


//
// Fold subsequent offset terms into pre-existing offset used in
// rte_pktmbuf_mtod_offset().
//
@disable paren@
expression M, O1, O2;
@@
(
- rte_pktmbuf_mtod_offset(M, char *, O1) + O2
+ rte_pktmbuf_mtod_offset(M, char *, O1 + O2)
|
- rte_pktmbuf_mtod_offset(M, char *, O1) - O2
+ rte_pktmbuf_mtod_offset(M, char *, O1 - O2)
|
- rte_pktmbuf_mtod_offset(M, unsigned char *, O1) + O2
+ rte_pktmbuf_mtod_offset(M, unsigned char *, O1 + O2)
|
- rte_pktmbuf_mtod_offset(M, unsigned char *, O1) - O2
+ rte_pktmbuf_mtod_offset(M, unsigned char *, O1 - O2)
|
- rte_pktmbuf_mtod_offset(M, uint8_t *, O1) + O2
+ rte_pktmbuf_mtod_offset(M, uint8_t *, O1 + O2)
|
- rte_pktmbuf_mtod_offset(M, uint8_t *, O1) - O2
+ rte_pktmbuf_mtod_offset(M, uint8_t *, O1 - O2)
)


//
// Cleanup rules.  Fold in double casts, remove unnecessary paranthesis, etc.
//
@disable paren@
expression M, O;
type C, T;
@@
(
- (C)rte_pktmbuf_mtod_offset(M, T, O)
+ rte_pktmbuf_mtod_offset(M, C, O)
|
- (rte_pktmbuf_mtod_offset(M, T, O))
+ rte_pktmbuf_mtod_offset(M, T, O)
|
- (C)rte_pktmbuf_mtod(M, T)
+ rte_pktmbuf_mtod(M, C)
|
- (rte_pktmbuf_mtod(M, T))
+ rte_pktmbuf_mtod(M, T)
)