From b13c4a0fd0519bb7e239b98999f791fab19a94ec Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Thu, 11 Jun 2026 12:08:50 +0200 Subject: [PATCH 1/7] [core][build] A collection of small detailed fixes and cleanups --- configure-data.tcl | 32 +++++-- scripts/codespell.sh | 83 +++++++++++++++++++ scripts/mafread.tcl | 1 + scripts/win-installer/build-win-installer.ps1 | 10 ++- srtcore/api.cpp | 2 +- srtcore/core.cpp | 3 +- srtcore/core.h | 3 +- srtcore/packet.cpp | 2 +- srtcore/packet.h | 8 +- test/test_bonding.cpp | 6 +- 10 files changed, 127 insertions(+), 23 deletions(-) create mode 100755 scripts/codespell.sh diff --git a/configure-data.tcl b/configure-data.tcl index d7b9d4937..aba499cc9 100644 --- a/configure-data.tcl +++ b/configure-data.tcl @@ -240,6 +240,20 @@ proc GetCompilerCmdName {compiler lang} { return $compiler${suffix} } +proc have-option name { + return [info exists ::optval($name)] +} + +proc is-option {name value} { + if {![have-option $name]} { + return no + } + if {$::optval($name) eq $value} { + return yes + } + return no +} + proc GetCompilerCommand { {lang {}} } { # Expect that the compiler was set through: # --with-compiler-prefix @@ -247,11 +261,11 @@ proc GetCompilerCommand { {lang {}} } { # (cmake-toolchain-file will set things up without the need to check things here) set compiler gcc - if { [info exists ::optval(--with-compiler-type)] } { + if { [have-option --with-compiler-type] } { set compiler $::optval(--with-compiler-type) } - if { [info exists ::optval(--with-compiler-prefix)] } { + if { [have-option --with-compiler-prefix] } { set prefix $::optval(--with-compiler-prefix) return ${prefix}[GetCompilerCmdName $compiler $lang] } else { @@ -259,17 +273,17 @@ proc GetCompilerCommand { {lang {}} } { } if { $lang != "c++" } { - if { [info exists ::optval(--cmake-c-compiler)] } { + if { [have-option --cmake-c-compiler] } { return $::optval(--cmake-c-compiler) } } if { $lang != "c" } { - if { [info exists ::optval(--cmake-c++-compiler)] } { + if { [have-option --cmake-c++-compiler] } { return $::optval(--cmake-c++-compiler) } - if { [info exists ::optval(--cmake-cxx-compiler)] } { + if { [have-option --cmake-cxx-compiler] } { return $::optval(--cmake-cxx-compiler) } } @@ -340,12 +354,12 @@ proc postprocess {} { # Complete the variables before calling cmake, otherwise it might not work - if { [info exists ::optval(--with-compiler-type)] } { - if { ![info exists ::optval(--cmake-c-compiler)] } { + if { [have-option --with-compiler-type] || [have-option --with-compiler-prefix] } { + if { ![have-option --cmake-c-compiler] } { lappend ::cmakeopt "-DCMAKE_C_COMPILER=[GetCompilerCommand c]" } - if { ![info exists ::optval(--cmake-c++-compiler)] } { + if { ![have-option --cmake-c++-compiler] } { lappend ::cmakeopt "-DCMAKE_CXX_COMPILER=[GetCompilerCommand c++]" } } @@ -439,7 +453,7 @@ proc postprocess {} { if { $::HAVE_DARWIN && !$toolchain_changed } { set use_brew 1 } - if { [info exists ::optval(--use-enclib)] && $::optval(--use-enclib) == "botan"} { + if {[is-option --use-enclib botan]} { set use_brew 0 } diff --git a/scripts/codespell.sh b/scripts/codespell.sh new file mode 100755 index 000000000..ed558ad57 --- /dev/null +++ b/scripts/codespell.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +if [[ -z `type -p codespell` ]]; then + echo >&2 "You need 'codespell' app to run the spell check." + echo >&2 "Follow instructions in CONTRIBUTING.md document" + exit 1 +fi + +function showhelp() +{ + echo "Usage: `basename $0` " + echo "" + echo "WORK MODES:" + echo " * show [default] - only show spelling errors" + echo " * fix - write spelling error fixes directly to files" + echo " * check - like fix, but ask user to confirm ambiguous fix" + echo " * review - like fix, but ask user for every modification" + echo "TARGETS:" + echo " * all [default] - check all files in the repository (including index)" + echo " * changed - check only files currently modified in the repository" +} + + +# Check if the script is run inside the repository view +GIT_TOP=`git rev-parse --show-toplevel` || (echo >&2 "Please run this script in the SRT repository directory"; exit) + +# Forcefully enter the top repo dir; this is the only directory where it should be run +cd $GIT_TOP + +WORKMODE=${1:-show} +EXTRACTION=${2:-all} + +CS_OPTIONS= + +case $WORKMODE in + help | --help) + showhelp + exit + ;; + show) + ;; + + fix) + CS_OPTIONS="-w " + ;; + + check) + CS_OPTIONS="-w -i 2" + ;; + + review) + CS_OPTIONS="-w -i 1" + ;; + + *) + echo >&2 "Unknown mode. Use 'help' to list available options." + exit 1 + ;; +esac + +CS_FILES= + +if [[ $EXTRACTION == "all" ]]; then + CS_FILES="git ls-files" +elif [[ $EXTRACTION == "changed" ]]; then + CS_FILES="git ls-files -m" +else + echo >&2 "Unknown extractopn spec '$EXTRACTION'. Use 'all' or 'changed'" + exit 1 +fi + +# Unfortunately this isn't Tcl, so we need to do it "space safe" way. +declare -a FILELIST +eval FILELIST=( $($CS_FILES | awk "{print \"'\" \$1 \"'\"}") ) + +if [[ -z ${FILELIST[@]} ]]; then + echo "SPELLCHECK: no files listed, not checking." + exit 0 +fi + +#echo Running in files from $CS_FILE: $FILELIST + +codespell --config scripts/codespell/codespell.cfg $CS_OPTIONS ${FILELIST[@]} diff --git a/scripts/mafread.tcl b/scripts/mafread.tcl index e5e1239fe..36d499fe5 100755 --- a/scripts/mafread.tcl +++ b/scripts/mafread.tcl @@ -25,6 +25,7 @@ set insection 0 while { [gets $fd line] >= 0 } { set oline [string trim $line] if { $oline == "" } { + set insection no continue } diff --git a/scripts/win-installer/build-win-installer.ps1 b/scripts/win-installer/build-win-installer.ps1 index c788e01ab..8141b50a2 100644 --- a/scripts/win-installer/build-win-installer.ps1 +++ b/scripts/win-installer/build-win-installer.ps1 @@ -10,9 +10,15 @@ #----------------------------------------------------------------------------- <# - .SYNOPSIS +.DESCRIPTION - Build the SRT static libraries installer for Windows. +Build the SRT static libraries installer for Windows. + +See README.md for usage details and prerequisites. + +.SYNOPSIS + + .\build-win-installer.ps1 [-Version DESIRED_VERSION] [-NoBuild] [-NoPause] .PARAMETER Version diff --git a/srtcore/api.cpp b/srtcore/api.cpp index 7b5709571..438deb9de 100644 --- a/srtcore/api.cpp +++ b/srtcore/api.cpp @@ -2990,7 +2990,7 @@ void srt::CUDTUnited::removeSocket(const SRTSOCKET u) return; } - HLOGC(smlog.Note, log << "@" << s->m_SocketID << " busy=" << s->isStillBusy()); + HLOGC(smlog.Debug, log << "@" << s->m_SocketID << " busy=" << s->isStillBusy()); #if ENABLE_BONDING if (s->m_GroupOf) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index e4577a27d..81c0bc4d9 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -7321,7 +7321,8 @@ int srt::CUDT::receiveMessage(char* data, int len, SRT_MSGCTRL& w_mctrl, int by_ ? m_pRcvBuffer->readMessage(data, len, &w_mctrl) : 0; leaveCS(m_RcvBufferLock); - HLOGC(arlog.Debug, log << CONID() << "AFTER readMsg: (NON-BLOCKING) result=" << res); + HLOGC(arlog.Debug, log << CONID() << "receiveMessage: AFTER readMessage: (NON-BLOCKING) result=" << res + << " %" << w_mctrl.pktseq << " #" << w_mctrl.msgno); if (res == 0) { diff --git a/srtcore/core.h b/srtcore/core.h index a4a9acaee..31cedbd4f 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -149,10 +149,9 @@ enum SeqPairItems }; -// Extended SRT Congestion control class - only an incomplete definition required -class CCryptoControl; namespace srt { +class CCryptoControl; class CUDTUnited; class CUDTSocket; #if ENABLE_BONDING diff --git a/srtcore/packet.cpp b/srtcore/packet.cpp index e0b1edfb3..5cb64a58e 100644 --- a/srtcore/packet.cpp +++ b/srtcore/packet.cpp @@ -585,7 +585,7 @@ inline void SprintSpecialWord(std::ostream& os, int32_t val) } #if ENABLE_LOGGING -std::string CPacket::Info() +std::string CPacket::Info() const { std::ostringstream os; os << "TARGET=@" << id() << " "; diff --git a/srtcore/packet.h b/srtcore/packet.h index 6747e244c..197f28c17 100644 --- a/srtcore/packet.h +++ b/srtcore/packet.h @@ -391,11 +391,11 @@ class CPacket uint32_t header(SrtPktHeaderFields field) const { return m_nHeader[field]; } #if ENABLE_LOGGING - std::string MessageFlagStr() { return PacketMessageFlagStr(m_nHeader[SRT_PH_MSGNO]); } - std::string Info(); + std::string MessageFlagStr() const { return PacketMessageFlagStr(m_nHeader[SRT_PH_MSGNO]); } + std::string Info() const; #else - std::string MessageFlagStr() { return std::string(); } - std::string Info() { return std::string(); } + std::string MessageFlagStr() const { return std::string(); } + std::string Info() const { return std::string(); } #endif }; diff --git a/test/test_bonding.cpp b/test/test_bonding.cpp index fa20b6098..79093683d 100644 --- a/test/test_bonding.cpp +++ b/test/test_bonding.cpp @@ -534,15 +534,15 @@ TEST(Bonding, Options) EXPECT_NE(srt_getsockflag(grp, SRTO_KMSTATE, &kms, &optsize), SRT_ERROR); EXPECT_EQ(optsize, (int) sizeof kms); - EXPECT_EQ(kms, int(SRT_KM_S_SECURED)); + EXPECT_EQ(kms, int32_t(SRT_KM_S_SECURED)); EXPECT_NE(srt_getsockflag(grp, SRTO_PBKEYLEN, &kms, &optsize), SRT_ERROR); EXPECT_EQ(optsize, (int) sizeof kms); - EXPECT_EQ(kms, 16); + EXPECT_EQ(kms, int32_t(16)); #ifdef ENABLE_AEAD_API_PREVIEW EXPECT_NE(srt_getsockflag(grp, SRTO_CRYPTOMODE, &kms, &optsize), SRT_ERROR); - EXPECT_EQ(optsize, sizeof kms); + EXPECT_EQ(optsize, int(sizeof kms)); EXPECT_EQ(kms, 1); #endif #endif From 117ef5b025f8a2e990a28399e05929581bbf74cb Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Mon, 15 Jun 2026 13:38:09 +0200 Subject: [PATCH 2/7] Fixed related to mpbond testing --- srtcore/group.cpp | 2 ++ testing/srt-test-mpbond.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/srtcore/group.cpp b/srtcore/group.cpp index b873bb710..2fbf31419 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -365,6 +365,8 @@ void CUDTGroup::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen) throw CUDTException(MJ_NOTSUP, MN_INVAL, 0); case SRTO_SENDER: // deprecated (1.2.0 version legacy) + return; // simply ignore - groups can't be used with HSv4 anyway. + case SRTO_IPV6ONLY: // link-type specific case SRTO_RENDEZVOUS: // socket-only case SRTO_BINDTODEVICE: // socket-specific diff --git a/testing/srt-test-mpbond.cpp b/testing/srt-test-mpbond.cpp index 3635ff585..ed63ca6a1 100644 --- a/testing/srt-test-mpbond.cpp +++ b/testing/srt-test-mpbond.cpp @@ -182,14 +182,32 @@ int main( int argc, char** argv ) Verb() << "LISTENERS [ " << VerbNoEOL; + map attr; for (size_t i = 0; i < args.size(); ++i) { UriParser u(args[i], UriParser::EXPECT_HOST); + if (!u.parameters().empty()) + { + attr = u.parameters(); + attr["mode"] = "listener"; + } + sockaddr_any sa = CreateAddr(u.host(), u.portno()); SRTSOCKET s = srt_create_socket(); srt::setopt(s)[SRTO_GROUPCONNECT] = 1; + + vector fails; + SrtConfigurePre(s, "", attr, &fails); + if (!fails.empty()) + { + cerr << "\nERROR: failure: " << args[i] << ":\n"; + for (auto& si: fails) + cerr << "\t" << si << endl; + return 1; + } + srt_bind(s, sa.get(), sizeof sa); srt_listen(s, 5); From b850afb53baaf4d90e5394a7ef01130245576dbb Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Mon, 15 Jun 2026 13:41:57 +0200 Subject: [PATCH 3/7] Removed redundant false-init of atomic (causes build breaks on some gcc versions) --- testing/testactivemedia.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/testactivemedia.hpp b/testing/testactivemedia.hpp index e92abbe0c..828e0c553 100644 --- a/testing/testactivemedia.hpp +++ b/testing/testactivemedia.hpp @@ -28,7 +28,7 @@ struct Medium std::mutex buffer_lock; std::thread thr; std::condition_variable ready; - srt::sync::atomic running {false}; + srt::sync::atomic running; std::exception_ptr xp; // To catch exception thrown by a thread virtual void Runner() = 0; From d86e0015c5f6c8f6f8113fd3da9cbf4f081d5ece Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Tue, 16 Jun 2026 09:29:53 +0200 Subject: [PATCH 4/7] Attempting to fix MSVC build break --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d69a8d991..46b16860f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ set(ENABLE_MONOTONIC_CLOCK_DEFAULT OFF) set(MONOTONIC_CLOCK_LINKLIB "") if (MICROSOFT) set(ENABLE_STDCXX_SYNC_DEFAULT ON) + add_compile_options(/Wd4267 /Wd4244) elseif (POSIX) test_requires_clock_gettime(ENABLE_MONOTONIC_CLOCK_DEFAULT MONOTONIC_CLOCK_LINKLIB) endif() From 74ecdcb5c3cde32b8d49af414d65b67040c8ebf3 Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Tue, 16 Jun 2026 09:42:58 +0200 Subject: [PATCH 5/7] Attempting to fix MSVC build break (Take 2) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46b16860f..e6b3251f8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ set(ENABLE_MONOTONIC_CLOCK_DEFAULT OFF) set(MONOTONIC_CLOCK_LINKLIB "") if (MICROSOFT) set(ENABLE_STDCXX_SYNC_DEFAULT ON) - add_compile_options(/Wd4267 /Wd4244) + add_compile_options(/wd4267 /wd4244) elseif (POSIX) test_requires_clock_gettime(ENABLE_MONOTONIC_CLOCK_DEFAULT MONOTONIC_CLOCK_LINKLIB) endif() From 850cfbfef40caeabab7c2de98847c7c9d1f67b59 Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Tue, 16 Jun 2026 11:40:57 +0200 Subject: [PATCH 6/7] Enforced stable compiler on Windows CI --- .github/workflows/windows-msvc-noenc.yml | 2 +- CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/windows-msvc-noenc.yml b/.github/workflows/windows-msvc-noenc.yml index a2c97cf34..f359487a4 100644 --- a/.github/workflows/windows-msvc-noenc.yml +++ b/.github/workflows/windows-msvc-noenc.yml @@ -17,7 +17,7 @@ jobs: - name: configure run: | md _build && cd _build - cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON -DUSE_CXX_STD=c++11 + cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON -DUSE_CXX_STD=c++11 -G "Visual Studio 17 2022" -T v143 - name: build run: cd _build && cmake --build ./ --config Release --verbose - name: test diff --git a/CMakeLists.txt b/CMakeLists.txt index e6b3251f8..d69a8d991 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,6 @@ set(ENABLE_MONOTONIC_CLOCK_DEFAULT OFF) set(MONOTONIC_CLOCK_LINKLIB "") if (MICROSOFT) set(ENABLE_STDCXX_SYNC_DEFAULT ON) - add_compile_options(/wd4267 /wd4244) elseif (POSIX) test_requires_clock_gettime(ENABLE_MONOTONIC_CLOCK_DEFAULT MONOTONIC_CLOCK_LINKLIB) endif() From 84af5fdda19fd0aaf7d1515d152dea48c10be992 Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Tue, 16 Jun 2026 11:48:30 +0200 Subject: [PATCH 7/7] Enforced stable compiler on Windows CI (with no -G) --- .github/workflows/windows-msvc-noenc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-msvc-noenc.yml b/.github/workflows/windows-msvc-noenc.yml index f359487a4..d05f8a6b0 100644 --- a/.github/workflows/windows-msvc-noenc.yml +++ b/.github/workflows/windows-msvc-noenc.yml @@ -17,7 +17,7 @@ jobs: - name: configure run: | md _build && cd _build - cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON -DUSE_CXX_STD=c++11 -G "Visual Studio 17 2022" -T v143 + cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON -DUSE_CXX_STD=c++11 -T v143 - name: build run: cd _build && cmake --build ./ --config Release --verbose - name: test