From c47c16b1ddfbbd719c4d7d4970008c8343a67705 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 12 Jan 2022 16:30:34 +0300 Subject: [PATCH] Fix dead nested assignments in various modules --- libs/iksemel/src/stream.c | 4 +-- libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c | 1 + libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c | 1 + .../mod_directory/mod_directory.c | 3 +- .../applications/mod_dptools/mod_dptools.c | 3 +- src/mod/applications/mod_expr/exprilfs.h | 6 ++-- src/mod/applications/mod_fifo/mod_fifo.c | 3 +- src/mod/applications/mod_hash/mod_hash.c | 4 +-- src/mod/applications/mod_httapi/mod_httapi.c | 5 ++- src/mod/applications/mod_oreka/mod_oreka.c | 25 +++++++------ src/mod/applications/mod_redis/credis.c | 6 ++-- src/mod/applications/mod_rss/mod_rss.c | 2 +- .../mod_signalwire/mod_signalwire.c | 3 +- src/mod/applications/mod_snom/mod_snom.c | 3 +- .../mod_soundtouch/mod_soundtouch.cpp | 19 +++++----- .../mod_spandsp/mod_spandsp_fax.c | 35 +++++++++---------- src/mod/applications/mod_spandsp/udptl.c | 4 +-- src/mod/applications/mod_spy/mod_spy.c | 3 +- .../applications/mod_stress/mod_stress.cpp | 8 ++--- .../mod_translate/mod_translate.c | 3 +- .../mod_voicemail/mod_voicemail.c | 5 ++- .../codecs/mod_dahdi_codec/mod_dahdi_codec.c | 4 +-- .../mod_dialplan_asterisk.c | 15 +------- .../endpoints/mod_dingaling/mod_dingaling.c | 6 ++-- .../endpoints/mod_portaudio/mod_portaudio.c | 3 +- src/mod/endpoints/mod_skinny/mod_skinny.c | 2 +- .../mod_event_socket/mod_event_socket.c | 2 +- .../mod_kazoo/kazoo_ei_config.c | 3 +- .../event_handlers/mod_rayo/xmpp_streams.c | 2 +- .../mod_local_stream/mod_local_stream.c | 3 +- .../formats/mod_tone_stream/mod_tone_stream.c | 3 +- src/mod/languages/mod_lua/mod_lua.cpp | 6 ++-- .../mod_python3/freeswitch_python.cpp | 4 +-- src/mod/languages/mod_python3/mod_python3.c | 3 +- 34 files changed, 82 insertions(+), 120 deletions(-) diff --git a/libs/iksemel/src/stream.c b/libs/iksemel/src/stream.c index e05e5d06ef..f304f67c64 100644 --- a/libs/iksemel/src/stream.c +++ b/libs/iksemel/src/stream.c @@ -879,11 +879,11 @@ iks_send_raw (iksparser *prs, const char *xmlstr) } else #elif HAVE_SSL if (data->flags & SF_SECURE) { - int r, err; + int r; do { r = SSL_write(data->ssl, xmlstr, strlen (xmlstr)); - } while (r == -1 && (err = SSL_get_error(data->ssl, r)) == SSL_ERROR_WANT_WRITE); + } while (r == -1 && SSL_get_error(data->ssl, r) == SSL_ERROR_WANT_WRITE); if (r < 0) { return IKS_NET_RWERR; diff --git a/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c b/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c index 3f4f577a21..ac33e160b9 100644 --- a/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c +++ b/libs/libvpx/vpx_dsp/x86/avg_intrin_avx2.c @@ -305,6 +305,7 @@ static void hadamard_8x8x2_avx2(const int16_t *src_diff, ptrdiff_t src_stride, src[5] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); src[6] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); src[7] = _mm256_loadu_si256((const __m256i *)(src_diff += src_stride)); + (void)src_diff; hadamard_col8x2_avx2(src, 0); hadamard_col8x2_avx2(src, 1); diff --git a/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c b/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c index 5aba903a2d..45bfefe08a 100644 --- a/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c +++ b/libs/libvpx/vpx_dsp/x86/avg_intrin_sse2.c @@ -276,6 +276,7 @@ static INLINE void hadamard_8x8_sse2(const int16_t *src_diff, src[5] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); src[6] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); src[7] = _mm_load_si128((const __m128i *)(src_diff += src_stride)); + (void)src_diff; hadamard_col8_sse2(src, 0); hadamard_col8_sse2(src, 1); diff --git a/src/mod/applications/mod_directory/mod_directory.c b/src/mod/applications/mod_directory/mod_directory.c index 3046558c5d..fc46e478da 100644 --- a/src/mod/applications/mod_directory/mod_directory.c +++ b/src/mod/applications/mod_directory/mod_directory.c @@ -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; } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index b9ef0708d8..afe6cbef68 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -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; } diff --git a/src/mod/applications/mod_expr/exprilfs.h b/src/mod/applications/mod_expr/exprilfs.h index f89eadfadc..e881b68d8c 100644 --- a/src/mod/applications/mod_expr/exprilfs.h +++ b/src/mod/applications/mod_expr/exprilfs.h @@ -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; diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 724d1dd24f..304996981a 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -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; } diff --git a/src/mod/applications/mod_hash/mod_hash.c b/src/mod/applications/mod_hash/mod_hash.c index 70bffd18e1..5b987f7fa0 100644 --- a/src/mod/applications/mod_hash/mod_hash.c +++ b/src/mod/applications/mod_hash/mod_hash.c @@ -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]); diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 0b89fd35a7..4b32d87c6d 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -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, ':'))) { diff --git a/src/mod/applications/mod_oreka/mod_oreka.c b/src/mod/applications/mod_oreka/mod_oreka.c index f3fe676386..560c34f6c6 100644 --- a/src/mod/applications/mod_oreka/mod_oreka.c +++ b/src/mod/applications/mod_oreka/mod_oreka.c @@ -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); diff --git a/src/mod/applications/mod_redis/credis.c b/src/mod/applications/mod_redis/credis.c index 58e57ce1cd..040ab3ae83 100644 --- a/src/mod/applications/mod_redis/credis.c +++ b/src/mod/applications/mod_redis/credis.c @@ -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; diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index 5f23024da2..16cd35412b 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -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 = ""; diff --git a/src/mod/applications/mod_signalwire/mod_signalwire.c b/src/mod/applications/mod_signalwire/mod_signalwire.c index 466adfa745..5b0be47a91 100644 --- a/src/mod/applications/mod_signalwire/mod_signalwire.c +++ b/src/mod/applications/mod_signalwire/mod_signalwire.c @@ -464,7 +464,6 @@ done: #define SIGNALWIRE_SYNTAX "token | token-reset | adoption | adopted | reload | update | debug | kslog " 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, diff --git a/src/mod/applications/mod_snom/mod_snom.c b/src/mod/applications/mod_snom/mod_snom.c index 2f706c2556..b3cf2b478e 100644 --- a/src/mod/applications/mod_snom/mod_snom.c +++ b/src/mod/applications/mod_snom/mod_snom.c @@ -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; } diff --git a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp index fc2843440b..05461bc453 100644 --- a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp +++ b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp @@ -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 { diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 2af4babf08..8c8d0103c4 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -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); diff --git a/src/mod/applications/mod_spandsp/udptl.c b/src/mod/applications/mod_spandsp/udptl.c index aa82f953d0..35b9f29f77 100644 --- a/src/mod/applications/mod_spandsp/udptl.c +++ b/src/mod/applications/mod_spandsp/udptl.c @@ -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; diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c index 0200ee9bdf..ced290f0d7 100644 --- a/src/mod/applications/mod_spy/mod_spy.c +++ b/src/mod/applications/mod_spy/mod_spy.c @@ -286,12 +286,11 @@ static void event_handler(switch_event_t *event) #define USERSPY_SYNTAX " [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; diff --git a/src/mod/applications/mod_stress/mod_stress.cpp b/src/mod/applications/mod_stress/mod_stress.cpp index 791ad06f89..66da2d26dc 100644 --- a/src/mod/applications/mod_stress/mod_stress.cpp +++ b/src/mod/applications/mod_stress/mod_stress.cpp @@ -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) diff --git a/src/mod/applications/mod_translate/mod_translate.c b/src/mod/applications/mod_translate/mod_translate.c index 3e7402c30d..efbcd3f14b 100644 --- a/src/mod/applications/mod_translate/mod_translate.c +++ b/src/mod/applications/mod_translate/mod_translate.c @@ -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); diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 0dc84b34ce..6ece9f4f47 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -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, diff --git a/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c b/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c index df09429ced..6e7f15428c 100644 --- a/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c +++ b/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c @@ -440,7 +440,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load) switch_codec_interface_t *codec_interface; struct stat statbuf; struct dahdi_transcoder_info info = { 0 }; - int32_t fd, res; + int32_t fd; int mpf = 20000; /* Algorithmic delay of 15ms with 5ms of look-ahead delay */ int spf = 160; int bpfd = 320; @@ -472,7 +472,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load) return SWITCH_STATUS_FALSE; } - for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) { + for (info.tcnum = 0; !ioctl(fd, DAHDI_TC_GETINFO, &info); info.tcnum++) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found dahdi transcoder name: %s\n", info.name); if ((info.srcfmts & DAHDI_FORMAT_ULAW) && (info.dstfmts & (DAHDI_FORMAT_G729A | DAHDI_FORMAT_G723_1))) { total_encoders += info.numchannels; diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c index 691b640a78..24119f6f8c 100644 --- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c +++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c @@ -103,12 +103,11 @@ SWITCH_STANDARD_APP(avoid_function) SWITCH_STANDARD_APP(goto_function) { - int argc; char *argv[3] = { 0 }; char *mydata; if (data && (mydata = switch_core_session_strdup(session, data))) { - if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 1) { + if (switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0]))) < 1) { goto error; } @@ -352,24 +351,12 @@ static switch_call_cause_t iax2_outgoing_channel(switch_core_session_t *session, return switch_core_session_outgoing_channel(session, var_event, "iax", outbound_profile, new_session, pool, SOF_NONE, cancel_cause); } - -#define WE_DONT_NEED_NO_STINKIN_KEY "true" -static char *key() -{ - return WE_DONT_NEED_NO_STINKIN_KEY; -} - SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_asterisk_load) { switch_dialplan_interface_t *dp_interface; switch_application_interface_t *app_interface; - char *mykey = NULL; int x = 0; - if ((mykey = key())) { - mykey = NULL; - } - /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); /* add a dialplan interface */ diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 99a6587409..6b1728ebe5 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -883,10 +883,9 @@ static void dl_logger(char *file, const char *func, int line, int level, char *f { va_list ap; char *data = NULL; - int ret; va_start(ap, fmt); - if ((ret = switch_vasprintf(&data, fmt, ap)) != -1) { + if (switch_vasprintf(&data, fmt, ap) != -1) { if (!strncasecmp(data, "+xml:", 5)) { switch_xml_t xml; char *form; @@ -3062,7 +3061,6 @@ SWITCH_STANDARD_API(dl_logout) SWITCH_STANDARD_API(dingaling) { char *argv[10] = { 0 }; - int argc = 0; void *val; char *myarg = NULL; mdl_profile_t *profile = NULL; @@ -3077,7 +3075,7 @@ SWITCH_STANDARD_API(dingaling) return SWITCH_STATUS_FALSE; } - if ((argc = switch_separate_string(myarg, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 1) { + if (switch_separate_string(myarg, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) != 1) { stream->write_function(stream, "USAGE: %s\n", DINGALING_SYNTAX); goto done; } diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 0e24faef16..62eba524d3 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -2962,7 +2962,6 @@ static switch_status_t list_calls(char **argv, int argc, switch_stream_handle_t static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t *stream) { switch_core_session_t *session; - switch_status_t status = SWITCH_STATUS_SUCCESS; char *dest = NULL; if (zstr(argv[0])) { @@ -3025,7 +3024,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } tech_pvt->session = session; - if ((status = validate_main_audio_stream()) == SWITCH_STATUS_SUCCESS) { + if (validate_main_audio_stream() == SWITCH_STATUS_SUCCESS) { switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); switch_channel_mark_answered(channel); switch_channel_set_state(channel, CS_INIT); diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 3df1290047..c6cfc716c7 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -2056,7 +2056,7 @@ sock_fail: assert(profile->sock); - if ((rv = switch_socket_accept(&inbound_socket, profile->sock, listener_pool))) { + if (switch_socket_accept(&inbound_socket, profile->sock, listener_pool)) { if (!skinny_globals.running) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n"); goto end; diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 0b01e55e66..70331a95e2 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -3007,7 +3007,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) } - if ((rv = switch_socket_accept(&inbound_socket, listen_list.sock, listener_pool))) { + if (switch_socket_accept(&inbound_socket, listen_list.sock, listener_pool)) { if (prefs.done) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n"); goto end; diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c b/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c index b2f3baf963..f1726b677b 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c @@ -53,7 +53,6 @@ static int read_cookie_from_file(char *filename) { char cookie[MAXATOMLEN + 1]; char *end; struct stat buf; - ssize_t res; if (!stat(filename, &buf)) { if ((buf.st_mode & S_IRWXG) || (buf.st_mode & S_IRWXO)) { @@ -70,7 +69,7 @@ static int read_cookie_from_file(char *filename) { return 2; } - if ((res = read(fd, cookie, MAXATOMLEN)) < 1) { + if (read(fd, cookie, MAXATOMLEN) < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to read cookie file %s : %d.\n", filename, errno); } diff --git a/src/mod/event_handlers/mod_rayo/xmpp_streams.c b/src/mod/event_handlers/mod_rayo/xmpp_streams.c index e8e9f6487d..c78fff78e3 100644 --- a/src/mod/event_handlers/mod_rayo/xmpp_streams.c +++ b/src/mod/event_handlers/mod_rayo/xmpp_streams.c @@ -1589,7 +1589,7 @@ static void *SWITCH_THREAD_FUNC xmpp_listener_thread(switch_thread_t *thread, vo } /* accept the connection */ - if ((rv = switch_socket_accept(&socket, listener->socket, pool))) { + if (switch_socket_accept(&socket, listener->socket, pool)) { if (context->shutdown) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting down xmpp listener\n"); goto end; diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index 2587313c36..b3898ab200 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -1367,7 +1367,6 @@ SWITCH_STANDARD_API(local_stream_function) char *mycmd = NULL, *argv[5] = { 0 }; char *local_stream_name = NULL; int argc = 0; - int ok = 0; if (zstr(cmd)) { goto usage; @@ -1461,7 +1460,7 @@ SWITCH_STANDARD_API(local_stream_function) stream->write_function(stream, "+OK stream: %s", source->name); switch_thread_rwlock_unlock(source->rwlock); } else { - if ((ok = launch_streams(local_stream_name))) { + if (launch_streams(local_stream_name)) { stream->write_function(stream, "+OK stream: %s", local_stream_name); } } diff --git a/src/mod/formats/mod_tone_stream/mod_tone_stream.c b/src/mod/formats/mod_tone_stream/mod_tone_stream.c index e3d5d26074..412baacf1d 100644 --- a/src/mod/formats/mod_tone_stream/mod_tone_stream.c +++ b/src/mod/formats/mod_tone_stream/mod_tone_stream.c @@ -130,7 +130,6 @@ static switch_status_t tone_stream_file_open(switch_file_handle_t *handle, const char *tmp; int fd = -1; char buf[1024] = ""; - size_t len; memset(&ts, 0, sizeof(ts)); @@ -172,7 +171,7 @@ static switch_status_t tone_stream_file_open(switch_file_handle_t *handle, const return SWITCH_STATUS_FALSE; } - while ((len = switch_fd_read_line(fd, buf, sizeof(buf)))) { + while (switch_fd_read_line(fd, buf, sizeof(buf))) { teletone_run(&ts, buf); } close(fd); diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp index 63aaf25fc0..b1d19428dc 100644 --- a/src/mod/languages/mod_lua/mod_lua.cpp +++ b/src/mod/languages/mod_lua/mod_lua.cpp @@ -241,7 +241,6 @@ static switch_xml_t lua_fetch(const char *section, if (!zstr(globals.xml_handler)) { L = lua_init(); const char *str; - int error; mycmd = strdup(globals.xml_handler); switch_assert(mycmd); @@ -266,7 +265,7 @@ static switch_xml_t lua_fetch(const char *section, mod_lua_conjure_event(L, params, "params", 1); } - if((error = lua_parse_and_execute(L, mycmd, NULL))){ + if(lua_parse_and_execute(L, mycmd, NULL)){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n"); goto end; } @@ -522,7 +521,6 @@ SWITCH_STANDARD_API(lua_api_function) { char *mycmd; - int error; if (zstr(cmd)) { stream->write_function(stream, ""); @@ -541,7 +539,7 @@ SWITCH_STANDARD_API(lua_api_function) mod_lua_conjure_event(L, stream->param_event, "env", 1); } - if ((error = lua_parse_and_execute(L, mycmd, session))) { + if (lua_parse_and_execute(L, mycmd, session)) { char * http = switch_event_get_header(stream->param_event, "http-uri"); if (http && (!strncasecmp(http, "/api/", 5) || !strncasecmp(http, "/webapi/", 8))) { /* api -> fs api streams the Content-Type e.g. text/html or text/xml */ diff --git a/src/mod/languages/mod_python3/freeswitch_python.cpp b/src/mod/languages/mod_python3/freeswitch_python.cpp index 0893c47c91..77c04fa9fc 100644 --- a/src/mod/languages/mod_python3/freeswitch_python.cpp +++ b/src/mod/languages/mod_python3/freeswitch_python.cpp @@ -144,7 +144,7 @@ void Session::check_hangup_hook() void Session::do_hangup_hook() { - PyObject *result, *arglist; + PyObject *arglist; const char *what = hook_state == CS_HANGUP ? "hangup" : "transfer"; if (hh && !mark) { @@ -167,7 +167,7 @@ void Session::do_hangup_hook() arglist = Py_BuildValue("(Os)", Self, what); } - if (!(result = PyEval_CallObject(hangup_func, arglist))) { + if (!PyEval_CallObject(hangup_func, arglist)) { PyErr_Print(); } diff --git a/src/mod/languages/mod_python3/mod_python3.c b/src/mod/languages/mod_python3/mod_python3.c index d0c7c20df5..52a3312361 100644 --- a/src/mod/languages/mod_python3/mod_python3.c +++ b/src/mod/languages/mod_python3/mod_python3.c @@ -178,7 +178,6 @@ static void eval_some_python(const char *funcname, char *args, switch_core_sessi PyThreadState *tstate = NULL; char *dupargs = NULL; char *argv[2] = { 0 }; - int argc; char *script = NULL; PyObject *module_o = NULL, *module = NULL, *sp = NULL, *stp = NULL, *eve = NULL; PyObject *function = NULL; @@ -198,7 +197,7 @@ static void eval_some_python(const char *funcname, char *args, switch_core_sessi assert(dupargs != NULL); - if (!(argc = switch_separate_string(dupargs, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { + if (!switch_separate_string(dupargs, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No module name specified!\n"); goto done; }