diff options
author | Harald Welte <laforge@osmocom.org> | 2020-06-29 14:51:19 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2020-06-29 22:12:42 +0200 |
commit | 760097bfb0a49a492719c0ee6c1633097c6980ed (patch) | |
tree | 18ca2045f04c662e7804fa3dd7d63659ff30229e | |
parent | 9144ba03738504d770a8cf3a644f64a14ebd7e8b (diff) |
change list ordering for list of interfaces / lines
By using llist_add_tail(), we add new elements at the end of the list,
rather than inserting at front. Among other things, this has the added
benefit that when the VTY prints information on lines, they are printed
in numerically ascending orrder (0,1,2, ...) and not the reverse.
Change-Id: I07a6ba706f855a29b4e33b1a6b008e0d2f11b6f3
-rw-r--r-- | src/intf_line.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/intf_line.c b/src/intf_line.c index bc01559..c3466e0 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -54,11 +54,11 @@ e1_intf_new(struct e1_daemon *e1d, void *drv_data) INIT_LLIST_HEAD(&intf->lines); if (!llist_empty(&e1d->interfaces)) { - struct e1_intf *f = llist_first_entry(&e1d->interfaces, struct e1_intf, list); + struct e1_intf *f = llist_last_entry(&e1d->interfaces, struct e1_intf, list); intf->id = f->id + 1; } - llist_add(&intf->list, &e1d->interfaces); + llist_add_tail(&intf->list, &e1d->interfaces); return intf; } @@ -80,11 +80,11 @@ e1_line_new(struct e1_intf *intf, void *drv_data) INIT_LLIST_HEAD(&line->list); if (!llist_empty(&intf->lines)) { - struct e1_line *l = llist_first_entry(&intf->lines, struct e1_line, list); + struct e1_line *l = llist_last_entry(&intf->lines, struct e1_line, list); line->id = l->id + 1; } - llist_add(&line->list, &intf->lines); + llist_add_tail(&line->list, &intf->lines); return line; } |