From 45ade68cb48baad5f4f994fae6fe52211f379f70 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Tue, 15 Apr 2014 18:01:47 +0000
Subject: [PATCH] Remove unused RAII_VAR() declarations.

* Remove unused RAII_VAR() declarations.  The compiler cannot catch these
because the cleanup function "references" the unused variable.  Some
actually allocated and released resources that were never used.

* Fixed some whitespace issues in stasis_bridges.c.
........

Merged revisions 412399 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_oss.c                |  1 -
 channels/chan_skinny.c             |  2 --
 main/cdr.c                         |  6 -----
 main/pbx.c                         |  2 --
 main/stasis_bridges.c              | 36 +++++++++++++++---------------
 main/stasis_channels.c             |  2 --
 res/ari/resource_channels.c        |  1 -
 res/ari/resource_recordings.c      |  1 -
 res/parking/parking_applications.c |  1 -
 res/parking/parking_manager.c      |  3 ---
 res/res_ari.c                      |  1 -
 res/res_fax.c                      |  1 -
 res/res_parking.c                  |  1 -
 res/res_pjsip/location.c           |  1 -
 res/res_pjsip/security_events.c    |  1 -
 res/res_pjsip_refer.c              |  1 -
 res/res_pjsip_session.c            |  2 +-
 res/res_stasis_playback.c          |  1 -
 res/res_stasis_recording.c         |  1 -
 res/stasis/app.c                   |  2 --
 res/stasis_recording/stored.c      |  1 -
 21 files changed, 19 insertions(+), 49 deletions(-)

diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index e5300ef823..7fc4f40521 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1175,7 +1175,6 @@ static char *console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args
 static char *console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct chan_oss_pvt *o = find_desc(oss_active);
-	RAII_VAR(struct ast_channel *, b, NULL, ast_channel_cleanup);
 	char *tmp, *ext, *ctx;
 
 	switch (cmd) {
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index cf0b07209d..8ed469ebea 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -7202,8 +7202,6 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
 		}
 
 		if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)) {
-			RAII_VAR(struct ast_channel *, bridged, NULL, ast_channel_cleanup);
-
 			c = sub->owner;
 			ast_channel_lock(c);
 			bridge_channel = ast_channel_get_bridge_channel(c);
diff --git a/main/cdr.c b/main/cdr.c
index 467969097c..1828b0a4c9 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1085,7 +1085,6 @@ static struct ast_cdr *cdr_object_create_public_records(struct cdr_object *cdr)
 	struct ast_var_t *it_var, *it_copy_var;
 	struct ast_channel_snapshot *party_a;
 	struct ast_channel_snapshot *party_b;
-	RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);
 
 	for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
 		struct ast_cdr *cdr_copy;
@@ -1239,9 +1238,6 @@ static void cdr_object_set_disposition(struct cdr_object *cdr, int hangupcause)
  */
 static void cdr_object_finalize(struct cdr_object *cdr)
 {
-	RAII_VAR(struct module_config *, mod_cfg,
-			ao2_global_obj_ref(module_configs), ao2_cleanup);
-
 	if (!ast_tvzero(cdr->end)) {
 		return;
 	}
@@ -1644,8 +1640,6 @@ static enum ast_cdr_disposition dial_status_to_disposition(const char *dial_stat
 
 static int dial_state_process_dial_end(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer, const char *dial_status)
 {
-	RAII_VAR(struct module_config *, mod_cfg,
-			ao2_global_obj_ref(module_configs), ao2_cleanup);
 	struct ast_channel_snapshot *party_a;
 
 	if (caller) {
diff --git a/main/pbx.c b/main/pbx.c
index b24bcd8c8d..d161117461 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4834,8 +4834,6 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
 	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
 	char passdata[EXT_DATA_SIZE];
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 
 	ast_rdlock_contexts();
 	if (found)
diff --git a/main/stasis_bridges.c b/main/stasis_bridges.c
index eb020163d7..1e0b36edff 100644
--- a/main/stasis_bridges.c
+++ b/main/stasis_bridges.c
@@ -346,11 +346,11 @@ static struct ast_json *ast_bridge_merge_message_to_json(
 		return NULL;
 	}
 
-        return ast_json_pack("{s: s, s: o, s: O, s: O}",
-                "type", "BridgeMerged",
-                "timestamp", ast_json_timeval(*stasis_message_timestamp(msg), NULL),
-                "bridge", json_bridge_to,
-                "bridge_from", json_bridge_from);
+	return ast_json_pack("{s: s, s: o, s: O, s: O}",
+		"type", "BridgeMerged",
+		"timestamp", ast_json_timeval(*stasis_message_timestamp(msg), NULL),
+		"bridge", json_bridge_to,
+		"bridge_from", json_bridge_from);
 }
 
 void ast_bridge_publish_merge(struct ast_bridge *to, struct ast_bridge *from)
@@ -466,10 +466,10 @@ void ast_bridge_publish_leave(struct ast_bridge *bridge, struct ast_channel *cha
 }
 
 static struct ast_json *simple_bridge_channel_event(
-        const char *type,
-        struct ast_bridge_snapshot *bridge_snapshot,
-        struct ast_channel_snapshot *channel_snapshot,
-        const struct timeval *tv,
+	const char *type,
+	struct ast_bridge_snapshot *bridge_snapshot,
+	struct ast_channel_snapshot *channel_snapshot,
+	const struct timeval *tv,
 	const struct stasis_message_sanitizer *sanitize)
 {
 	RAII_VAR(struct ast_json *, json_bridge,
@@ -481,31 +481,31 @@ static struct ast_json *simple_bridge_channel_event(
 		return NULL;
 	}
 
-        return ast_json_pack("{s: s, s: o, s: O, s: O}",
-                "type", type,
-                "timestamp", ast_json_timeval(*tv, NULL),
-                "bridge", json_bridge,
-                "channel", json_channel);
+	return ast_json_pack("{s: s, s: o, s: O, s: O}",
+		"type", type,
+		"timestamp", ast_json_timeval(*tv, NULL),
+		"bridge", json_bridge,
+		"channel", json_channel);
 }
 
 struct ast_json *ast_channel_entered_bridge_to_json(
 	struct stasis_message *msg,
 	const struct stasis_message_sanitizer *sanitize)
 {
-        struct ast_bridge_blob *obj = stasis_message_data(msg);
+	struct ast_bridge_blob *obj = stasis_message_data(msg);
 
 	return simple_bridge_channel_event("ChannelEnteredBridge", obj->bridge,
-                obj->channel, stasis_message_timestamp(msg), sanitize);
+		obj->channel, stasis_message_timestamp(msg), sanitize);
 }
 
 struct ast_json *ast_channel_left_bridge_to_json(
 	struct stasis_message *msg,
 	const struct stasis_message_sanitizer *sanitize)
 {
-        struct ast_bridge_blob *obj = stasis_message_data(msg);
+	struct ast_bridge_blob *obj = stasis_message_data(msg);
 
 	return simple_bridge_channel_event("ChannelLeftBridge", obj->bridge,
-                obj->channel, stasis_message_timestamp(msg), sanitize);
+		obj->channel, stasis_message_timestamp(msg), sanitize);
 }
 
 static struct ast_json *container_to_json_array(struct ao2_container *items,
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index 45ec53d7f7..c75d174925 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -716,7 +716,6 @@ static struct ast_manager_event_blob *varset_to_ami(struct stasis_message *msg)
 static struct ast_manager_event_blob *agent_login_to_ami(struct stasis_message *msg)
 {
 	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
-	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
 	struct ast_channel_blob *obj = stasis_message_data(msg);
 	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
 
@@ -734,7 +733,6 @@ static struct ast_manager_event_blob *agent_login_to_ami(struct stasis_message *
 static struct ast_manager_event_blob *agent_logoff_to_ami(struct stasis_message *msg)
 {
 	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
-	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
 	struct ast_channel_blob *obj = stasis_message_data(msg);
 	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
 	long logintime = ast_json_integer_get(ast_json_object_get(obj->blob, "logintime"));
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index 7b7e807390..9d127b2ea4 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -464,7 +464,6 @@ void ast_ari_channels_record(struct ast_variable *headers,
 	struct ast_ari_response *response)
 {
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
 	RAII_VAR(char *, recording_url, NULL, ast_free);
 	struct ast_json *json;
diff --git a/res/ari/resource_recordings.c b/res/ari/resource_recordings.c
index abde4f0c0e..bc07d55992 100644
--- a/res/ari/resource_recordings.c
+++ b/res/ari/resource_recordings.c
@@ -166,7 +166,6 @@ static void control_recording(const char *name,
 	struct ast_ari_response *response)
 {
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	enum stasis_app_recording_oper_results res;
 
 	recording = stasis_app_recording_find_by_name(name);
diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c
index 85075bc5a2..3d2eecd297 100644
--- a/res/parking/parking_applications.c
+++ b/res/parking/parking_applications.c
@@ -553,7 +553,6 @@ static int parked_call_app_exec(struct ast_channel *chan, const char *data)
 {
 	RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
 	RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup); /* Parked user being retrieved */
-	RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
 	struct ast_bridge *retrieval_bridge;
 	int res;
 	int target_space = -1;
diff --git a/res/parking/parking_manager.c b/res/parking/parking_manager.c
index 70a230c562..16e2863698 100644
--- a/res/parking/parking_manager.c
+++ b/res/parking/parking_manager.c
@@ -152,7 +152,6 @@ static struct stasis_subscription *parking_sub;
 
 static struct ast_parked_call_payload *parked_call_payload_from_failure(struct ast_channel *chan)
 {
-	RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, parkee_snapshot, NULL, ao2_cleanup);
 
 	ast_channel_lock(chan);
@@ -167,7 +166,6 @@ static struct ast_parked_call_payload *parked_call_payload_from_failure(struct a
 
 static struct ast_parked_call_payload *parked_call_payload_from_parked_user(struct parked_user *pu, enum ast_parked_call_event_type event_type)
 {
-	RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, parkee_snapshot, NULL, ao2_cleanup);
 	long int timeout;
 	long int duration;
@@ -177,7 +175,6 @@ static struct ast_parked_call_payload *parked_call_payload_from_parked_user(stru
 	ast_channel_lock(pu->chan);
 	parkee_snapshot = ast_channel_snapshot_create(pu->chan);
 	ast_channel_unlock(pu->chan);
-
 	if (!parkee_snapshot) {
 		return NULL;
 	}
diff --git a/res/res_ari.c b/res/res_ari.c
index 133ca6689c..4f16c021c5 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -472,7 +472,6 @@ void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
 	struct ast_variable *get_params, struct ast_variable *headers,
 	struct ast_ari_response *response)
 {
-	RAII_VAR(char *, response_text, NULL, ast_free);
 	RAII_VAR(struct stasis_rest_handlers *, root, NULL, ao2_cleanup);
 	struct stasis_rest_handlers *handler;
 	RAII_VAR(struct ast_variable *, path_vars, NULL, ast_variables_destroy);
diff --git a/res/res_fax.c b/res/res_fax.c
index e05b101f74..4f253b7588 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -1175,7 +1175,6 @@ static char *generate_filenames_string(struct ast_fax_session_details *details,
 static int report_fax_status(struct ast_channel *chan, struct ast_fax_session_details *details, const char *status)
 {
 	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 	struct ast_json *json_filenames = NULL;
 
diff --git a/res/res_parking.c b/res/res_parking.c
index 6d07818dee..c36d558b6e 100644
--- a/res/res_parking.c
+++ b/res/res_parking.c
@@ -689,7 +689,6 @@ static int parking_add_extension(struct ast_context *context, int replace, const
 
 static int extension_is_compatible(struct parking_lot_cfg *lot_cfg, const char *app_type, struct ast_exten *extension)
 {
-	RAII_VAR(struct parking_lot_cfg *, owner, NULL, ao2_cleanup);
 	const char *extension_registrar = ast_get_extension_registrar(extension);
 	const char *extension_context = ast_get_context_name(ast_get_extension_context(extension));
 	const char *extension_name = ast_get_extension_name(extension);
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index e526c46658..2cd852daaf 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -158,7 +158,6 @@ struct ast_sip_contact *ast_sip_location_retrieve_contact_from_aor_list(const ch
 
 	while ((aor_name = strsep(&rest, ","))) {
 		RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
-		RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
 
 		if (!aor) {
 			continue;
diff --git a/res/res_pjsip/security_events.c b/res/res_pjsip/security_events.c
index 5bb5af90c8..5c30e1c5e7 100644
--- a/res/res_pjsip/security_events.c
+++ b/res/res_pjsip/security_events.c
@@ -136,7 +136,6 @@ void ast_sip_report_auth_failed_challenge_response(struct ast_sip_endpoint *endp
 	char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
 	char nonce[64] = "", response[256] = "";
 	struct ast_sockaddr local, remote;
-	RAII_VAR(struct ast_sip_endpoint *, artificial, ast_sip_get_artificial_endpoint(), ao2_cleanup);
 
 	struct ast_security_event_chal_resp_failed chal_resp_failed = {
 				.common.event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED,
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 399e9e6720..9725caa149 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -732,7 +732,6 @@ static int refer_incoming_invite_request(struct ast_sip_session *session, struct
 	int response = 0;
 	RAII_VAR(struct ast_sip_session *, other_session, NULL, ao2_cleanup);
 	struct invite_replaces invite;
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
 
 	/* If a Replaces header is present make sure it is valid */
 	if (pjsip_replaces_verify_request(rdata, &other_dlg, PJ_TRUE, &packet) != PJ_SUCCESS) {
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 067bf87812..82c7a3f229 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -302,7 +302,7 @@ static int validate_incoming_sdp(const pjmedia_sdp_session *sdp)
 	for (i = 0; i < sdp->media_count; ++i) {
 		RAII_VAR(int *, port, ao2_alloc(sizeof(int), NULL), ao2_cleanup);
 		RAII_VAR(int *, port_match, NULL, ao2_cleanup);
-		RAII_VAR(int *, bundle_match, NULL, ao2_cleanup);
+
 		*port = sdp->media[i]->desc.port;
 		port_match = ao2_find(portlist, port, OBJ_KEY);
 		if (port_match) {
diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c
index 299cb44837..79c2bab9ce 100644
--- a/res/res_stasis_playback.c
+++ b/res/res_stasis_playback.c
@@ -192,7 +192,6 @@ static const char *state_to_string(enum stasis_app_playback_state state)
 static void playback_publish(struct stasis_app_playback *playback)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
 	ast_assert(playback != NULL);
diff --git a/res/res_stasis_recording.c b/res/res_stasis_recording.c
index 080ee7b815..a256fe9994 100644
--- a/res/res_stasis_recording.c
+++ b/res/res_stasis_recording.c
@@ -211,7 +211,6 @@ enum ast_record_if_exists stasis_app_recording_if_exists_parse(
 static void recording_publish(struct stasis_app_recording *recording, const char *cause)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 
 	ast_assert(recording != NULL);
diff --git a/res/stasis/app.c b/res/stasis/app.c
index 54ee5898e2..d9eef4c663 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -387,7 +387,6 @@ static struct ast_json *channel_dialplan(
 	struct ast_channel_snapshot *new_snapshot,
 	const struct timeval *tv)
 {
-	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ast_json *json_channel;
 
 	/* No Newexten event on cache clear or first event */
@@ -422,7 +421,6 @@ static struct ast_json *channel_callerid(
 	struct ast_channel_snapshot *new_snapshot,
 	const struct timeval *tv)
 {
-	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ast_json *json_channel;
 
 	/* No NewCallerid event on cache clear or first event */
diff --git a/res/stasis_recording/stored.c b/res/stasis_recording/stored.c
index 255976d285..03af06987e 100644
--- a/res/stasis_recording/stored.c
+++ b/res/stasis_recording/stored.c
@@ -247,7 +247,6 @@ static int scan_file(struct ao2_container *recordings,
 {
 	RAII_VAR(struct stasis_app_stored_recording *, recording, NULL,
 		ao2_cleanup);
-	RAII_VAR(struct ast_str *, name, NULL, ast_free);
 	const char *ext;
 	char *dot;
 
-- 
GitLab