From: Kathleen King Date: Fri, 4 Jul 2014 00:03:01 +0000 (-0700) Subject: Fixed dead code. X-Git-Tag: v1.5.13~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d85726ecd5bfb42de0563cdead31eaed21a303b;p=thirdparty%2Ffreeswitch.git Fixed dead code. While reviewing code I noticed some dead code. It was not possible to default to the channel variable because the parameter could not be both full and empty. If the parameter is not a non zero length string then the code looked like it was intending to default to the channel variable 'presence_data_cols'. If neither of these are the case it is a noop. By enabling the dead code, you now have access to set the 'presence_data_cols' in the dialplan or scripts like lua. --- diff --git a/src/switch_channel.c b/src/switch_channel.c index 2168fd396e..c27f1c5ff9 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1336,32 +1336,30 @@ SWITCH_DECLARE(switch_status_t) switch_channel_transfer_variable_prefix(switch_c SWITCH_DECLARE(void) switch_channel_set_presence_data_vals(switch_channel_t *channel, const char *presence_data_cols) { - if (!zstr(presence_data_cols)) { - char *cols[128] = { 0 }; - char header_name[128] = ""; - int col_count = 0, i = 0; - char *data_copy = NULL; - + char *cols[128] = { 0 }; + char header_name[128] = ""; + int col_count = 0, i = 0; + char *data_copy = NULL; + + if (zstr(presence_data_cols)) { + presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1); if (zstr(presence_data_cols)) { - presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1); - if (zstr(presence_data_cols)) { - return; - } + return; } - - data_copy = strdup(presence_data_cols); + } - col_count = switch_split(data_copy, ':', cols); + data_copy = strdup(presence_data_cols); - for (i = 0; i < col_count; i++) { - const char *val = NULL; - switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]); - val = switch_channel_get_variable(channel, cols[i]); - switch_channel_set_profile_var(channel, header_name, val); - } - - switch_safe_free(data_copy); + col_count = switch_split(data_copy, ':', cols); + + for (i = 0; i < col_count; i++) { + const char *val = NULL; + switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]); + val = switch_channel_get_variable(channel, cols[i]); + switch_channel_set_profile_var(channel, header_name, val); } + + switch_safe_free(data_copy); }