Fix dead nested assignments in various modules

This commit is contained in:
Andrey Volk committed 2022-08-09 23:20:52 +03:00
1 parent e53e8a17c1
commit c47c16b1dd
34 files changed
+82 -120

No files matched your search

@@ -953,7 +953,6 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p
SWITCH_STANDARD_APP(directory_function)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
int argc = 0;
char *argv[6] = { 0 };
char *mydata = NULL;
const char *profile_name = NULL;
@@ -975,7 +974,7 @@ SWITCH_STANDARD_APP(directory_function)
}
mydata = switch_core_session_strdup(session, data);
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
if (switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) < 2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Not enough args [%s]\n", data);
return;
}
@@ -1459,7 +1459,6 @@ SWITCH_STANDARD_APP(wait_for_video_ready_function)
SWITCH_STANDARD_APP(presence_function)
{
char *argv[6] = { 0 };
int argc;
char *mydata = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -1468,7 +1467,7 @@ SWITCH_STANDARD_APP(presence_function)
return;
}
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
if (switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0])) < 2) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n");
return;
}
+4 -2
View File
@@ -563,10 +563,12 @@ case EXPR_NODEFUNC_RECTTOPOLA:
tmp = atan2(d2, d1);
EXPR_CHECK_ERR();
if (tmp < 0.0)
if (tmp < 0.0) {
*val = tmp = (2.0 * M_PI);
else
(void)tmp;
} else {
*val = tmp;
}
} else
return err;
+1 -2
View File
@@ -2353,7 +2353,6 @@ SWITCH_STANDARD_API(fifo_check_bridge_function)
SWITCH_STANDARD_API(fifo_add_outbound_function)
{
char *data = NULL, *argv[4] = { 0 };
int argc;
uint32_t priority = 0;
if (zstr(cmd)) {
@@ -2362,7 +2361,7 @@ SWITCH_STANDARD_API(fifo_add_outbound_function)
data = strdup(cmd);
if ((argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2 || !argv[0]) {
if (switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) < 2 || !argv[0]) {
goto fail;
}
+2 -2
View File
@@ -435,7 +435,7 @@ SWITCH_STANDARD_APP(hash_function)
if (argc < 4) {
goto usage;
}
if (!(value = switch_core_hash_find(globals.db_hash, hash_key))) {
if (!switch_core_hash_find(globals.db_hash, hash_key)) {
switch_core_hash_insert_dup(globals.db_hash, hash_key, argv[3]);
}
@@ -507,7 +507,7 @@ SWITCH_STANDARD_API(hash_api_function)
goto usage;
}
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
if ((value = switch_core_hash_find(globals.db_hash, hash_key))) {
if (switch_core_hash_find(globals.db_hash, hash_key)) {
stream->write_function(stream, "-ERR key already exists\n");
} else {
switch_core_hash_insert_dup(globals.db_hash, hash_key, argv[3]);
+2 -3
View File
@@ -2378,7 +2378,6 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 };
char meta_buffer[1024] = "";
int fd;
switch_ssize_t bytes;
switch_md5_string(digest, (void *) url, strlen(url));
@@ -2390,7 +2389,7 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
ext = find_ext(url);
}
if (ext && (p = strchr(ext, '?'))) {
if (ext && strchr(ext, '?')) {
dext = strdup(ext);
if ((p = strchr(dext, '?'))) {
*p = '\0';
@@ -2402,7 +2401,7 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
context->meta_file = switch_core_sprintf(context->pool, "%s%s%s.meta", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
if (switch_file_exists(context->meta_file, context->pool) == SWITCH_STATUS_SUCCESS && ((fd = open(context->meta_file, O_RDONLY, 0)) > -1)) {
if ((bytes = read(fd, meta_buffer, sizeof(meta_buffer))) > 0) {
if (read(fd, meta_buffer, sizeof(meta_buffer)) > 0) {
char *p;
if ((p = strchr(meta_buffer, ':'))) {
+12 -13
View File
@@ -583,10 +583,9 @@ SWITCH_STANDARD_APP(oreka_start_function)
oreka_session_t *oreka = NULL;
switch_media_bug_t *bug = NULL;
char *argv[6];
int argc;
int flags = 0;
int flags = 0;
char *lbuf = NULL;
const char *var;
const char *var;
if ((oreka = (oreka_session_t *) switch_channel_get_private(channel, OREKA_PRIVATE))) {
if (!zstr(data) && !strcasecmp(data, "stop")) {
@@ -606,14 +605,14 @@ SWITCH_STANDARD_APP(oreka_start_function)
switch_assert(oreka);
memset(oreka, 0, sizeof(*oreka));
oreka->mux_streams = globals.mux_streams;
oreka->mux_streams = globals.mux_streams;
if ((var = switch_channel_get_variable(channel, "oreka_mux_streams"))) {
oreka->mux_streams = switch_true(var);
}
if ((var = switch_channel_get_variable(channel, "oreka_mux_streams"))) {
oreka->mux_streams = switch_true(var);
}
if (data && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
&& switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) {
#if 0
if (!strncasecmp(argv[x], "server", sizeof("server"))) {
/* parse server=192.168.1.144 string */
@@ -623,11 +622,11 @@ SWITCH_STANDARD_APP(oreka_start_function)
oreka->session = session;
if (oreka->mux_streams) {
flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING | SMBF_ANSWER_REQ;
} else {
flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_ANSWER_REQ;
}
if (oreka->mux_streams) {
flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING | SMBF_ANSWER_REQ;
} else {
flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_ANSWER_REQ;
}
status = switch_core_media_bug_add(session, OREKA_BUG_NAME_READ, NULL, oreka_audio_callback, oreka, 0, flags, &bug);
+3 -3
View File
@@ -367,7 +367,7 @@ static int cr_readln(REDIS rhnd, int start, char **line, int *idx)
static int cr_receivemultibulk(REDIS rhnd, char *line)
{
int bnum, blen, i, rc=0, idx=0;
int bnum, blen, i, idx=0;
bnum = atoi(line);
@@ -381,7 +381,7 @@ static int cr_receivemultibulk(REDIS rhnd, char *line)
return CREDIS_ERR_NOMEM;
}
for (i = 0; bnum > 0 && (rc = cr_readln(rhnd, 0, &line, NULL)) > 0; i++, bnum--) {
for (i = 0; bnum > 0 && cr_readln(rhnd, 0, &line, NULL) > 0; i++, bnum--) {
if (*(line++) != CR_BULK)
return CREDIS_ERR_PROTOCOL;
@@ -389,7 +389,7 @@ static int cr_receivemultibulk(REDIS rhnd, char *line)
if (blen == -1)
rhnd->reply.multibulk.idxs[i] = -1;
else {
if ((rc = cr_readln(rhnd, blen, &line, &idx)) != blen)
if (cr_readln(rhnd, blen, &line, &idx) != blen)
return CREDIS_ERR_PROTOCOL;
rhnd->reply.multibulk.idxs[i] = idx;
+1 -1
View File
@@ -305,7 +305,7 @@ SWITCH_STANDARD_APP(rss_function)
char cmd[3];
main_menu:
filename = NULL;
len = idx = 0;
len = 0;
*cmd = '\0';
title_txt = description_txt = rights_txt = "";
@@ -464,7 +464,6 @@ done:
#define SIGNALWIRE_SYNTAX "token | token-reset | adoption | adopted | reload | update | debug <level> | kslog <on|off|logfile e.g. /tmp/ks.log>"
SWITCH_STANDARD_API(mod_signalwire_api_function)
{
int argc = 0;
char *argv[2] = { 0 };
char *buf = NULL;
@@ -474,7 +473,7 @@ SWITCH_STANDARD_API(mod_signalwire_api_function)
return SWITCH_STATUS_SUCCESS;
}
if ((argc = switch_separate_string(buf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (switch_separate_string(buf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) {
if (!strcmp(argv[0], "token")) {
if (globals.adoption_token[0]) {
stream->write_function(stream,
+1 -2
View File
@@ -149,10 +149,9 @@ SWITCH_STANDARD_API(snom_command_api_function)
char *ret = NULL;
switch_cache_db_handle_t *db = NULL;
switch_stream_handle_t apistream = { 0 };
switch_status_t status;
SWITCH_STANDARD_STREAM(apistream);
if ((status = switch_api_execute("sofia_contact", argv[0], NULL, &apistream)) != SWITCH_STATUS_SUCCESS) {
if (switch_api_execute("sofia_contact", argv[0], NULL, &apistream) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR error executing sofia_contact\n");
goto end;
}
@@ -246,7 +246,6 @@ static switch_bool_t soundtouch_callback(switch_media_bug_t *bug, void *user_dat
SWITCH_STANDARD_APP(soundtouch_start_function)
{
switch_media_bug_t *bug;
switch_status_t status;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct soundtouch_helper *sth;
char *argv[6];
@@ -311,14 +310,13 @@ SWITCH_STANDARD_APP(soundtouch_start_function)
sth->session = session;
if ((status = switch_core_media_bug_add(session, "soundtouch", NULL, soundtouch_callback, sth, 0,
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
if (switch_core_media_bug_add(session, "soundtouch", NULL, soundtouch_callback, sth, 0,
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
return;
}
switch_channel_set_private(channel, "_soundtouch_", bug);
}
/* API Interface Function */
@@ -327,12 +325,11 @@ SWITCH_STANDARD_API(soundtouch_api_function)
{
switch_core_session_t *rsession = NULL;
switch_channel_t *channel = NULL;
switch_media_bug_t *bug;
switch_status_t status;
struct soundtouch_helper *sth;
switch_media_bug_t *bug;
struct soundtouch_helper *sth;
char *mycmd = NULL;
int argc = 0;
char *argv[10] = { 0 };
int argc = 0;
char *argv[10] = { 0 };
char *uuid = NULL;
char *action = NULL;
int x, n;
@@ -420,8 +417,8 @@ SWITCH_STANDARD_API(soundtouch_api_function)
sth->session = rsession;
if ((status = switch_core_media_bug_add(rsession, "soundtouch", NULL, soundtouch_callback, sth, 0,
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
if (switch_core_media_bug_add(rsession, "soundtouch", NULL, soundtouch_callback, sth, 0,
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Failure!\n");
goto done;
} else {
@@ -1266,32 +1266,29 @@ static t38_mode_t request_t38(pvt_t *pvt)
insist = spandsp_globals.enable_t38_insist;
}
if ((t38_options = switch_channel_get_private(channel, "t38_options"))) {
if (switch_channel_get_private(channel, "t38_options")) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"%s already has T.38 data\n", switch_channel_get_name(channel));
enabled = 0;
}
if (enabled) {
if (!(t38_options = switch_channel_get_private(channel, "_preconfigured_t38_options"))) {
t38_options = switch_core_session_alloc(session, sizeof(*t38_options));
t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400;
t38_options->T38FaxVersion = 0;
t38_options->T38FaxFillBitRemoval = 1;
t38_options->T38FaxTranscodingMMR = 0;
t38_options->T38FaxTranscodingJBIG = 0;
t38_options->T38FaxRateManagement = "transferredTCF";
t38_options->T38FaxMaxBuffer = 2000;
t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM;
t38_options->T38FaxUdpEC = "t38UDPRedundancy";
t38_options->T38VendorInfo = "0 0 0";
}
if (!(t38_options = switch_channel_get_private(channel, "_preconfigured_t38_options"))) {
t38_options = switch_core_session_alloc(session, sizeof(*t38_options));
t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400;
t38_options->T38FaxVersion = 0;
t38_options->T38FaxFillBitRemoval = 1;
t38_options->T38FaxTranscodingMMR = 0;
t38_options->T38FaxTranscodingJBIG = 0;
t38_options->T38FaxRateManagement = "transferredTCF";
t38_options->T38FaxMaxBuffer = 2000;
t38_options->T38FaxMaxDatagram = LOCAL_FAX_MAX_DATAGRAM;
t38_options->T38FaxUdpEC = "t38UDPRedundancy";
t38_options->T38VendorInfo = "0 0 0";
}
switch_channel_set_private(channel, "t38_options", t38_options);
switch_channel_set_private(channel, "_preconfigured_t38_options", NULL);
switch_channel_set_private(channel, "t38_options", t38_options);
switch_channel_set_private(channel, "_preconfigured_t38_options", NULL);
pvt->t38_mode = T38_MODE_REQUESTED;
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_REQ);
+2 -2
View File
@@ -188,7 +188,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
seq_no = (buf[0] << 8) | buf[1];
ptr += 2;
/* Break out the primary packet */
if ((stat = decode_open_type(buf, len, &ptr, &msg, &msg_len)) != 0)
if (decode_open_type(buf, len, &ptr, &msg, &msg_len) != 0)
return -1;
/* Decode error_recovery */
if (ptr + 1 > len)
@@ -290,7 +290,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
/* Decode the elements */
for (i = 0; i < entries; i++) {
if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0)
if (decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i]) != 0)
return -1;
if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM)
return -1;
+1 -2
View File
@@ -286,12 +286,11 @@ static void event_handler(switch_event_t *event)
#define USERSPY_SYNTAX "<user@domain> [uuid]"
SWITCH_STANDARD_APP(userspy_function)
{
int argc = 0;
char *argv[2] = { 0 };
char *params = NULL;
if (!zstr(data) && (params = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
if (switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) >= 1) {
switch_channel_t *channel = switch_core_session_get_channel(session);
char *uuid = switch_core_session_get_uuid(session);
switch_status_t status;
@@ -197,11 +197,9 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
SWITCH_STANDARD_APP(stress_start_function)
{
switch_media_bug_t *bug;
switch_status_t status;
switch_channel_t *channel = switch_core_session_get_channel(session);
struct stress_helper *sth;
char *argv[6];
int argc;
char *lbuf = NULL;
int x = 0;
@@ -220,7 +218,7 @@ SWITCH_STANDARD_APP(stress_start_function)
if (data && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
&& switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) {
if (!strncasecmp(argv[x], "read", 4)) {
sth->read = 1;
}
@@ -228,14 +226,12 @@ SWITCH_STANDARD_APP(stress_start_function)
sth->session = session;
if ((status = switch_core_media_bug_add(session, "stress", NULL, stress_callback, sth, 0,
sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
if (switch_core_media_bug_add(session, "stress", NULL, stress_callback, sth, 0, sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
return;
}
switch_channel_set_private(channel, "_stress_", bug);
}
SWITCH_MODULE_LOAD_FUNCTION(mod_stress_load)
@@ -333,7 +333,6 @@ SWITCH_STANDARD_API(translate_function)
char *translated = NULL;
switch_event_t *event = NULL;
char *argv[32] = { 0 };
int argc = 0;
if (zstr(cmd)) {
stream->write_function(stream, "USAGE: %s\n", TRANSLATE_SYNTAX);
@@ -344,7 +343,7 @@ SWITCH_STANDARD_API(translate_function)
mydata = strdup(cmd);
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) {
if (!session) {
char *areacode = switch_core_get_variable("default_areacode");
switch_core_new_memory_pool(&pool);
@@ -3165,7 +3165,6 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
char *dup = NULL, *user = NULL, *domain = NULL, *profile_name = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
int isgroup = 0, isall = 0;
int argc = 0;
char *argv[6] = { 0 };
char *box, *path, *cid_num, *cid_name;
switch_memory_pool_t *pool = NULL;
@@ -3181,7 +3180,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
dup = strdup(data);
switch_assert(dup);
if ((argc = switch_separate_string(dup, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
if (switch_separate_string(dup, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) < 2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Not enough args [%s]\n", data);
status = SWITCH_STATUS_FALSE;
goto end;
@@ -3338,7 +3337,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
} else {
switch_xml_t x_group = NULL;
if ((status = switch_xml_locate_user_in_domain(user, x_domain, &ut, &x_group)) == SWITCH_STATUS_SUCCESS) {
if (switch_xml_locate_user_in_domain(user, x_domain, &ut, &x_group) == SWITCH_STATUS_SUCCESS) {
switch_xml_merge_user(ut, x_domain, x_group);
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
status = deliver_vm(profile, ut, domain, path, 0, read_flags,