This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/12583 Change subject: trxcon/l1ctl_link.c: refactor l1ctl_link_init() ...................................................................... trxcon/l1ctl_link.c: refactor l1ctl_link_init() Change-Id: I7fe1bc306494ac692c182dcfd2a2d9412929194b --- M src/host/trxcon/l1ctl_link.c M src/host/trxcon/l1ctl_link.h M src/host/trxcon/trxcon.c 3 files changed, 16 insertions(+), 18 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/83/12583/1 diff --git a/src/host/trxcon/l1ctl_link.c b/src/host/trxcon/l1ctl_link.c index 20cb70c..6d6e356 100644 --- a/src/host/trxcon/l1ctl_link.c +++ b/src/host/trxcon/l1ctl_link.c @@ -229,53 +229,51 @@ return 0; } -int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path) +struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path) { - struct l1ctl_link *l1l_new; + struct l1ctl_link *l1l; struct osmo_fd *bfd; int rc; LOGP(DL1C, LOGL_NOTICE, "Init L1CTL link (%s)\n", sock_path); - l1l_new = talloc_zero(tall_trx_ctx, struct l1ctl_link); - if (!l1l_new) { + l1l = talloc_zero(tall_ctx, struct l1ctl_link); + if (!l1l) { LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory\n"); - return -ENOMEM; + return NULL; } /* Create a socket and bind handlers */ - bfd = &l1l_new->listen_bfd; + bfd = &l1l->listen_bfd; rc = osmo_sock_unix_init_ofd(bfd, SOCK_STREAM, 0, sock_path, OSMO_SOCK_F_BIND); if (rc < 0) { LOGP(DL1C, LOGL_ERROR, "Could not create UNIX socket: %s\n", strerror(errno)); - talloc_free(l1l_new); - return rc; + talloc_free(l1l); + return NULL; } /* Bind shutdown handler */ - l1l_new->shutdown_cb = l1ctl_shutdown_cb; + l1l->shutdown_cb = l1ctl_shutdown_cb; /* Bind connection handler */ bfd->cb = l1ctl_link_accept; bfd->when = BSC_FD_READ; - bfd->data = l1l_new; + bfd->data = l1l; /** * To be able to accept first connection and * drop others, it should be set to -1 */ - l1l_new->wq.bfd.fd = -1; + l1l->wq.bfd.fd = -1; /* Allocate a new dedicated state machine */ osmo_fsm_register(&l1ctl_fsm); - l1l_new->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l_new, + l1l->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l, NULL, LOGL_DEBUG, "l1ctl_link"); - *l1l = l1l_new; - - return 0; + return l1l; } void l1ctl_link_shutdown(struct l1ctl_link *l1l) diff --git a/src/host/trxcon/l1ctl_link.h b/src/host/trxcon/l1ctl_link.h index 01103dc..da64419 100644 --- a/src/host/trxcon/l1ctl_link.h +++ b/src/host/trxcon/l1ctl_link.h @@ -41,7 +41,7 @@ void (*shutdown_cb)(struct l1ctl_link *l1l); }; -int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path); +struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path); void l1ctl_link_shutdown(struct l1ctl_link *l1l); int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg); diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c index 501d0c7..777138f 100644 --- a/src/host/trxcon/trxcon.c +++ b/src/host/trxcon/trxcon.c @@ -279,8 +279,8 @@ NULL, LOGL_DEBUG, "main"); /* Init L1CTL server */ - rc = l1ctl_link_init(&app_data.l1l, app_data.bind_socket); - if (rc) + app_data.l1l = l1ctl_link_init(tall_trx_ctx, app_data.bind_socket); + if (app_data.l1l == NULL) goto exit; /* Init transceiver interface */ -- To view, visit https://gerrit.osmocom.org/12583 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I7fe1bc306494ac692c182dcfd2a2d9412929194b Gerrit-Change-Number: 12583 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190116/1405b0ca/attachment.htm>