summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-07-17 22:30:28 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-07-17 22:30:28 +0000
commit40ce5e0d18520cd7a440cd8849e3e920be68f471 (patch)
tree5499af489ac45954318119e4294811be3da06dff /main
parentda1902cdc060763a712bb1586cfca5ec1e9a2c49 (diff)
Change ast_hangup() to return void and be NULL safe.
Since ast_hangup() is effectively a channel destructor, it should be a void function. * Make the few silly callers checking the return value no longer do so. Only the CDR and CEL unit tests checked the return value. * Make all callers take advantage of the NULL safe change and remove the NULL check before the call. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/channel.c11
-rw-r--r--main/dial.c14
-rw-r--r--main/features.c12
3 files changed, 16 insertions, 21 deletions
diff --git a/main/channel.c b/main/channel.c
index c6df5f8b0..9932642c3 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2640,8 +2640,13 @@ static void destroy_hooks(struct ast_channel *chan)
}
/*! \brief Hangup a channel */
-int ast_hangup(struct ast_channel *chan)
+void ast_hangup(struct ast_channel *chan)
{
+ /* Be NULL safe for RAII_VAR() usage. */
+ if (!chan) {
+ return;
+ }
+
ast_autoservice_stop(chan);
ast_channel_lock(chan);
@@ -2669,7 +2674,7 @@ int ast_hangup(struct ast_channel *chan)
ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE);
destroy_hooks(chan);
ast_channel_unlock(chan);
- return 0;
+ return;
}
/* Mark as a zombie so a masquerade cannot be setup on this channel. */
@@ -2733,8 +2738,6 @@ int ast_hangup(struct ast_channel *chan)
ast_cc_offer(chan);
ast_channel_unref(chan);
-
- return 0;
}
int ast_raw_answer(struct ast_channel *chan)
diff --git a/main/dial.c b/main/dial.c
index ab35373c5..e13805ad4 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -942,10 +942,8 @@ void ast_dial_hangup(struct ast_dial *dial)
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
- if (channel->owner) {
- ast_hangup(channel->owner);
- channel->owner = NULL;
- }
+ ast_hangup(channel->owner);
+ channel->owner = NULL;
}
AST_LIST_UNLOCK(&dial->channels);
@@ -976,11 +974,11 @@ int ast_dial_destroy(struct ast_dial *dial)
option_types[i].disable(channel->options[i]);
channel->options[i] = NULL;
}
+
/* Hang up channel if need be */
- if (channel->owner) {
- ast_hangup(channel->owner);
- channel->owner = NULL;
- }
+ ast_hangup(channel->owner);
+ channel->owner = NULL;
+
/* Free structure */
ast_free(channel->tech);
ast_free(channel->device);
diff --git a/main/features.c b/main/features.c
index df8151340..fd72b9cb2 100644
--- a/main/features.c
+++ b/main/features.c
@@ -2547,9 +2547,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
* is up, hang it up as it has no one to talk to.
*/
ast_debug(1, "Everyone is hungup.\n");
- if (newchan) {
- ast_hangup(newchan);
- }
+ ast_hangup(newchan);
ast_party_connected_line_free(&connected_line);
return -1;
}
@@ -5586,18 +5584,14 @@ AST_TEST_DEFINE(features_test)
/* find the real channel */
parked_chan = ast_channel_get_by_name("TestChannel1");
if (unpark_test_channel(parked_chan, &args)) {
- if (parked_chan) {
- ast_hangup(parked_chan);
- }
+ ast_hangup(parked_chan);
res = -1;
}
exit_features_test:
- if (test_channel1) {
- ast_hangup(test_channel1);
- }
+ ast_hangup(test_channel1);
force_reload_load = 1;
ast_features_reload();