[5/6] gprs-ns: Let gprs_nsvc_reset return a value
diff mbox

Message ID 1412762718-31961-5-git-send-email-jerlbeck@sysmocom.de
State Accepted
Headers show

Commit Message

Jacob Erlbeck Oct. 8, 2014, 10:05 a.m. UTC
Currently gprs_nsvc_reset does not return any value.

This patch changes the function to return an integer, where a value
less than zero indicates an error. The value is taken from the
gprs_ns_tx_reset function. In case of failure, an error message is logged.

Sponsored-by: On-Waves ehf
---
 include/osmocom/gprs/gprs_ns.h | 2 +-
 src/gb/gprs_ns.c               | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Holger Freyther Oct. 9, 2014, 5:49 a.m. UTC | #1
On Wed, Oct 08, 2014 at 12:05:17PM +0200, Jacob Erlbeck wrote:
> Currently gprs_nsvc_reset does not return any value.
> 
> This patch changes the function to return an integer, where a value
> less than zero indicates an error. The value is taken from the
> gprs_ns_tx_reset function. In case of failure, an error message is logged.

ah. Now update the unit test to print "failed" again or preferable
OSMO_ASSERT(rc < 0)?

Patch
diff mbox

diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h
index b4af61b..e77ca42 100644
--- a/include/osmocom/gprs/gprs_ns.h
+++ b/include/osmocom/gprs/gprs_ns.h
@@ -172,7 +172,7 @@  struct gprs_nsvc *gprs_nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei);
 struct gprs_nsvc *gprs_nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci);
 
 /* Initiate a RESET procedure (including timer start, ...)*/
-void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause);
+int gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause);
 
 /* Add NS-specific VTY stuff */
 int gprs_ns_vty_init(struct gprs_ns_inst *nsi);
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index ee2d7ec..cf7adaf 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -1495,20 +1495,25 @@  int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
  * will not only send a NS-RESET, but also set the state to BLOCKED and
  * start the Tns-reset timer.
  */
-void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause)
+int gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause)
 {
+	int rc;
+
 	LOGP(DNS, LOGL_INFO, "NSEI=%u RESET procedure based on API request\n",
 		nsvc->nsei);
 
 	/* Mark NS-VC locally as blocked and dead */
 	nsvc->state = NSE_S_BLOCKED;
 	/* Send NS-RESET PDU */
-	if (gprs_ns_tx_reset(nsvc, cause) < 0) {
+	rc = gprs_ns_tx_reset(nsvc, cause);
+	if (rc < 0) {
 		LOGP(DNS, LOGL_ERROR, "NSEI=%u, error resetting NS-VC\n",
 			nsvc->nsei);
 	}
 	/* Start Tns-reset */
 	nsvc_start_timer(nsvc, NSVC_TIMER_TNS_RESET);
+
+	return rc;
 }
 
 /*! \brief Establish a NS connection (from the BSS) to the SGSN