diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e317d2bfc8..5fa80caccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,21 +32,23 @@ jobs: os: [ 'ubuntu-22.04', 'windows-latest' ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} - name: Setup java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: ${{ matrix.java }} @@ -56,7 +58,7 @@ jobs: echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV echo "BUILD_JAVA_VERSION=${{ matrix.java }}" >> $GITHUB_ENV - name: Setup java 8 to run the Gradle script - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 8 @@ -75,21 +77,23 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: 1 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} - name: Cache NuGet dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('csharp/**/*.sln') }} @@ -118,16 +122,18 @@ jobs: CXX: g++-${{ matrix.version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} @@ -153,16 +159,18 @@ jobs: CXX: g++-${{ matrix.version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} @@ -189,16 +197,18 @@ jobs: CXX: clang++-${{ matrix.version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} @@ -227,16 +237,18 @@ jobs: CXX: clang++-${{ matrix.version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} @@ -265,7 +277,9 @@ jobs: CXX: clang++ steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Install CMake run: | curl -O -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Darwin-x86_64.tar.gz @@ -286,7 +300,9 @@ jobs: CXX: cl steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Install CMake run: | $client = new-object System.Net.WebClient @@ -305,16 +321,18 @@ jobs: rust: [ stable, beta, nightly ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fba15354c6..98c49cca6a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -37,21 +37,23 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} - name: Setup java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: ${{ matrix.java }} @@ -92,21 +94,23 @@ jobs: DOTNET_CLI_TELEMETRY_OPTOUT: 1 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} - name: Cache NuGet dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('csharp/**/*.sln') }} @@ -148,16 +152,18 @@ jobs: CXX: g++-${{ matrix.version }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Cache Gradle dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - name: Cache Gradle wrappers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/wrapper key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} diff --git a/build.gradle b/build.gradle index 3e9a6dea27..8cf1d0f03d 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,7 @@ def toolchainLauncher = javaToolchains.launcherFor { def checkstyleVersion = '9.3' def hamcrestVersion = '2.2' def mockitoVersion = '4.11.0' -def junitVersion = '5.10.1' +def junitVersion = '5.10.2' def jmhVersion = '1.37' def agronaVersion = '1.20.0' def agronaVersionRange = '[1.20.0,2.0[' // allow any release >= 1.20.0 and < 2.0.0 diff --git a/gradle.properties b/gradle.properties index 65930afd28..13abd18beb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.java.installations.auto-download=false org.gradle.java.installations.fromEnv=BUILD_JAVA_HOME -org.gradle.logging.level=warn +org.gradle.logging.level=lifecycle org.gradle.warning.mode=all # HTTP timeouts for Gradle diff --git a/sbe-tool/src/main/cpp/otf/IrDecoder.h b/sbe-tool/src/main/cpp/otf/IrDecoder.h index 6374fecdd2..b4ed9cefd8 100644 --- a/sbe-tool/src/main/cpp/otf/IrDecoder.h +++ b/sbe-tool/src/main/cpp/otf/IrDecoder.h @@ -48,10 +48,7 @@ namespace sbe { namespace otf { class IrDecoder { public: - IrDecoder() : - m_length(0) - { - } + IrDecoder() = default; int decode(char *irBuffer, std::uint64_t length) { @@ -107,11 +104,13 @@ class IrDecoder std::shared_ptr> result; std::for_each(m_messages.begin(), m_messages.end(), - [&](std::shared_ptr> tokens) + [&](const std::shared_ptr> &tokens) { Token &token = tokens->at(0); - if (token.signal() == Signal::BEGIN_MESSAGE && token.fieldId() == id && token.tokenVersion() == version) + if (token.signal() == Signal::BEGIN_MESSAGE && + token.fieldId() == id && + token.tokenVersion() <= version) { result = tokens; } @@ -125,7 +124,7 @@ class IrDecoder std::shared_ptr> result; std::for_each(m_messages.begin(), m_messages.end(), - [&](std::shared_ptr> tokens) + [&](const std::shared_ptr> &tokens) { Token &token = tokens->at(0); @@ -142,7 +141,7 @@ class IrDecoder // OS specifics static long long getFileSize(const char *filename) { - struct stat fileStat; + struct stat fileStat{}; if (::stat(filename, &fileStat) != 0) { @@ -165,7 +164,7 @@ class IrDecoder int fd = fileno(fptr); while (remaining > 0) { - unsigned int bytes = static_cast(4098 < remaining ? 4098 : remaining); + auto bytes = static_cast(4098 < remaining ? 4098 : remaining); long long sz = ::read(fd, buffer + (length - remaining), bytes); remaining -= sz; if (sz < 0) @@ -183,8 +182,8 @@ class IrDecoder std::shared_ptr> m_headerTokens; std::vector>> m_messages; std::unique_ptr m_buffer; - std::uint64_t m_length; - int m_id; + std::uint64_t m_length = 0; + int m_id = 0; int decodeIr() { @@ -192,9 +191,14 @@ class IrDecoder FrameCodec frame; std::uint64_t offset = 0; - char tmp[256]; + char tmp[256] = {}; - frame.wrapForDecode(m_buffer.get(), offset, frame.sbeBlockLength(), frame.sbeSchemaVersion(), m_length); + frame.wrapForDecode( + m_buffer.get(), + offset, + FrameCodec::sbeBlockLength(), + FrameCodec::sbeSchemaVersion(), + m_length); frame.getPackageName(tmp, sizeof(tmp)); @@ -230,18 +234,22 @@ class IrDecoder TokenCodec tokenCodec; tokenCodec.wrapForDecode( - m_buffer.get(), offset, tokenCodec.sbeBlockLength(), tokenCodec.sbeSchemaVersion(), m_length); - - Signal signal = static_cast(tokenCodec.signal()); - PrimitiveType type = static_cast(tokenCodec.primitiveType()); - Presence presence = static_cast(tokenCodec.presence()); - ByteOrder byteOrder = static_cast(tokenCodec.byteOrder()); + m_buffer.get(), + offset, + TokenCodec::sbeBlockLength(), + TokenCodec::sbeSchemaVersion(), + m_length); + + auto signal = static_cast(tokenCodec.signal()); + auto type = static_cast(tokenCodec.primitiveType()); + auto presence = static_cast(tokenCodec.presence()); + auto byteOrder = static_cast(tokenCodec.byteOrder()); std::int32_t tokenOffset = tokenCodec.tokenOffset(); std::int32_t tokenSize = tokenCodec.tokenSize(); std::int32_t id = tokenCodec.fieldId(); std::int32_t version = tokenCodec.tokenVersion(); std::int32_t componentTokenCount = tokenCodec.componentTokenCount(); - char tmpBuffer[256]; + char tmpBuffer[256] = {}; std::uint64_t tmpLen = 0; tmpLen = tokenCodec.getName(tmpBuffer, sizeof(tmpBuffer)); diff --git a/sbe-tool/src/main/cpp/otf/OtfMessageDecoder.h b/sbe-tool/src/main/cpp/otf/OtfMessageDecoder.h index 8b59b5df7d..edd65bff17 100644 --- a/sbe-tool/src/main/cpp/otf/OtfMessageDecoder.h +++ b/sbe-tool/src/main/cpp/otf/OtfMessageDecoder.h @@ -157,14 +157,13 @@ static void decodeComposite( std::uint64_t actingVersion, TokenListener &listener) { - listener.onBeginComposite(fieldToken, *tokens.get(), tokenIndex, toIndex); + listener.onBeginComposite(fieldToken, *tokens, tokenIndex, toIndex); for (size_t i = tokenIndex + 1; i < toIndex;) { Token &token = tokens->at(i); const size_t nextFieldIndex = i + token.componentTokenCount(); - - const std::size_t offset = static_cast(token.offset()); + const auto offset = static_cast(token.offset()); switch (token.signal()) { @@ -183,12 +182,12 @@ static void decodeComposite( case Signal::BEGIN_ENUM: listener.onEnum( - fieldToken, buffer + bufferIndex + offset, *tokens.get(), i, nextFieldIndex - 1, actingVersion); + fieldToken, buffer + bufferIndex + offset, *tokens, i, nextFieldIndex - 1, actingVersion); break; case Signal::BEGIN_SET: listener.onBitSet( - fieldToken, buffer + bufferIndex + offset, *tokens.get(), i, nextFieldIndex - 1, actingVersion); + fieldToken, buffer + bufferIndex + offset, *tokens, i, nextFieldIndex - 1, actingVersion); break; case Signal::ENCODING: @@ -202,7 +201,7 @@ static void decodeComposite( i += token.componentTokenCount(); } - listener.onEndComposite(fieldToken, *tokens.get(), tokenIndex, toIndex); + listener.onEndComposite(fieldToken, *tokens, tokenIndex, toIndex); } template @@ -246,13 +245,11 @@ static size_t decodeFields( break; case Signal::BEGIN_ENUM: - listener.onEnum( - fieldToken, buffer + offset, *tokens.get(), tokenIndex, nextFieldIndex - 2, actingVersion); + listener.onEnum(fieldToken, buffer + offset, *tokens, tokenIndex, nextFieldIndex - 2, actingVersion); break; case Signal::BEGIN_SET: - listener.onBitSet( - fieldToken, buffer + offset, *tokens.get(), tokenIndex, nextFieldIndex - 2, actingVersion); + listener.onBitSet(fieldToken, buffer + offset, *tokens, tokenIndex, nextFieldIndex - 2, actingVersion); break; case Signal::ENCODING: @@ -342,7 +339,7 @@ std::pair decodeGroups( const bool isPresent = token.tokenVersion() <= static_cast(actingVersion); Token &dimensionsTypeComposite = tokens->at(tokenIndex + 1); - std::size_t dimensionsLength = static_cast(dimensionsTypeComposite.encodedLength()); + auto dimensionsLength = static_cast(dimensionsTypeComposite.encodedLength()); if ((bufferIndex + dimensionsLength) > length) { @@ -391,7 +388,7 @@ std::pair decodeGroups( tokenIndex += token.componentTokenCount(); } - return std::pair(bufferIndex, tokenIndex); + return { bufferIndex, tokenIndex }; } /** diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java index c82a0f0a14..54a1683371 100755 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java @@ -2673,10 +2673,10 @@ private CharSequence generateMessageFlyweightCode( "%22$s" + "public:\n" + - " static const %1$s SBE_BLOCK_LENGTH = %2$s;\n" + - " static const %3$s SBE_TEMPLATE_ID = %4$s;\n" + - " static const %5$s SBE_SCHEMA_ID = %6$s;\n" + - " static const %7$s SBE_SCHEMA_VERSION = %8$s;\n" + + " static constexpr %1$s SBE_BLOCK_LENGTH = %2$s;\n" + + " static constexpr %3$s SBE_TEMPLATE_ID = %4$s;\n" + + " static constexpr %5$s SBE_SCHEMA_ID = %6$s;\n" + + " static constexpr %7$s SBE_SCHEMA_VERSION = %8$s;\n" + " static constexpr const char* SBE_SEMANTIC_VERSION = \"%13$s\";\n\n" + " enum MetaAttribute\n" +