From 7bab5df1c859490aa15cbaa8305f3e28b369c20d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 16 May 2008 15:29:44 +0000 Subject: [PATCH] refactoring.... Found by Klockwork (www.klocwork.com) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8436 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_core_session.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 2b712a54ab..f3d82e32e9 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -217,6 +217,8 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const if (session) { channel = switch_core_session_get_channel(session); + switch_assert(channel != NULL); + forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); if (!switch_strlen_zero(forwardvar)) { forwardval = atoi(forwardvar) - 1; @@ -267,20 +269,20 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const switch_caller_profile_t *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL; switch_event_t *event; switch_channel_t *peer_channel = switch_core_session_get_channel(*new_session); + + switch_assert(peer_channel); + + peer_profile = switch_channel_get_caller_profile(peer_channel); - if (session && channel) { - profile = switch_channel_get_caller_profile(channel); - } - if (peer_channel) { - peer_profile = switch_channel_get_caller_profile(peer_channel); - } - - if (channel && peer_channel) { + if (channel) { const char *export_vars, *val; switch_codec_t *read_codec = switch_core_session_get_read_codec(session); const char *max_forwards = switch_core_session_sprintf(session, "%d", forwardval); + switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards); + profile = switch_channel_get_caller_profile(channel); + if (read_codec) { char tmp[80]; switch_codec2str(read_codec, tmp, sizeof(tmp)); @@ -336,7 +338,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const } if (peer_profile) { - if (session && (cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) { + if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) { switch_channel_set_originatee_caller_profile(channel, cloned_profile); } }