pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/38081?usp=email )

Change subject: Clarify code around bts->loc_list
......................................................................

Clarify code around bts->loc_list

In set_bts_loc():
* Comment stating the entry was appended to the list was wrong.
* location_equal() could be called with lastloc containing poisoned
  pointers (INIT_LLIST_HEAD), which is not that nice.

Change-Id: I5b706dfd3a96f5e9b61907a727ef5887338e66c6
---
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/bts_ctrl.c
2 files changed, 6 insertions(+), 6 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index aa31505..777807b 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -3289,12 +3289,12 @@
        char timestr[50];

        llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
-               if (llist_empty(&bts->loc_list)) {
+               curloc = llist_first_entry_or_null(&bts->loc_list, struct 
bts_location, list);
+               if (!curloc) {
                        vty_out(vty, "BTS Nr: %d position invalid%s", bts->nr,
                                VTY_NEWLINE);
                        continue;
                }
-               curloc = llist_entry(bts->loc_list.next, struct bts_location, 
list);
                if (gmtime_r(&curloc->tstamp, &time) == NULL) {
                        vty_out(vty, "Time conversion failed for BTS %d%s", 
bts->nr,
                                VTY_NEWLINE);
diff --git a/src/osmo-bsc/bts_ctrl.c b/src/osmo-bsc/bts_ctrl.c
index f10ba29..48b1b8a 100644
--- a/src/osmo-bsc/bts_ctrl.c
+++ b/src/osmo-bsc/bts_ctrl.c
@@ -128,7 +128,7 @@
                return CTRL_CMD_REPLY;
        }

-       curloc = llist_entry(bts->loc_list.next, struct bts_location, list);
+       curloc = llist_first_entry(&bts->loc_list, struct bts_location, list);

        cmd->reply = talloc_asprintf(cmd, "%lu,%s,%f,%f,%f", curloc->tstamp,
                        get_value_string(bts_loc_fix_names, curloc->valid), 
curloc->lat, curloc->lon, curloc->height);
@@ -183,14 +183,14 @@
        curloc->height = atof(height);
        talloc_free(tmp);

-       lastloc = llist_entry(bts->loc_list.next, struct bts_location, list);
+       lastloc = llist_first_entry_or_null(&bts->loc_list, struct 
bts_location, list);

-       /* Add location to the end of the list */
+       /* Add location to the start of the list */
        llist_add(&curloc->list, &bts->loc_list);

        ret = get_bts_loc(cmd, data);

-       if (!location_equal(curloc, lastloc))
+       if (!lastloc || !location_equal(curloc, lastloc))
                bsc_gen_location_state_trap(bts);

        cleanup_locations(&bts->loc_list);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38081?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I5b706dfd3a96f5e9b61907a727ef5887338e66c6
Gerrit-Change-Number: 38081
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>

Reply via email to