diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 964eef7..15416bc 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,8 +48,7 @@ jobs: scan-build --status-bugs cmake --build build -j"$(nproc)" - clang-tidy -p build $(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx') \ - FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx')" + FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' | grep -v '^buffer/' | grep -v '^libs/')" if [ -n "$FILES" ]; then clang-tidy -p build $FILES \ --warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*' @@ -58,8 +57,19 @@ jobs: fi - cppcheck --enable=warning,style,performance,portability --std=c++17 --force \ + cppcheck --enable=warning,performance,portability --std=c++17 --force \ --project=build/compile_commands.json \ --suppress=missingIncludeSystem \ - -i build . 2> cppcheck.log || true - cat cppcheck.log + -i build -i buffer -i libs 2> cppcheck-warn.log + + cppcheck --enable=style --std=c++17 --force \ + --project=build/compile_commands.json \ + --suppress=missingIncludeSystem \ + -i build -i buffer -i libs 2> cppcheck-style.log || true + + if [ -s cppcheck-style.log ]; then + echo "Style issues found by cppcheck:" + cat cppcheck-style.log + else + echo "No style issues found by cppcheck." + fi diff --git a/openai_audio_streamer_glue.cpp b/openai_audio_streamer_glue.cpp index 98d7652..a8babf4 100644 --- a/openai_audio_streamer_glue.cpp +++ b/openai_audio_streamer_glue.cpp @@ -230,7 +230,10 @@ class AudioStreamer { return out_buffer; } - std::string createWavFromRaw(std::string rawAudio) { + // create wav file from raw audio + // rawAudio passed as constant reference because it is never edited + std::string createWavFromRaw(const std::string& rawAudio) { + const int numChannels = 1; // mono const int bitsPerSample = 16; // pcm16 int byteRate = in_sample_rate * numChannels * bitsPerSample / 8; @@ -1012,7 +1015,9 @@ extern "C" { { auto* tech_pvt = (private_t*) switch_core_media_bug_get_user_data(bug); char sessionId[MAX_SESSION_ID]; - strcpy(sessionId, tech_pvt->sessionId); + + strncpy(sessionId, tech_pvt->sessionId, MAX_SESSION_ID - 1); + sessionId[MAX_SESSION_ID - 1] = '\0'; switch_mutex_lock(tech_pvt->mutex); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "(%s) stream_session_cleanup\n", sessionId);