From ef32d90e91001c39ed261518db423868844a32fd Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Fri, 26 Apr 2024 12:41:07 +0000 Subject: [PATCH] [mod_av] Fix scan-build 14 --- src/mod/applications/mod_av/avcodec.c | 1 - src/mod/applications/mod_av/avformat.c | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_av/avcodec.c b/src/mod/applications/mod_av/avcodec.c index 16d268273b..4f0057264e 100644 --- a/src/mod/applications/mod_av/avcodec.c +++ b/src/mod/applications/mod_av/avcodec.c @@ -1581,7 +1581,6 @@ GCC_DIAG_ON(deprecated-declarations) } else if (ret == AVERROR(EAGAIN)) { /* we fully drain all the output in each encode call, so this should not ever happen */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder - BUG, should never happen\n"); - ret = AVERROR_BUG; goto error; } else if (ret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error sending frame to encoder\n"); diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c index 69475c169f..c1e0052530 100644 --- a/src/mod/applications/mod_av/avformat.c +++ b/src/mod/applications/mod_av/avformat.c @@ -1170,7 +1170,6 @@ GCC_DIAG_ON(deprecated-declarations) } else if (ret == AVERROR(EAGAIN)) { /* we fully drain all the output in each encode call, so this should not ever happen */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder on draining AVERROR_BUG - should never happen\n"); - ret = AVERROR_BUG; goto do_break; } else if (ret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder on draining\n"); @@ -1426,7 +1425,7 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h av_dump_format(context->fc, 0, filename, 0); - for (i = 0; i< context->fc->nb_streams; i++) { + for (i = 0; i < context->fc->nb_streams; i++) { enum AVMediaType codec_type = av_get_codec_type(context->fc->streams[i]); if (codec_type == AVMEDIA_TYPE_AUDIO && context->has_audio < 2 && idx < 2) { @@ -1554,7 +1553,9 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h if (context->has_audio) { AVCodecContext *c[2] = { NULL }; - c[0] = av_get_codec_context(&context->audio_st[0]); + if (!(c[0] = av_get_codec_context(&context->audio_st[0]))) { + switch_goto_status(SWITCH_STATUS_FALSE, err); + } if ((cc = av_get_codec_context(&context->audio_st[1]))) { c[1] = cc; @@ -1568,9 +1569,7 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h if (c[1]) { context->audio_st[1].frame = av_frame_alloc(); switch_assert(context->audio_st[1].frame); - } - if (c[0] && c[1]) { context->audio_st[0].channels = 1; context->audio_st[1].channels = 1; } else { @@ -2016,7 +2015,6 @@ GCC_DIAG_ON(deprecated-declarations) } else if (dret == AVERROR(EAGAIN)) { /* we fully drain all the output in each decode call, so this should not ever happen */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending audio packet to decoder - BUG, should never happen\n"); - dret = AVERROR_BUG; goto do_continue; } else if (dret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending audio packet to decoder\n");