[Asterisk-code-review] res parking: Cleanup find channel parking lot name() usage. (asterisk[13])

Anonymous Coward asteriskteam at digium.com
Sat Mar 26 11:33:01 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: res_parking: Cleanup find_channel_parking_lot_name() usage.
......................................................................


res_parking: Cleanup find_channel_parking_lot_name() usage.

Change-Id: I8f7a8890aef27824301c642d4d15407ac83e6f02
---
M res/parking/parking_applications.c
M res/parking/parking_bridge_features.c
M res/parking/res_parking.h
M res/res_parking.c
4 files changed, 12 insertions(+), 19 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c
index d8cda6f..95a87ef 100644
--- a/res/parking/parking_applications.c
+++ b/res/parking/parking_applications.c
@@ -567,7 +567,7 @@
 	int target_space = -1;
 	struct ast_bridge_features chan_features;
 	char *parse;
-	char *lot_name;
+	const char *lot_name;
 
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(lot_name);
diff --git a/res/parking/parking_bridge_features.c b/res/parking/parking_bridge_features.c
index a21be90..becb74e 100644
--- a/res/parking/parking_bridge_features.c
+++ b/res/parking/parking_bridge_features.c
@@ -474,18 +474,11 @@
 static int parking_park_call(struct ast_bridge_channel *parker, char *exten, size_t length)
 {
 	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
-	const char *lot_name = NULL;
+	const char *lot_name;
 
 	ast_channel_lock(parker->chan);
-	lot_name = find_channel_parking_lot_name(parker->chan);
-	if (!ast_strlen_zero(lot_name)) {
-		lot_name = ast_strdupa(lot_name);
-	}
+	lot_name = ast_strdupa(find_channel_parking_lot_name(parker->chan));
 	ast_channel_unlock(parker->chan);
-
-	if (ast_strlen_zero(lot_name)) {
-		return -1;
-	}
 
 	lot = parking_lot_find_by_name(lot_name);
 	if (!lot) {
diff --git a/res/parking/res_parking.h b/res/parking/res_parking.h
index 3d77e51..b8be041 100644
--- a/res/parking/res_parking.h
+++ b/res/parking/res_parking.h
@@ -308,8 +308,9 @@
  *
  * \param chan The channel we want the parking lot name for
  *
- * \retval name of the channel's assigned parking lot if it is defined by the channel in some way
- * \retval name of the default parking lot if it is not
+ * \return name of the parking lot to use for the channel.
+ *
+ * \note Always returns a parking lot name.
  *
  * \note Channel needs to be locked while the returned string is in use.
  */
diff --git a/res/res_parking.c b/res/res_parking.c
index 3edbd46..f062b4f 100644
--- a/res/res_parking.c
+++ b/res/res_parking.c
@@ -568,14 +568,13 @@
 
 	/* The channel variable overrides everything */
 	name = pbx_builtin_getvar_helper(chan, "PARKINGLOT");
-	if (ast_strlen_zero(name) && !ast_strlen_zero(ast_channel_parkinglot(chan))) {
-		/* Use the channel's parking lot. */
-		name = ast_channel_parkinglot(chan);
-	}
-
-	/* If the name couldn't be pulled from that either, use the default parking lot name. */
 	if (ast_strlen_zero(name)) {
-		name = DEFAULT_PARKING_LOT;
+		/* Try the channel's parking lot. */
+		name = ast_channel_parkinglot(chan);
+		if (ast_strlen_zero(name)) {
+			/* Fall back to the default parking lot. */
+			name = DEFAULT_PARKING_LOT;
+		}
 	}
 
 	return name;

-- 
To view, visit https://gerrit.asterisk.org/2475
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8f7a8890aef27824301c642d4d15407ac83e6f02
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list