[MERGED] osmo-bsc[master]: libcommon: eliminate talloc_ctx.c

2018-02-14 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: libcommon: eliminate talloc_ctx.c
..


libcommon: eliminate talloc_ctx.c

Interestingly enough, talloc_ctx_init() actually had not a single caller.

While dropping it, see to it that the few contexts that are actually used in
osmo-bsc.git are indeed initialized in all the main scopes.

Also initialize two void* ctxts as NULL explicitly, to allocate under the NULL
context in case some main scope forgets to branch it off another root context.
(That's bsc, fle and paging, all others actually come in from other libraries.)

Change-Id: I344a3d07e146999e154824837ed95db2b9879356
---
M src/ipaccess/ipaccess-proxy.c
M src/libbsc/abis_nm.c
M src/libbsc/paging.c
M src/libcommon/Makefile.am
M src/libcommon/gsm_data.c
D src/libcommon/talloc_ctx.c
M src/osmo-bsc/osmo_bsc_main.c
M src/osmo-bsc_nat/bsc_nat.c
M src/utils/bs11_config.c
9 files changed, 24 insertions(+), 56 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/ipaccess/ipaccess-proxy.c b/src/ipaccess/ipaccess-proxy.c
index 5cf6d6d..d44cdf2 100644
--- a/src/ipaccess/ipaccess-proxy.c
+++ b/src/ipaccess/ipaccess-proxy.c
@@ -121,7 +121,7 @@
 };
 
 /* some of the code against we link from OpenBSC needs this */
-void *tall_bsc_ctx;
+void *tall_bsc_ctx = NULL;
 
 static char *listen_ipaddr;
 static char *bsc_ipaddr;
diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c
index 403b94c..671c874 100644
--- a/src/libbsc/abis_nm.c
+++ b/src/libbsc/abis_nm.c
@@ -2374,7 +2374,7 @@
 
 /* BS11 SWL */
 
-void *tall_fle_ctx;
+void *tall_fle_ctx = NULL;
 
 struct abis_nm_bs11_sw {
struct gsm_bts *bts;
diff --git a/src/libbsc/paging.c b/src/libbsc/paging.c
index be272f5..825d31e 100644
--- a/src/libbsc/paging.c
+++ b/src/libbsc/paging.c
@@ -51,7 +51,7 @@
 #include 
 #include 
 
-void *tall_paging_ctx;
+void *tall_paging_ctx = NULL;
 
 #define PAGING_TIMER 0, 50
 
diff --git a/src/libcommon/Makefile.am b/src/libcommon/Makefile.am
index a6ef44e..3518a55 100644
--- a/src/libcommon/Makefile.am
+++ b/src/libcommon/Makefile.am
@@ -22,6 +22,5 @@
 libcommon_a_SOURCES = \
gsm_data.c \
gsm_data_shared.c \
-   talloc_ctx.c \
handover_cfg.c \
$(NULL)
diff --git a/src/libcommon/gsm_data.c b/src/libcommon/gsm_data.c
index 92ebbfe..3b63ad0 100644
--- a/src/libcommon/gsm_data.c
+++ b/src/libcommon/gsm_data.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 
-void *tall_bsc_ctx;
+void *tall_bsc_ctx = NULL;
 
 static LLIST_HEAD(bts_models);
 
diff --git a/src/libcommon/talloc_ctx.c b/src/libcommon/talloc_ctx.c
deleted file mode 100644
index 9f64d75..000
--- a/src/libcommon/talloc_ctx.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* OpenBSC allocation contexts initialization code */
-/* (C) 2011-2016 by sysmocom s.f.m.c. GmbH 
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see .
- *
- */
-
-#include 
-#include 
-
-extern void *tall_bsc_ctx;
-extern void *tall_fle_ctx;
-extern void *tall_locop_ctx;
-extern void *tall_authciphop_ctx;
-extern void *tall_gsms_ctx;
-extern void *tall_subscr_ctx;
-extern void *tall_sub_req_ctx;
-extern void *tall_call_ctx;
-extern void *tall_paging_ctx;
-extern void *tall_sigh_ctx;
-extern void *tall_tqe_ctx;
-extern void *tall_trans_ctx;
-extern void *tall_ctr_ctx;
-
-void talloc_ctx_init(void *ctx_root)
-{
-   msgb_talloc_ctx_init(ctx_root, 0);
-   tall_fle_ctx = talloc_named_const(ctx_root, 0, "bs11_file_list_entry");
-   tall_locop_ctx = talloc_named_const(ctx_root, 0, "loc_updating_oper");
-   tall_authciphop_ctx = talloc_named_const(ctx_root, 0, "auth_ciph_oper");
-   tall_gsms_ctx = talloc_named_const(ctx_root, 0, "sms");
-   tall_subscr_ctx = talloc_named_const(ctx_root, 0, "subscriber");
-   tall_call_ctx = talloc_named_const(ctx_root, 0, "gsm_call");
-   tall_paging_ctx = talloc_named_const(ctx_root, 0, "paging_request");
-   tall_sigh_ctx = talloc_named_const(ctx_root, 0, "signal_handler");
-   tall_tqe_ctx = talloc_named_const(ctx_root, 0, "subch_txq_entry");
-   tall_trans_ctx = talloc_named_const(ctx_root, 0, "transaction");
-   tall_ctr_ctx = 

osmo-bsc[master]: libcommon: eliminate talloc_ctx.c

2018-02-14 Thread Harald Welte

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6432
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I344a3d07e146999e154824837ed95db2b9879356
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-bsc[master]: libcommon: eliminate talloc_ctx.c

2018-02-14 Thread Vadim Yanitskiy

Patch Set 3: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/6432
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I344a3d07e146999e154824837ed95db2b9879356
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-bsc[master]: libcommon: eliminate talloc_ctx.c

2018-02-13 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/6432

libcommon: eliminate talloc_ctx.c

Interestingly enough, talloc_ctx_init() actually had not a single caller.

While dropping it, see to it that the few contexts that are actually used in
osmo-bsc.git are indeed initialized in all the main scopes.

Also initialize two void* ctxts as NULL explicitly, to allocate under the NULL
context in case some main scope forgets to branch it off another root context.
(That's bsc, fle and paging, all others actually come in from other libraries.)

Change-Id: I344a3d07e146999e154824837ed95db2b9879356
---
M src/ipaccess/ipaccess-proxy.c
M src/libbsc/abis_nm.c
M src/libbsc/paging.c
M src/libcommon/Makefile.am
M src/libcommon/gsm_data.c
D src/libcommon/talloc_ctx.c
M src/osmo-bsc/osmo_bsc_main.c
M src/osmo-bsc_nat/bsc_nat.c
M src/utils/bs11_config.c
9 files changed, 24 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/32/6432/1

diff --git a/src/ipaccess/ipaccess-proxy.c b/src/ipaccess/ipaccess-proxy.c
index 5cf6d6d..d44cdf2 100644
--- a/src/ipaccess/ipaccess-proxy.c
+++ b/src/ipaccess/ipaccess-proxy.c
@@ -121,7 +121,7 @@
 };
 
 /* some of the code against we link from OpenBSC needs this */
-void *tall_bsc_ctx;
+void *tall_bsc_ctx = NULL;
 
 static char *listen_ipaddr;
 static char *bsc_ipaddr;
diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c
index 403b94c..671c874 100644
--- a/src/libbsc/abis_nm.c
+++ b/src/libbsc/abis_nm.c
@@ -2374,7 +2374,7 @@
 
 /* BS11 SWL */
 
-void *tall_fle_ctx;
+void *tall_fle_ctx = NULL;
 
 struct abis_nm_bs11_sw {
struct gsm_bts *bts;
diff --git a/src/libbsc/paging.c b/src/libbsc/paging.c
index be272f5..825d31e 100644
--- a/src/libbsc/paging.c
+++ b/src/libbsc/paging.c
@@ -51,7 +51,7 @@
 #include 
 #include 
 
-void *tall_paging_ctx;
+void *tall_paging_ctx = NULL;
 
 #define PAGING_TIMER 0, 50
 
diff --git a/src/libcommon/Makefile.am b/src/libcommon/Makefile.am
index a6ef44e..3518a55 100644
--- a/src/libcommon/Makefile.am
+++ b/src/libcommon/Makefile.am
@@ -22,6 +22,5 @@
 libcommon_a_SOURCES = \
gsm_data.c \
gsm_data_shared.c \
-   talloc_ctx.c \
handover_cfg.c \
$(NULL)
diff --git a/src/libcommon/gsm_data.c b/src/libcommon/gsm_data.c
index 92ebbfe..3b63ad0 100644
--- a/src/libcommon/gsm_data.c
+++ b/src/libcommon/gsm_data.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 
-void *tall_bsc_ctx;
+void *tall_bsc_ctx = NULL;
 
 static LLIST_HEAD(bts_models);
 
diff --git a/src/libcommon/talloc_ctx.c b/src/libcommon/talloc_ctx.c
deleted file mode 100644
index 9f64d75..000
--- a/src/libcommon/talloc_ctx.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* OpenBSC allocation contexts initialization code */
-/* (C) 2011-2016 by sysmocom s.f.m.c. GmbH 
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see .
- *
- */
-
-#include 
-#include 
-
-extern void *tall_bsc_ctx;
-extern void *tall_fle_ctx;
-extern void *tall_locop_ctx;
-extern void *tall_authciphop_ctx;
-extern void *tall_gsms_ctx;
-extern void *tall_subscr_ctx;
-extern void *tall_sub_req_ctx;
-extern void *tall_call_ctx;
-extern void *tall_paging_ctx;
-extern void *tall_sigh_ctx;
-extern void *tall_tqe_ctx;
-extern void *tall_trans_ctx;
-extern void *tall_ctr_ctx;
-
-void talloc_ctx_init(void *ctx_root)
-{
-   msgb_talloc_ctx_init(ctx_root, 0);
-   tall_fle_ctx = talloc_named_const(ctx_root, 0, "bs11_file_list_entry");
-   tall_locop_ctx = talloc_named_const(ctx_root, 0, "loc_updating_oper");
-   tall_authciphop_ctx = talloc_named_const(ctx_root, 0, "auth_ciph_oper");
-   tall_gsms_ctx = talloc_named_const(ctx_root, 0, "sms");
-   tall_subscr_ctx = talloc_named_const(ctx_root, 0, "subscriber");
-   tall_call_ctx = talloc_named_const(ctx_root, 0, "gsm_call");
-   tall_paging_ctx = talloc_named_const(ctx_root, 0, "paging_request");
-   tall_sigh_ctx = talloc_named_const(ctx_root, 0, "signal_handler");
-   tall_tqe_ctx = talloc_named_const(ctx_root, 0, "subch_txq_entry");
-   tall_trans_ctx = talloc_named_const(ctx_root, 0, "transaction");
-   tall_ctr_ctx = talloc_named_const(ctx_root, 0, "counter");
-}
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index 6539969..2b6dfb6 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++