From d24133372adb96733975647ac0425edaa1a96266 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 16 May 2023 11:17:28 -0400 Subject: [PATCH] MT#55283 move declarations to eliminate shadowing Change-Id: Iff73629ef2d515429e7080cafa7deb89a802d16c --- daemon/call_interfaces.c | 6 ++++-- daemon/cli.c | 2 +- daemon/codec.c | 3 +-- daemon/jitter_buffer.c | 2 +- daemon/mqtt.c | 6 +++--- daemon/redis.c | 6 +++--- daemon/statistics.c | 2 +- lib/codeclib.c | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index fb7841be1..132d082d1 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1317,9 +1317,11 @@ static void call_ng_parse_block_mode(str *s, enum block_dtmf_mode *output) { #endif static void call_ng_flags_freqs(struct sdp_ng_flags *out, bencode_item_t *value) { + unsigned int val; + switch (value->type) { case BENCODE_INTEGER:; - unsigned int val = value->value; + val = value->value; g_array_append_val(out->frequencies, val); break; case BENCODE_LIST: @@ -1330,7 +1332,7 @@ static void call_ng_flags_freqs(struct sdp_ng_flags *out, bencode_item_t *value) str s, token; bencode_get_str(value, &s); while (str_token_sep(&token, &s, ',') == 0) { - unsigned int val = str_to_i(&token, 0); + val = str_to_i(&token, 0); g_array_append_val(out->frequencies, val); } break; diff --git a/daemon/cli.c b/daemon/cli.c index e682e3a2b..b2b3f2cd9 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -225,7 +225,6 @@ static void cli_handler_do(const cli_handler_t *handlers, str *instr, } static void destroy_own_foreign_calls(bool foreign_call, unsigned int uint_keyspace_db) { - struct call *c = NULL; struct call_monologue *ml = NULL; GQueue call_list = G_QUEUE_INIT; GList *i; @@ -250,6 +249,7 @@ next:; ITERATE_CALL_LIST_NEXT_END(c); // destroy calls + struct call *c = NULL; while ((c = g_queue_pop_head(&call_list))) { if (!c->ml_deleted) { for (i = c->monologues.head; i; i = i->next) { diff --git a/daemon/codec.c b/daemon/codec.c index f2699c4ac..2a3a7bb02 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1958,8 +1958,7 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch, p->ttq_entry.when = csch->first_send; uint32_t ts_diff = (uint32_t) ts - (uint32_t) csch->first_send_ts; // allow for wrap-around ts_diff += ts_delay; - long long ts_diff_us = - (unsigned long long) ts_diff * 1000000 / handler->dest_pt.clock_rate; + ts_diff_us = (unsigned long long) ts_diff * 1000000 / handler->dest_pt.clock_rate; timeval_add_usec(&p->ttq_entry.when, ts_diff_us); // how far in the future is this? diff --git a/daemon/jitter_buffer.c b/daemon/jitter_buffer.c index 040b1f2e6..0ebf082a2 100644 --- a/daemon/jitter_buffer.c +++ b/daemon/jitter_buffer.c @@ -294,7 +294,7 @@ int buffer_packet(struct media_packet *mp, const str *s) { else { // store data from first packet and use for successive packets and queue the first packet unsigned long ts = ntohl(mp->rtp->timestamp); - int payload_type = (mp->rtp->m_pt & 0x7f); + payload_type = (mp->rtp->m_pt & 0x7f); int clockrate = get_clock_rate(mp, payload_type); if(!clockrate){ if(jb->rtptime_delta && payload_type != COMFORT_NOISE) { //ignore CN diff --git a/daemon/mqtt.c b/daemon/mqtt.c index 31a1bce72..c5b79c30c 100644 --- a/daemon/mqtt.c +++ b/daemon/mqtt.c @@ -54,7 +54,7 @@ static int mqtt_connect(void) { mosquitto_threaded_set(mosq, true); if (rtpe_config.mqtt_user) { - int ret = mosquitto_username_pw_set(mosq, rtpe_config.mqtt_user, rtpe_config.mqtt_pass); + ret = mosquitto_username_pw_set(mosq, rtpe_config.mqtt_user, rtpe_config.mqtt_pass); if (ret != MOSQ_ERR_SUCCESS) { ilog(LOG_ERR, "Failed to set mosquitto user/pass auth: %s", mosquitto_strerror(errno)); return -1; @@ -62,7 +62,7 @@ static int mqtt_connect(void) { } if (rtpe_config.mqtt_cafile || rtpe_config.mqtt_capath) { - int ret = mosquitto_tls_set(mosq, rtpe_config.mqtt_cafile, rtpe_config.mqtt_capath, + ret = mosquitto_tls_set(mosq, rtpe_config.mqtt_cafile, rtpe_config.mqtt_capath, rtpe_config.mqtt_certfile, rtpe_config.mqtt_keyfile, NULL); if (ret != MOSQ_ERR_SUCCESS) { ilog(LOG_ERR, "Failed to set mosquitto TLS options: %s", mosquitto_strerror(errno)); @@ -72,7 +72,7 @@ static int mqtt_connect(void) { if (rtpe_config.mqtt_tls_alpn) { #if LIBMOSQUITTO_VERSION_NUMBER >= 1006000 - int ret = mosquitto_string_option(mosq, MOSQ_OPT_TLS_ALPN, rtpe_config.mqtt_tls_alpn); + ret = mosquitto_string_option(mosq, MOSQ_OPT_TLS_ALPN, rtpe_config.mqtt_tls_alpn); if (ret != MOSQ_ERR_SUCCESS) { ilog(LOG_ERR, "Failed to set mosquitto TLS ALPN options: %s", mosquitto_strerror(errno)); return -1; diff --git a/daemon/redis.c b/daemon/redis.c index 91df25f30..020234c90 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2175,7 +2175,7 @@ static void restore_thread(void *call_p, void *ctx_p) { int redis_restore(struct redis *r, bool foreign, int db) { redisReply *calls = NULL, *call; - int i, ret = -1; + int ret = -1; GThreadPool *gtp; struct thread_ctx ctx; @@ -2218,12 +2218,12 @@ int redis_restore(struct redis *r, bool foreign, int db) { mutex_init(&ctx.r_m); g_queue_init(&ctx.r_q); ctx.foreign = foreign; - for (i = 0; i < rtpe_config.redis_num_threads; i++) + for (int i = 0; i < rtpe_config.redis_num_threads; i++) g_queue_push_tail(&ctx.r_q, redis_dup(r, db)); gtp = g_thread_pool_new(restore_thread, &ctx, rtpe_config.redis_num_threads, TRUE, NULL); - for (i = 0; i < calls->elements; i++) { + for (int i = 0; i < calls->elements; i++) { call = calls->element[i]; if (call->type != REDIS_REPLY_STRING) continue; diff --git a/daemon/statistics.c b/daemon/statistics.c index caff1fc7a..bb3d12872 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -592,7 +592,7 @@ GQueue *statistics_gather_metrics(struct interface_sampled_rate_stats *interface HEADER("{", NULL); - GString *tmp = g_string_new(""); + tmp = g_string_new(""); METRICsva("proxy", "\"%s\"", sockaddr_print_buf(&cur->proxy)); g_string_append_printf(tmp, " %20s ", sockaddr_print_buf(&cur->proxy)); for (int i = 0; i < NGC_COUNT; i++) { diff --git a/lib/codeclib.c b/lib/codeclib.c index 6b60e67fc..ed454a79c 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -4027,7 +4027,7 @@ static const char *evs_encoder_init(encoder_t *enc, const str *extra_opts) { else { mode &= 0xff; mode = evs_clamp_mode_by_bw(mode, enc->codec_options.evs.max_bw); - int bitrate = evs_mode_bitrates[0][mode]; + bitrate = evs_mode_bitrates[0][mode]; ilog(LOG_INFO, "EVS: using bitrate %i instead of %i as restricted by BW %i", bitrate, enc->bitrate, enc->codec_options.evs.max_bw); enc->bitrate = bitrate;