]> git.proxmox.com Git - mirror_frr.git/blame - tools/cocci.h
bgpd: pre-fix coccinelle hang points
[mirror_frr.git] / tools / cocci.h
CommitLineData
d62a17ae 1/* some of this stuff doesn't seem to parse properly in coccinelle
896014f4 2 */
52c6b0e2 3
d62a17ae 4#define DEFUN(funcname, cmdname, str, help) \
5 static int funcname(const struct cmd_element *self, struct vty *vty, \
6 int argc, struct cmd_token *argv[])
7#define DEFUN_HIDDEN(funcname, cmdname, str, help) \
8 static int funcname(const struct cmd_element *self, struct vty *vty, \
9 int argc, struct cmd_token *argv[])
52c6b0e2
DL
10
11#define ENABLE_BGP_VNC 1
d62a17ae 12#define ALL_LIST_ELEMENTS_RO(list, node, data) \
13 (node) = listhead(list), ((data) = NULL); \
14 (node) != NULL && ((data) = listgetdata(node)); \
15 (node) = listnextnode(node), ((data) = NULL)
16#define ALL_LIST_ELEMENTS(list, node, nextnode, data) \
17 (node) = listhead(list), ((data) = NULL); \
18 (node) != NULL \
19 && ((data) = listgetdata(node), (nextnode) = node->next); \
20 (node) = (nextnode), ((data) = NULL)
21#define LIST_HEAD(name, type) \
22 struct name { \
23 struct type *lh_first; /* first element */ \
24 }
25#define LIST_ENTRY(type) \
26 struct { \
27 struct type *le_next; /* next element */ \
28 struct type **le_prev; /* address of previous next element */ \
29 }
3f0cc3ff
QY
30
31#define STREAM_GETC(S, P) \
32 do { \
33 uint8_t _pval; \
34 if (!stream_getc2((S), &_pval)) \
35 goto stream_failure; \
36 (P) = _pval; \
37 } while (0)
38
39#define STREAM_GETW(S, P) \
40 do { \
41 uint16_t _pval; \
42 if (!stream_getw2((S), &_pval)) \
43 goto stream_failure; \
44 (P) = _pval; \
45 } while (0)
46
47#define STREAM_GETL(S, P) \
48 do { \
49 uint32_t _pval; \
50 if (!stream_getl2((S), &_pval)) \
51 goto stream_failure; \
52 (P) = _pval; \
53 } while (0)
54
55#define STREAM_GETF(S, P) \
56 do { \
57 union { \
58 float r; \
59 uint32_t d; \
60 } _pval; \
61 if (stream_getl2((S), &_pval.d)) \
62 goto stream_failure; \
63 (P) = _pval.r; \
64 } while (0)
65
66#define STREAM_GETQ(S, P) \
67 do { \
68 uint64_t _pval; \
69 if (!stream_getq2((S), &_pval)) \
70 goto stream_failure; \
71 (P) = _pval; \
72 } while (0)
73
74#define STREAM_GET(P, STR, SIZE) \
75 do { \
76 if (!stream_get2((P), (STR), (SIZE))) \
77 goto stream_failure; \
78 } while (0)
79
80#define AF_FOREACH(af) for ((af) = BGP_AF_START; (af) < BGP_AF_MAX; (af)++)
81
82#define FOREACH_AFI_SAFI(afi, safi) \
83 \
84 for (afi = AFI_IP; afi < AFI_MAX; afi++) \
85 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
86
87#define FOREACH_SAFI(safi) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)