From: Andrey Volk Date: Fri, 12 Jul 2019 16:10:11 +0000 (+0400) Subject: FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_native_file X-Git-Tag: v1.10.0~266 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8861e1cbade96679868f74c9fdac1c73d5e45d8;p=thirdparty%2Ffreeswitch.git FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_native_file --- diff --git a/src/mod/formats/mod_native_file/mod_native_file.c b/src/mod/formats/mod_native_file/mod_native_file.c index 4d406c3e1b..585109351e 100644 --- a/src/mod/formats/mod_native_file/mod_native_file.c +++ b/src/mod/formats/mod_native_file/mod_native_file.c @@ -75,6 +75,8 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const return SWITCH_STATUS_GENERR; } + handle->pos = 0; + if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) { int64_t samples = 0; switch_file_seek(context->fd, SEEK_END, &samples); @@ -84,10 +86,8 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const handle->samples = 0; handle->samplerate = 8000; - if (ext) { - if (!strcasecmp(ext, "G722")) { - handle->samplerate = 16000; - } + if (!strcasecmp(ext, "G722")) { + handle->samplerate = 16000; } handle->channels = 1; @@ -95,7 +95,6 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const handle->sections = 0; handle->seekable = 1; handle->speed = 0; - handle->pos = 0; handle->private_info = context; handle->flags |= SWITCH_FILE_NATIVE; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);