From 04557496d79d92f1f2d281a33432a0dd7f627d36 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Wed, 20 Aug 2025 22:51:02 +0200 Subject: [PATCH 1/5] Fix missed old clang-tidy failing Signed-off-by: Dario Pellegrino --- .github/workflows/checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 964eef7..5b59e3d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,6 @@ 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')" if [ -n "$FILES" ]; then clang-tidy -p build $FILES \ From 429c64a8637af8b9f199f13cea8b1827c448e9c0 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Thu, 21 Aug 2025 10:37:31 +0200 Subject: [PATCH 2/5] Fix strcpy warn and avoid legacy ringbuffer static checks Signed-off-by: Dario Pellegrino --- .github/workflows/checks.yml | 4 ++-- openai_audio_streamer_glue.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5b59e3d..78b6c65 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,7 @@ jobs: scan-build --status-bugs cmake --build build -j"$(nproc)" - FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx')" + FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' | grep -v '^buffer/')" if [ -n "$FILES" ]; then clang-tidy -p build $FILES \ --warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*' @@ -60,5 +60,5 @@ jobs: cppcheck --enable=warning,style,performance,portability --std=c++17 --force \ --project=build/compile_commands.json \ --suppress=missingIncludeSystem \ - -i build . 2> cppcheck.log || true + -i build -i buffer . 2> cppcheck.log || true cat cppcheck.log diff --git a/openai_audio_streamer_glue.cpp b/openai_audio_streamer_glue.cpp index 98d7652..b8ea318 100644 --- a/openai_audio_streamer_glue.cpp +++ b/openai_audio_streamer_glue.cpp @@ -1012,7 +1012,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); From 603a06fe14802ca2eedb4b65c815d177a6a3c27f Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Thu, 21 Aug 2025 11:14:53 +0200 Subject: [PATCH 3/5] Fix cppcheck ci Signed-off-by: Dario Pellegrino --- .github/workflows/checks.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 78b6c65..580e8a3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,7 @@ jobs: scan-build --status-bugs cmake --build build -j"$(nproc)" - FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' | grep -v '^buffer/')" + 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-*' @@ -57,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 -i buffer . 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 From a79ff62d8bc8426b309f00ae58dc5c049c4a9bc0 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Thu, 21 Aug 2025 11:16:25 +0200 Subject: [PATCH 4/5] Fix write audio performance issues Signed-off-by: Dario Pellegrino --- openai_audio_streamer_glue.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openai_audio_streamer_glue.cpp b/openai_audio_streamer_glue.cpp index b8ea318..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; From 8b1f90dd3fd7fcad39ec9dcda15f0628553ce0be Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Thu, 21 Aug 2025 11:27:17 +0200 Subject: [PATCH 5/5] Fix cppcheck included paths Signed-off-by: Dario Pellegrino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 580e8a3..15416bc 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -60,12 +60,12 @@ jobs: cppcheck --enable=warning,performance,portability --std=c++17 --force \ --project=build/compile_commands.json \ --suppress=missingIncludeSystem \ - -i build -i buffer -i libs . 2> cppcheck-warn.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 + -i build -i buffer -i libs 2> cppcheck-style.log || true if [ -s cppcheck-style.log ]; then echo "Style issues found by cppcheck:"