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
6 Rename some list stuff to avoid namespace collision with libubox
8 control.c | 18 +++++++++---------
9 control.h | 12 ++++++------
10 lib/bmx7_tun/tun.c | 2 +-
11 list.c | 26 +++++++++++++-------------
12 list.h | 36 ++++++++++++++++++------------------
18 10 files changed, 55 insertions(+), 55 deletions(-)
20 diff --git a/control.c b/control.c
21 index ee9df30..9ab778d 100644
24 @@ -73,7 +73,7 @@ uint32_t My_pid = 0;
26 LIST_SIMPEL(ctrl_list, struct ctrl_node, list, list);
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];
32 static uint8_t debug_system_active = NO;
33 @@ -136,7 +136,7 @@ void add_dbgl_node(struct ctrl_node *cn, int dbgl)
37 - list_add_tail(&dbgl_clients[dbgl], &dn->list);
38 + bmx_list_add_tail(&dbgl_clients[dbgl], &dn->list);
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
44 struct ctrl_node *cn = debugMallocReset(sizeof(struct ctrl_node), -300010);
46 - list_add_tail(&ctrl_list, &cn->list);
47 + bmx_list_add_tail(&ctrl_list, &cn->list);
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)
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]))
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)
62 opt->d.parent_opt = tmp_opt;
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);
69 @@ -1017,7 +1017,7 @@ void register_option(struct opt_type *opt, const char * category_name)
73 - list_add_tail(&opt_list, &opt->d.list);
74 + bmx_list_add_tail(&opt_list, &opt->d.list);
78 @@ -1094,7 +1094,7 @@ struct opt_type *get_option(struct opt_type *parent_opt, uint8_t short_opt, char
80 struct list_node *list_pos;
82 - struct list_head *list;
83 + struct bmx_list_head *list;
84 struct opt_type *opt = 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)
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);
96 @@ -1347,7 +1347,7 @@ struct opt_parent *add_opt_parent(struct opt_type *opt)
98 LIST_INIT_HEAD(p->childs_instance_list, struct opt_child, list, list);
100 - list_add_tail(&opt->d.parents_instance_list, &p->list);
101 + bmx_list_add_tail(&opt->d.parents_instance_list, &p->list);
105 diff --git a/control.h b/control.h
106 index df0176f..4ef0854 100644
109 @@ -49,7 +49,7 @@ typedef uint32_t TIME_SEC_T;
111 extern int unix_sock;
113 -extern struct list_head ctrl_list;
114 +extern struct bmx_list_head ctrl_list;
116 extern int32_t Client_mode;
118 @@ -115,7 +115,7 @@ struct ctrl_node {
122 -extern struct list_head dbgl_clients[DBGL_MAX + 1];
123 +extern struct bmx_list_head dbgl_clients[DBGL_MAX + 1];
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
129 #define MAX_UNIX_MSG_SIZE 2000
131 -extern struct list_head opt_list;
132 +extern struct bmx_list_head opt_list;
136 @@ -292,7 +292,7 @@ struct opt_child {
138 struct list_node list;
140 - struct list_head childs_instance_list;
141 + struct bmx_list_head childs_instance_list;
145 @@ -311,9 +311,9 @@ struct opt_data {
147 struct opt_type *parent_opt; //REMOVE THIS and use casting instead !
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
152 - struct list_head parents_instance_list; //
153 + struct bmx_list_head parents_instance_list; //
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);
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);
170 diff --git a/list.c b/list.c
171 index 5e0665d..b698874 100644
175 * @head: list head of maintained nodes
176 * @node: a node maintained in the list or NULL
178 -void * list_iterate(struct list_head *head, void *node)
179 +void * list_iterate(struct bmx_list_head *head, void *node)
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);
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)
190 while ((node = list_iterate(head, node))) {
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
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)
200 new->next = head->next;
201 @@ -82,12 +82,12 @@ void list_add_head(struct list_head *head, struct list_node *new)
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
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)
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)
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)
223 new->next = ln->next;
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.
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)
232 assertion(-502641, (ln->next != (struct list_node*) head));
234 @@ -126,7 +126,7 @@ void list_del_next(struct list_head *head, struct list_node *ln)
238 -void *list_del_head(struct list_head *head)
239 +void *list_del_head(struct bmx_list_head *head)
241 if (LIST_EMPTY(head))
243 @@ -147,7 +147,7 @@ void *list_del_head(struct list_head *head)
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)
251 if (head->last == (struct list_node*)
252 @@ -169,17 +169,17 @@ static struct plist_node *plist_node_create(void *item)
256 -void plist_add_head(struct list_head *head, void *item)
257 +void plist_add_head(struct bmx_list_head *head, void *item)
259 list_add_head(head, &((plist_node_create(item))->list));
262 -void plist_add_tail(struct list_head *head, void *item)
263 +void plist_add_tail(struct bmx_list_head *head, void *item)
265 - list_add_tail(head, &((plist_node_create(item))->list));
266 + bmx_list_add_tail(head, &((plist_node_create(item))->list));
269 -void * plist_del_head(struct list_head *head)
270 +void * plist_del_head(struct bmx_list_head *head)
272 struct plist_node *pln = list_del_head(head);
274 diff --git a/list.h b/list.h
275 index d40306c..770dc9f 100644
287 @@ -36,7 +36,7 @@ struct list_node {
288 struct list_node *next;
292 +struct bmx_list_head {
293 struct list_node *next;
294 struct list_node *last;
296 @@ -52,7 +52,7 @@ struct plist_node {
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, \
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) ))
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);
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);
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 )
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);
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);
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.
350 @@ -109,7 +109,7 @@ void *plist_del_head(struct list_head *head);
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.
358 #define list_for_each(pos, head) \
359 @@ -123,8 +123,8 @@ void *plist_del_head(struct list_head *head);
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.
369 #define list_for_each_safe(pos, n, head) \
370 diff --git a/msg.h b/msg.h
371 index d36f6e2..b881cef 100644
374 @@ -357,7 +357,7 @@ struct tx_frame_iterator {
375 // MUST be initialized:
376 // remains unchanged:
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;
383 diff --git a/plugin.c b/plugin.c
384 index 5016956..102cdba 100644
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);
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)
394 cbn = list_entry(list_pos, struct cb_node, list);
396 @@ -82,7 +82,7 @@ void _set_thread_hook(int32_t cb_type, void (*cb_handler) (void), int8_t del, st
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);
405 @@ -103,7 +103,7 @@ void _set_thread_hook(int32_t cb_type, void (*cb_handler) (void), int8_t del, st
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);
414 @@ -261,7 +261,7 @@ int activate_plugin(struct plugin *p, void *dlhandle, const char *dl_name)
416 pn->dlhandle = dlhandle;
418 - list_add_tail(&plugin_list, &pn->list);
419 + bmx_list_add_tail(&plugin_list, &pn->list);
421 dbgf_all(DBGT_INFO, "%s SUCCESS", pn->plugin->plugin_name);
423 diff --git a/plugin.h b/plugin.h
424 index 5028d4e..b5c9727 100644
427 @@ -74,7 +74,7 @@ struct cb_fd_node {
428 void (*cb_fd_handler) (int32_t fd);
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
440 @@ -205,7 +205,7 @@ void task_register(TIME_T timeout, void (* task) (void *), void *data, int32_t t
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);
449 diff --git a/tun.h b/tun.h
450 index 06b8c6f..102ee87 100644
453 @@ -309,7 +309,7 @@ struct tunXin6_net_adv_list_node {
457 -extern struct list_head tunXin6_net_adv_list_list;
458 +extern struct bmx_list_head tunXin6_net_adv_list_list;
460 struct tun_bit_key_nodes {
461 struct tun_search_node *tsn;