Merge pull request #446 from ecsv/batadv-2019.0
[feed/routing.git] / bmx7 / patches / 100-rename-list_add_tail-and-struct-list_head.patch
1 From 53f5a6ef74acff4c7294f4346a3d88fa04ad49c9 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Tue, 14 Aug 2018 12:19:49 +0200
4 Subject: [PATCH] rename list_add_tail and struct list_head
5
6 Rename some list stuff to avoid namespace collision with libubox
7 ---
8 control.c | 18 +++++++++---------
9 control.h | 12 ++++++------
10 lib/bmx7_tun/tun.c | 2 +-
11 list.c | 26 +++++++++++++-------------
12 list.h | 36 ++++++++++++++++++------------------
13 msg.h | 2 +-
14 plugin.c | 8 ++++----
15 plugin.h | 2 +-
16 schedule.c | 2 +-
17 tun.h | 2 +-
18 10 files changed, 55 insertions(+), 55 deletions(-)
19
20 diff --git a/control.c b/control.c
21 index ee9df30..9ab778d 100644
22 --- a/control.c
23 +++ b/control.c
24 @@ -73,7 +73,7 @@ uint32_t My_pid = 0;
25
26 LIST_SIMPEL(ctrl_list, struct ctrl_node, list, list);
27
28 -struct list_head dbgl_clients[DBGL_MAX + 1];
29 +struct bmx_list_head dbgl_clients[DBGL_MAX + 1];
30 static struct dbg_histogram dbgl_history[2][DBG_HIST_SIZE];
31
32 static uint8_t debug_system_active = NO;
33 @@ -136,7 +136,7 @@ void add_dbgl_node(struct ctrl_node *cn, int dbgl)
34
35 dn->cn = cn;
36 cn->dbgl = dbgl;
37 - list_add_tail(&dbgl_clients[dbgl], &dn->list);
38 + bmx_list_add_tail(&dbgl_clients[dbgl], &dn->list);
39
40 if (dbgl == DBGL_SYS || dbgl == DBGL_CHANGES) {
41 dbgf_all(DBGT_INFO, "resetting muted dbg history");
42 @@ -255,7 +255,7 @@ struct ctrl_node *create_ctrl_node(int fd, void (*cn_fd_handler) (struct ctrl_no
43 {
44 struct ctrl_node *cn = debugMallocReset(sizeof(struct ctrl_node), -300010);
45
46 - list_add_tail(&ctrl_list, &cn->list);
47 + bmx_list_add_tail(&ctrl_list, &cn->list);
48
49 cn->fd = fd;
50 cn->cn_fd_handler = cn_fd_handler;
51 @@ -571,7 +571,7 @@ void debug_output(uint32_t check_len, struct ctrl_node *cn, int8_t dbgl, int8_t
52 if (level == DBGL_SYS && mute_dbgl_sys == DBG_HIST_MUTED)
53 continue;
54
55 - list_for_each(list_pos, /*(struct list_head *)*/&(dbgl_clients[level]))
56 + list_for_each(list_pos, /*(struct bmx_list_head *)*/&(dbgl_clients[level]))
57 {
58
59 struct dbgl_node *dn = list_entry(list_pos, struct dbgl_node, list);
60 @@ -990,7 +990,7 @@ void register_option(struct opt_type *opt, const char * category_name)
61
62 opt->d.parent_opt = tmp_opt;
63
64 - list_add_tail(&tmp_opt->d.childs_type_list, &opt->d.list);
65 + bmx_list_add_tail(&tmp_opt->d.childs_type_list, &opt->d.list);
66
67 } else {
68
69 @@ -1017,7 +1017,7 @@ void register_option(struct opt_type *opt, const char * category_name)
70 }
71
72 if (!tmp_opt)
73 - list_add_tail(&opt_list, &opt->d.list);
74 + bmx_list_add_tail(&opt_list, &opt->d.list);
75
76 }
77
78 @@ -1094,7 +1094,7 @@ struct opt_type *get_option(struct opt_type *parent_opt, uint8_t short_opt, char
79
80 struct list_node *list_pos;
81 int32_t len = 0;
82 - struct list_head *list;
83 + struct bmx_list_head *list;
84 struct opt_type *opt = NULL;
85 char *equalp = NULL;
86 char s[MAX_ARG_SIZE] = "";
87 @@ -1305,7 +1305,7 @@ struct opt_child *add_opt_child(struct opt_type *opt, struct opt_parent *p)
88
89 c->opt = opt;
90 c->parent_instance = p;
91 - list_add_tail(&p->childs_instance_list, &c->list);
92 + bmx_list_add_tail(&p->childs_instance_list, &c->list);
93
94 return c;
95 }
96 @@ -1347,7 +1347,7 @@ struct opt_parent *add_opt_parent(struct opt_type *opt)
97
98 LIST_INIT_HEAD(p->childs_instance_list, struct opt_child, list, list);
99
100 - list_add_tail(&opt->d.parents_instance_list, &p->list);
101 + bmx_list_add_tail(&opt->d.parents_instance_list, &p->list);
102
103 return p;
104 }
105 diff --git a/control.h b/control.h
106 index df0176f..4ef0854 100644
107 --- a/control.h
108 +++ b/control.h
109 @@ -49,7 +49,7 @@ typedef uint32_t TIME_SEC_T;
110
111 extern int unix_sock;
112
113 -extern struct list_head ctrl_list;
114 +extern struct bmx_list_head ctrl_list;
115
116 extern int32_t Client_mode;
117
118 @@ -115,7 +115,7 @@ struct ctrl_node {
119 int8_t dbgl;
120 };
121
122 -extern struct list_head dbgl_clients[DBGL_MAX + 1];
123 +extern struct bmx_list_head dbgl_clients[DBGL_MAX + 1];
124
125 struct dbgl_node {
126 struct list_node list;
127 @@ -227,7 +227,7 @@ struct ctrl_node *create_ctrl_node(int fd, void (*cn_fd_handler) (struct ctrl_no
128
129 #define MAX_UNIX_MSG_SIZE 2000
130
131 -extern struct list_head opt_list;
132 +extern struct bmx_list_head opt_list;
133
134
135 /* opt_t types:
136 @@ -292,7 +292,7 @@ struct opt_child {
137 struct opt_parent {
138 struct list_node list;
139
140 - struct list_head childs_instance_list;
141 + struct bmx_list_head childs_instance_list;
142
143 char *val; //key
144
145 @@ -311,9 +311,9 @@ struct opt_data {
146
147 struct opt_type *parent_opt; //REMOVE THIS and use casting instead !
148
149 - struct list_head childs_type_list; //if this opt is a section type, then further sub-opts types can be listed here
150 + struct bmx_list_head childs_type_list; //if this opt is a section type, then further sub-opts types can be listed here
151
152 - struct list_head parents_instance_list; //
153 + struct bmx_list_head parents_instance_list; //
154 };
155
156 struct opt_type {
157 diff --git a/lib/bmx7_tun/tun.c b/lib/bmx7_tun/tun.c
158 index 2aa740c..265c47a 100644
159 --- a/lib/bmx7_tun/tun.c
160 +++ b/lib/bmx7_tun/tun.c
161 @@ -126,7 +126,7 @@ void set_tunXin6_net_adv_list_handl(uint8_t del, void **adv_list_ptr)
162 n = debugMallocReset(sizeof( struct tunXin6_net_adv_list_node), -300517);
163
164 n->adv_list = adv_list;
165 - list_add_tail((&tunXin6_net_adv_list_list), &n->list);
166 + bmx_list_add_tail((&tunXin6_net_adv_list_list), &n->list);
167 }
168
169 STATIC_FUNC
170 diff --git a/list.c b/list.c
171 index 5e0665d..b698874 100644
172 --- a/list.c
173 +++ b/list.c
174 @@ -39,7 +39,7 @@
175 * @head: list head of maintained nodes
176 * @node: a node maintained in the list or NULL
177 */
178 -void * list_iterate(struct list_head *head, void *node)
179 +void * list_iterate(struct bmx_list_head *head, void *node)
180 {
181 struct list_node *ln = (node ?
182 ((struct list_node*) (((char*) node) + head->list_node_offset)) :
183 @@ -53,7 +53,7 @@ void * list_iterate(struct list_head *head, void *node)
184 return(((char*) ln->next) - head->list_node_offset);
185 }
186
187 -void *list_find_next(struct list_head *head, void* key, void *node)
188 +void *list_find_next(struct bmx_list_head *head, void* key, void *node)
189 {
190 while ((node = list_iterate(head, node))) {
191
192 @@ -68,7 +68,7 @@ void *list_find_next(struct list_head *head, void* key, void *node)
193 * @head: list head to add it after
194 * @new: new entry to be added
195 */
196 -void list_add_head(struct list_head *head, struct list_node *new)
197 +void list_add_head(struct bmx_list_head *head, struct list_node *new)
198 {
199
200 new->next = head->next;
201 @@ -82,12 +82,12 @@ void list_add_head(struct list_head *head, struct list_node *new)
202 }
203
204 /**
205 - * list_add_tail - add a new entry
206 + * bmx_list_add_tail - add a new entry
207 * @head: list head to add it before
208 * @new: new entry to be added
209 */
210
211 -void list_add_tail(struct list_head *head, struct list_node *new)
212 +void bmx_list_add_tail(struct bmx_list_head *head, struct list_node *new)
213 {
214 new->next = (struct list_node *) head;
215 head->last->next = new;
216 @@ -96,7 +96,7 @@ void list_add_tail(struct list_head *head, struct list_node *new)
217 head->items++;
218 }
219
220 -void list_add_after(struct list_head *head, struct list_node *ln, struct list_node *new)
221 +void list_add_after(struct bmx_list_head *head, struct list_node *ln, struct list_node *new)
222 {
223 new->next = ln->next;
224 ln->next = new;
225 @@ -112,7 +112,7 @@ void list_add_after(struct list_head *head, struct list_node *ln, struct list_no
226 * @entry: the element to delete from the list.
227 * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
228 */
229 -void list_del_next(struct list_head *head, struct list_node *ln)
230 +void list_del_next(struct bmx_list_head *head, struct list_node *ln)
231 {
232 assertion(-502641, (ln->next != (struct list_node*) head));
233
234 @@ -126,7 +126,7 @@ void list_del_next(struct list_head *head, struct list_node *ln)
235 head->items--;
236 }
237
238 -void *list_del_head(struct list_head *head)
239 +void *list_del_head(struct bmx_list_head *head)
240 {
241 if (LIST_EMPTY(head))
242 return NULL;
243 @@ -147,7 +147,7 @@ void *list_del_head(struct list_head *head)
244 */
245
246 /* UNTESTED
247 -void * plist_iterate(struct list_head *head, struct plist_node **pln)
248 +void * plist_iterate(struct bmx_list_head *head, struct plist_node **pln)
249 {
250
251 if (head->last == (struct list_node*)
252 @@ -169,17 +169,17 @@ static struct plist_node *plist_node_create(void *item)
253 return plh;
254 }
255
256 -void plist_add_head(struct list_head *head, void *item)
257 +void plist_add_head(struct bmx_list_head *head, void *item)
258 {
259 list_add_head(head, &((plist_node_create(item))->list));
260 }
261
262 -void plist_add_tail(struct list_head *head, void *item)
263 +void plist_add_tail(struct bmx_list_head *head, void *item)
264 {
265 - list_add_tail(head, &((plist_node_create(item))->list));
266 + bmx_list_add_tail(head, &((plist_node_create(item))->list));
267 }
268
269 -void * plist_del_head(struct list_head *head)
270 +void * plist_del_head(struct bmx_list_head *head)
271 {
272 struct plist_node *pln = list_del_head(head);
273
274 diff --git a/list.h b/list.h
275 index d40306c..770dc9f 100644
276 --- a/list.h
277 +++ b/list.h
278 @@ -28,7 +28,7 @@
279
280
281 #ifndef _LIST_H
282 -#define _LIST_H
283 +#define _LIST_H_
284
285 #include <stdint.h>
286
287 @@ -36,7 +36,7 @@ struct list_node {
288 struct list_node *next;
289 };
290
291 -struct list_head {
292 +struct bmx_list_head {
293 struct list_node *next;
294 struct list_node *last;
295 uint16_t items;
296 @@ -52,7 +52,7 @@ struct plist_node {
297
298
299
300 -#define LIST_SIMPEL(ptr, element_type, list_field, key_field ) struct list_head ptr = { \
301 +#define LIST_SIMPEL(ptr, element_type, list_field, key_field ) struct bmx_list_head ptr = { \
302 .next = (struct list_node *)&ptr, \
303 .last = (struct list_node *)&ptr, \
304 .items = 0, \
305 @@ -75,14 +75,14 @@ struct plist_node {
306 #define list_get_first(head) ((void*)((LIST_EMPTY(head)) ? NULL : (((char*) (head)->next) - (head)->list_node_offset) ))
307 #define list_get_last(head) ((void*)((LIST_EMPTY(head)) ? NULL : (((char*) (head)->last) - (head)->list_node_offset) ))
308
309 -void *list_iterate(struct list_head *head, void *node);
310 -void *list_find_next(struct list_head *head, void* key, void *node);
311 +void *list_iterate(struct bmx_list_head *head, void *node);
312 +void *list_find_next(struct bmx_list_head *head, void* key, void *node);
313
314 -void list_add_head(struct list_head *head, struct list_node * new);
315 -void list_add_tail(struct list_head *head, struct list_node * new);
316 -void list_add_after(struct list_head *head, struct list_node *pos, struct list_node * new);
317 -void list_del_next(struct list_head *head, struct list_node *pos);
318 -void *list_del_head(struct list_head *head);
319 +void list_add_head(struct bmx_list_head *head, struct list_node * new);
320 +void bmx_list_add_tail(struct bmx_list_head *head, struct list_node * new);
321 +void list_add_after(struct bmx_list_head *head, struct list_node *pos, struct list_node * new);
322 +void list_del_next(struct bmx_list_head *head, struct list_node *pos);
323 +void *list_del_head(struct bmx_list_head *head);
324
325
326 #define plist_get_first(head) (LIST_EMPTY(head) ? NULL : \
327 @@ -91,17 +91,17 @@ void *list_del_head(struct list_head *head);
328 #define plist_get_last(head) (LIST_EMPTY(head) ? NULL : \
329 ((struct plist_node*)(((char*) (head)->prev) - (head)->list_node_offset))-item )
330
331 -void * plist_iterate(struct list_head *head, struct plist_node **pln);
332 +void * plist_iterate(struct bmx_list_head *head, struct plist_node **pln);
333
334 -void plist_add_head(struct list_head *head, void *item);
335 -void plist_add_tail(struct list_head *head, void *item);
336 -void *plist_del_head(struct list_head *head);
337 +void plist_add_head(struct bmx_list_head *head, void *item);
338 +void plist_add_tail(struct bmx_list_head *head, void *item);
339 +void *plist_del_head(struct bmx_list_head *head);
340
341
342
343 /**
344 * list_entry - get the struct for this entry
345 - * @ptr: the &struct list_head pointer.
346 + * @ptr: the &struct bmx_list_head pointer.
347 * @type: the type of the struct this is embedded in.
348 * @member: the name of the list_struct within the struct.
349 */
350 @@ -109,7 +109,7 @@ void *plist_del_head(struct list_head *head);
351
352 /**
353 * list_for_each - iterate over a list
354 - * @pos: the &struct list_head to use as a loop counter.
355 + * @pos: the &struct bmx_list_head to use as a loop counter.
356 * @head: the head for your list.
357 */
358 #define list_for_each(pos, head) \
359 @@ -123,8 +123,8 @@ void *plist_del_head(struct list_head *head);
360
361 /**
362 * list_for_each_safe - iterate over a list safe against removal of list entry
363 - * @pos: the &struct list_head to use as a loop counter.
364 - * @n: another &struct list_head to use as temporary storage
365 + * @pos: the &struct bmx_list_head to use as a loop counter.
366 + * @n: another &struct bmx_list_head to use as temporary storage
367 * @head: the head for your list.
368 */
369 #define list_for_each_safe(pos, n, head) \
370 diff --git a/msg.h b/msg.h
371 index d36f6e2..b881cef 100644
372 --- a/msg.h
373 +++ b/msg.h
374 @@ -357,7 +357,7 @@ struct tx_frame_iterator {
375 // MUST be initialized:
376 // remains unchanged:
377 const char *caller;
378 - struct list_head *tx_task_list;
379 + struct bmx_list_head *tx_task_list;
380 struct tx_task_node *ttn;
381 // struct desc_contents *descContents;
382 struct frame_db *db;
383 diff --git a/plugin.c b/plugin.c
384 index 5016956..102cdba 100644
385 --- a/plugin.c
386 +++ b/plugin.c
387 @@ -74,7 +74,7 @@ void _set_thread_hook(int32_t cb_type, void (*cb_handler) (void), int8_t del, st
388 cleanup_all(-500143);
389 }
390
391 - list_for_each_safe(list_pos, tmp_pos, (struct list_head*) cb_list)
392 + list_for_each_safe(list_pos, tmp_pos, (struct bmx_list_head*) cb_list)
393 {
394 cbn = list_entry(list_pos, struct cb_node, list);
395
396 @@ -82,7 +82,7 @@ void _set_thread_hook(int32_t cb_type, void (*cb_handler) (void), int8_t del, st
397
398 if (del) {
399
400 - list_del_next(((struct list_head*) cb_list), prev_pos);
401 + list_del_next(((struct bmx_list_head*) cb_list), prev_pos);
402 debugFree(cbn, -300069);
403 return;
404
405 @@ -103,7 +103,7 @@ void _set_thread_hook(int32_t cb_type, void (*cb_handler) (void), int8_t del, st
406
407 cbn->cb_type = cb_type;
408 cbn->cb_handler = cb_handler;
409 - list_add_tail(((struct list_head*) cb_list), &cbn->list);
410 + bmx_list_add_tail(((struct bmx_list_head*) cb_list), &cbn->list);
411
412 }
413
414 @@ -261,7 +261,7 @@ int activate_plugin(struct plugin *p, void *dlhandle, const char *dl_name)
415 pn->plugin = p;
416 pn->dlhandle = dlhandle;
417
418 - list_add_tail(&plugin_list, &pn->list);
419 + bmx_list_add_tail(&plugin_list, &pn->list);
420
421 dbgf_all(DBGT_INFO, "%s SUCCESS", pn->plugin->plugin_name);
422
423 diff --git a/plugin.h b/plugin.h
424 index 5028d4e..b5c9727 100644
425 --- a/plugin.h
426 +++ b/plugin.h
427 @@ -74,7 +74,7 @@ struct cb_fd_node {
428 void (*cb_fd_handler) (int32_t fd);
429 };
430
431 -extern struct list_head cb_fd_list;
432 +extern struct bmx_list_head cb_fd_list;
433 // cb_fd_handler is called when fd received data
434 // called function may remove itself
435 void set_fd_hook(int32_t fd, void (*cb_fd_handler) (int32_t fd), int8_t del);
436 diff --git a/schedule.c b/schedule.c
437 index 8e3f7a6..8868b01 100644
438 --- a/schedule.c
439 +++ b/schedule.c
440 @@ -205,7 +205,7 @@ void task_register(TIME_T timeout, void (* task) (void *), void *data, int32_t t
441 }
442
443 if ((tmp_tn == NULL) || (U32_LE(tmp_tn->expire, tn->expire)))
444 - list_add_tail(&task_list, &tn->list);
445 + bmx_list_add_tail(&task_list, &tn->list);
446
447 }
448
449 diff --git a/tun.h b/tun.h
450 index 06b8c6f..102ee87 100644
451 --- a/tun.h
452 +++ b/tun.h
453 @@ -309,7 +309,7 @@ struct tunXin6_net_adv_list_node {
454 };
455
456
457 -extern struct list_head tunXin6_net_adv_list_list;
458 +extern struct bmx_list_head tunXin6_net_adv_list_list;
459
460 struct tun_bit_key_nodes {
461 struct tun_search_node *tsn;