diff --git a/.github/workflows/staleness_check.yml b/.github/workflows/staleness_check.yml index d9e8148265..3bb315b15f 100644 --- a/.github/workflows/staleness_check.yml +++ b/.github/workflows/staleness_check.yml @@ -52,7 +52,7 @@ jobs: # commit. uses: protocolbuffers/protobuf-ci/bazel@v5 with: - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: staleness bash: > diff --git a/.github/workflows/test_csharp.yml b/.github/workflows/test_csharp.yml index 6e9331b7c5..d0e9e66519 100644 --- a/.github/workflows/test_csharp.yml +++ b/.github/workflows/test_csharp.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests uses: protocolbuffers/protobuf-ci/docker@v5 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:8.0.1-3.1.415-6.0.100-b77fdae6d4771789dfc66a56bf8d806354e8011a + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:9.0.0-3.1.415-6.0.100-9fc33a0c378b5affd3c85d3f5ae4f330993048f7 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} entrypoint: /bin/bash command: >- @@ -43,7 +43,7 @@ jobs: - name: Run conformance tests uses: protocolbuffers/protobuf-ci/bazel-docker@v5 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:8.0.1-3.1.415-6.0.100-b77fdae6d4771789dfc66a56bf8d806354e8011a + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:9.0.0-3.1.415-6.0.100-9fc33a0c378b5affd3c85d3f5ae4f330993048f7 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: csharp_linux bazel: test //csharp:conformance_test --action_env=DOTNET_CLI_TELEMETRY_OPTOUT=1 --test_env=DOTNET_CLI_HOME=/home/bazel @@ -65,7 +65,7 @@ jobs: - name: Run tests uses: protocolbuffers/protobuf-ci/bash@v5 with: - bazel-version: 8.0.1 + bazel-version: 9.0.0 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: | dotnet build csharp/src/Google.Protobuf.sln diff --git a/.github/workflows/test_hpb.yml b/.github/workflows/test_hpb.yml index 68cf70ab15..a1a93a441e 100644 --- a/.github/workflows/test_hpb.yml +++ b/.github/workflows/test_hpb.yml @@ -22,7 +22,7 @@ jobs: include: - targets: "//hpb/... //hpb_generator/..." - - image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:8.0.1-e78301df86b3e4c46ec9ac4d98be00e19305d8f3" + - image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.0.0-7932bf8b25fb76a111e7257d151a6a58d5c3c671" - bazel_cmd: "test" name: Linux ${{ matrix.config.name }} diff --git a/.github/workflows/test_objectivec.yml b/.github/workflows/test_objectivec.yml index 207c7653b2..0f4b3eef00 100644 --- a/.github/workflows/test_objectivec.yml +++ b/.github/workflows/test_objectivec.yml @@ -70,7 +70,7 @@ jobs: CODE_SIGN_IDENTITY: "-" with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - bazel-version: 8.0.1 + bazel-version: 9.0.0 command: | xcodebuild \ -project "objectivec/${{ matrix.xc_project }}" \ @@ -113,7 +113,7 @@ jobs: if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v5 with: - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: cocoapods/${{ matrix.XCODE }} bash: | @@ -161,7 +161,7 @@ jobs: if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v5 with: - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel: ${{ matrix.config.bazel_action }} ${{ matrix.config.flags }} ${{ matrix.bazel_targets }} bazel-cache: objc_${{ matrix.platform }}_${{ matrix.config.name }} diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml index cf808f48e7..07bebc6582 100644 --- a/.github/workflows/test_php.yml +++ b/.github/workflows/test_php.yml @@ -65,7 +65,7 @@ jobs: if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v5 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:8.0.1-${{ matrix.version }}-7d856878bb9d57cf17083cbf1078afe50f3013f3 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:9.0.0-${{ matrix.version }}-9fc33a0c378b5affd3c85d3f5ae4f330993048f7 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_linux/${{ matrix.version }} bash: | @@ -115,7 +115,7 @@ jobs: id: cross-compile uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v5 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:8.0.1-e78301df86b3e4c46ec9ac4d98be00e19305d8f3 + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.0.0-7932bf8b25fb76a111e7257d151a6a58d5c3c671 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-i386 @@ -147,7 +147,7 @@ jobs: id: cross-compile uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v5 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:8.0.1-e78301df86b3e4c46ec9ac4d98be00e19305d8f3 + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.0.0-7932bf8b25fb76a111e7257d151a6a58d5c3c671 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-aarch64 @@ -204,7 +204,7 @@ jobs: uses: protocolbuffers/protobuf-ci/bash@v5 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - bazel-version: 8.0.1 + bazel-version: 9.0.0 # TODO this shouldn't be necessary, remove it bazel-flags: --xcode_version_config=//.github:host_xcodes_macos15 command: | @@ -220,6 +220,6 @@ jobs: uses: protocolbuffers/protobuf-ci/bazel@v5 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version bazel-cache: php_macos15/${{ matrix.version }} bazel: test //php:conformance_test //php:conformance_test_c --action_env=PATH --test_env=PATH --xcode_version_config=//.github:host_xcodes_macos15 diff --git a/.github/workflows/test_php_ext.yml b/.github/workflows/test_php_ext.yml index 1a24652952..bfb78d6d52 100644 --- a/.github/workflows/test_php_ext.yml +++ b/.github/workflows/test_php_ext.yml @@ -35,7 +35,7 @@ jobs: - name: Package extension uses: protocolbuffers/protobuf-ci/bazel@v5 with: - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_ext/${{ matrix.version }} bash: > diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index edb3232af2..f775666428 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -64,7 +64,7 @@ jobs: if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v5 with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:8.0.1-{0}-5237f14696e60e4b050edfbf7ba9b374f37f83c6', matrix.version) }} + image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:9.0.0-{0}-7932bf8b25fb76a111e7257d151a6a58d5c3c671', matrix.version) }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }} bazel: test ${{ matrix.targets }} ${{ matrix.flags }} ${{ matrix.nobzlmod && '--noenable_bzlmod' || '' }} --test_env=KOKORO_PYTHON_VERSION @@ -115,7 +115,7 @@ jobs: env: KOKORO_PYTHON_VERSION: ${{ matrix.version }} with: - version: 8.0.1 # Bazel version + version: 9.0.0 # Bazel version credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: python_macos/${{ matrix.type }}_${{ matrix.version }} bazel: >- diff --git a/.github/workflows/test_rust.yml b/.github/workflows/test_rust.yml index f715d26752..0404ab0d35 100644 --- a/.github/workflows/test_rust.yml +++ b/.github/workflows/test_rust.yml @@ -24,14 +24,14 @@ jobs: include: - targets: "//rust/... //src/google/protobuf/compiler/rust/..." - - image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:8.0.1-e78301df86b3e4c46ec9ac4d98be00e19305d8f3" + - image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.0.0-7932bf8b25fb76a111e7257d151a6a58d5c3c671" - bazel_cmd: "test" # Override cases with custom images - config: { name: Cargo } # We need Rust 1.90 so that we can use the new workspace publishing # feature. - image: "us-docker.pkg.dev/protobuf-build/containers/release/linux/rust:8.0.1-1.90.0-e1c2fe666ffa9b941b126541a26340d0ea787cea" + image: "us-docker.pkg.dev/protobuf-build/containers/release/linux/rust:9.0.0-1.90.0-98863a45066747115144a8a8fb4818189d1e0761" bazel_cmd: "run" targets: "//rust/release_crates:cargo_test" @@ -73,4 +73,4 @@ jobs: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel: run //rust/release_crates:cargo_test bazel-cache: windows-cargo - version: 8.0.1 + version: 9.0.0 diff --git a/.github/workflows/test_upb.yml b/.github/workflows/test_upb.yml index 98dfde818d..01dfa42ab4 100644 --- a/.github/workflows/test_upb.yml +++ b/.github/workflows/test_upb.yml @@ -74,7 +74,7 @@ jobs: bazel-cache: "upb-bazel-windows" # TODO: Enable python tests here once rules_python supports Windows better. bazel: test //upb/... //upb_generator/... - version: 8.0.1 + version: 9.0.0 exclude-targets: -//python:conformance_test -//upb/reflection:def_builder_test macos: @@ -103,7 +103,7 @@ jobs: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: "upb-bazel-macos" bazel: ${{ matrix.config.bazel-command }} ${{ matrix.config.flags }} //benchmarks/... //lua/... //python/... //upb/... //upb_generator/... - version: 8.0.1 + version: 9.0.0 build_wheels: name: Build Wheels @@ -117,7 +117,7 @@ jobs: - name: Build Wheels uses: protocolbuffers/protobuf-ci/bazel-docker@v5 with: - image: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple:8.0.1-8c286adfa190f9d0caa666ab605189345f362c02 + image: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple:9.0.0-9fc33a0c378b5affd3c85d3f5ae4f330993048f7 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: upb-bazel-python bazel: build --config=cross_config --symlink_prefix=/ -c dbg //python/dist //python/dist:test_wheel //python/dist:source_wheel diff --git a/python/descriptor.h b/python/descriptor.h index 013f1d8ca7..d4127d91ca 100644 --- a/python/descriptor.h +++ b/python/descriptor.h @@ -8,6 +8,9 @@ #ifndef PYUPB_DESCRIPTOR_H__ #define PYUPB_DESCRIPTOR_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "python/python_api.h" diff --git a/python/descriptor_containers.h b/python/descriptor_containers.h index cd9f8ccb1f..101a8807d8 100644 --- a/python/descriptor_containers.h +++ b/python/descriptor_containers.h @@ -20,6 +20,9 @@ // those functions directly inside these vtables, greatly reducing the amount of // "adaptor" code we need to write. +// clang-format on +#include "Python.h" +// clang-format off #include #include "protobuf.h" diff --git a/python/descriptor_pool.h b/python/descriptor_pool.h index 2283b96f5e..ac2f34c230 100644 --- a/python/descriptor_pool.h +++ b/python/descriptor_pool.h @@ -8,6 +8,9 @@ #ifndef PYUPB_DESCRIPTOR_POOL_H__ #define PYUPB_DESCRIPTOR_POOL_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "protobuf.h" diff --git a/python/dist/python_downloads.bzl b/python/dist/python_downloads.bzl index ef774f35ce..09887ba686 100644 --- a/python/dist/python_downloads.bzl +++ b/python/dist/python_downloads.bzl @@ -3,6 +3,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") limited_api_build_file = """ +load("@rules_cc//cc:defs.bzl", "cc_library") + cc_library( name = "python_headers", hdrs = glob(["**/Include/**/*.h"]), @@ -33,6 +35,8 @@ def python_source_archive(version, sha256): ) nuget_build_file = """ +load("@rules_cc//cc:defs.bzl", "cc_import") + cc_import( name = "python_full_api", hdrs = glob(["**/*.h"]), diff --git a/python/extension_dict.h b/python/extension_dict.h index 9db01cdf1e..361afe72c1 100644 --- a/python/extension_dict.h +++ b/python/extension_dict.h @@ -8,6 +8,9 @@ #ifndef PYUPB_EXTENSION_DICT_H__ #define PYUPB_EXTENSION_DICT_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "python/python_api.h" diff --git a/python/map.h b/python/map.h index 7aa57a2775..be8ff23580 100644 --- a/python/map.h +++ b/python/map.h @@ -8,6 +8,9 @@ #ifndef PYUPB_MAP_H__ #define PYUPB_MAP_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "python/protobuf.h" diff --git a/python/message.h b/python/message.h index 85e70a6dfe..31fd89da4c 100644 --- a/python/message.h +++ b/python/message.h @@ -8,6 +8,9 @@ #ifndef PYPB_MESSAGE_H__ #define PYPB_MESSAGE_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "python/protobuf.h" diff --git a/python/protobuf.h b/python/protobuf.h index 2a605ddac1..3af0e057c3 100644 --- a/python/protobuf.h +++ b/python/protobuf.h @@ -8,6 +8,9 @@ #ifndef PYUPB_PROTOBUF_H__ #define PYUPB_PROTOBUF_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include diff --git a/python/repeated.h b/python/repeated.h index 62d57267cf..1f6928e398 100644 --- a/python/repeated.h +++ b/python/repeated.h @@ -8,6 +8,9 @@ #ifndef PYUPB_REPEATED_H__ #define PYUPB_REPEATED_H__ +// clang-format off +#include "Python.h" +// chang-format on #include #include "python/protobuf.h" diff --git a/python/unknown_fields.h b/python/unknown_fields.h index c9eae3b8ee..f8d01ca4cd 100644 --- a/python/unknown_fields.h +++ b/python/unknown_fields.h @@ -8,6 +8,9 @@ #ifndef PYUPB_UNKNOWN_FIELDS_H__ #define PYUPB_UNKNOWN_FIELDS_H__ +// clang-format off +#include "Python.h" +// clang-format on #include #include "python/python_api.h" diff --git a/upb/message/test.cc b/upb/message/test.cc index 6a7214938b..5bb5abf3d4 100644 --- a/upb/message/test.cc +++ b/upb/message/test.cc @@ -108,7 +108,7 @@ TEST(MessageTest, Extensions) { char* serialized = upb_test_TestExtensions_serialize(ext_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); upb_test_TestExtensions* ext_msg2 = upb_test_TestExtensions_parse_ex( serialized, size, upb_DefPool_ExtensionRegistry(defpool.ptr()), 0, @@ -167,7 +167,7 @@ TEST(MessageTest, ExtensionsDeterministic) { char* serialized = upb_test_TestExtensions_serialize(ext_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); size_t deterministic_size; char* deterministic_serialized = upb_test_TestExtensions_serialize_ex( @@ -216,7 +216,7 @@ TEST(MessageTest, ExtensionsEmpty) { char* serialized = upb_test_TestExtensions_serialize_ex( ext_msg_with_empty, options, arena.ptr(), &size_with_empty); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size_with_empty, 0); + ASSERT_GE(size_with_empty, 0u); size_t size; serialized = upb_test_TestExtensions_serialize_ex(ext_msg, options, @@ -282,7 +282,7 @@ TEST(MessageTest, MessageSet) { char* serialized = upb_test_TestMessageSet_serialize(ext_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); upb_test_TestMessageSet* ext_msg2 = upb_test_TestMessageSet_parse_ex( serialized, size, upb_DefPool_ExtensionRegistry(defpool.ptr()), 0, @@ -328,7 +328,7 @@ TEST(MessageTest, UnknownMessageSet) { char* serialized = upb_test_FakeMessageSet_serialize(fake, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); upb::DefPool defpool; upb::MessageDefPtr m(upb_test_TestMessageSet_getmsgdef(defpool.ptr())); @@ -341,7 +341,7 @@ TEST(MessageTest, UnknownMessageSet) { char* serialized2 = upb_test_TestMessageSet_serialize(message_set, arena.ptr(), &size); ASSERT_TRUE(serialized2 != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); // Parse back into a fake MessageSet and verify that the unknown MessageSet // item was preserved in full (both type_id and message). @@ -351,7 +351,7 @@ TEST(MessageTest, UnknownMessageSet) { const upb_test_FakeMessageSet_Item* const* items = upb_test_FakeMessageSet_item(fake2, &size); - ASSERT_EQ(1, size); + ASSERT_EQ(1u, size); EXPECT_EQ(12345, upb_test_FakeMessageSet_Item_type_id(items[0])); EXPECT_TRUE(upb_StringView_IsEqual( data_view, upb_test_FakeMessageSet_Item_message(items[0]))); @@ -382,7 +382,7 @@ TEST(MessageTest, MessageSetSubmessageEncoding) { char* serialized = upb_test_TestExtensions_serialize(ext_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - ASSERT_GE(size, 0); + ASSERT_GE(size, 0u); upb::DefPool defpool; upb::MessageDefPtr m(upb_test_TestMessageSet_getmsgdef(defpool.ptr())); @@ -433,7 +433,7 @@ TEST(MessageTest, Proto2Enum) { EXPECT_EQ(false, upb_test_Proto2EnumMessage_has_optional_enum(enum_msg)); const int32_t* vals_const = upb_test_Proto2EnumMessage_repeated_enum(enum_msg, &size); - EXPECT_EQ(4, size); // Two unknown values moved to the unknown field set. + EXPECT_EQ(4u, size); // Two unknown values moved to the unknown field set. // Parsing back into the fake message shows the original data, except the // repeated enum is rearranged. @@ -455,12 +455,12 @@ TEST(MessageTest, Proto2Enum) { }; vals_const = upb_test_Proto2FakeEnumMessage_repeated_enum(fake_msg2, &size); - EXPECT_EQ(6, size); + EXPECT_EQ(6u, size); EXPECT_THAT(std::vector(vals_const, vals_const + size), ::testing::ElementsAreArray(expected)); vals_const = upb_test_Proto2FakeEnumMessage_packed_enum(fake_msg2, &size); - EXPECT_EQ(6, size); + EXPECT_EQ(6u, size); EXPECT_THAT(std::vector(vals_const, vals_const + size), ::testing::ElementsAreArray(expected)); } @@ -500,7 +500,7 @@ TEST(MessageTest, OneOf32BitStringViewInt64Alignment) { uint16_t offset = UPB_PRIVATE(_upb_MiniTableField_Offset)(mtfield); size_t alignment = 1 << absl::countr_zero(offset); // Must align to at least 64 bit - EXPECT_GE(alignment, 8); + EXPECT_GE(alignment, 8u); } TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) { @@ -523,7 +523,7 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) { char* serialized = upb_test_TestRequiredFields_serialize(test_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - EXPECT_NE(0, size); + EXPECT_NE(0u, size); // Fails, but the code path is slightly different because the serialized // payload is not empty. @@ -547,7 +547,7 @@ TEST(MessageTest, DecodeRequiredFieldsTopLevelMessage) { serialized = upb_test_TestRequiredFields_serialize(test_msg, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - EXPECT_NE(0, size); + EXPECT_NE(0u, size); upb_test_TestRequiredFields* test_msg2 = upb_test_TestRequiredFields_parse_ex( serialized, size, nullptr, kUpb_DecodeOption_CheckRequired, arena.ptr()); @@ -575,7 +575,7 @@ TEST(MessageTest, DecodeRequiredFieldsSubMessage) { size_t size; char* serialized = upb_test_SubMessageHasRequired_serialize(sub_msg, arena.ptr(), &size); - EXPECT_NE(0, size); + EXPECT_NE(0u, size); // No parse error when parsing normally. EXPECT_NE(nullptr, upb_test_SubMessageHasRequired_parse(serialized, size, @@ -592,7 +592,7 @@ TEST(MessageTest, DecodeRequiredFieldsSubMessage) { serialized = upb_test_SubMessageHasRequired_serialize(sub_msg, arena.ptr(), &size); - EXPECT_NE(0, size); + EXPECT_NE(0u, size); // No parse error; sub-message now is complete. EXPECT_NE(nullptr, upb_test_SubMessageHasRequired_parse_ex( @@ -610,7 +610,7 @@ TEST(MessageTest, EncodeRequiredFields) { char* serialized = upb_test_TestRequiredFields_serialize_ex(test_msg, 0, arena.ptr(), &size); ASSERT_TRUE(serialized != nullptr); - EXPECT_EQ(size, 0); + EXPECT_EQ(size, 0u); // Fails, we asked for required field checking but the required field is // missing. @@ -681,7 +681,7 @@ TEST(MessageTest, MapField) { char* serialized = upb_test_TestMapFieldExtra_serialize_ex( test_msg_extra, 0, arena.ptr(), &size); ASSERT_NE(nullptr, serialized); - ASSERT_NE(0, size); + ASSERT_NE(0u, size); upb_test_TestMapField* test_msg = upb_test_TestMapField_parse(serialized, size, arena.ptr()); @@ -690,7 +690,7 @@ TEST(MessageTest, MapField) { ASSERT_FALSE(upb_test_TestMapField_map_field_get(test_msg, 0, nullptr)); serialized = upb_test_TestMapField_serialize_ex(test_msg, 0, arena.ptr(), &size); - ASSERT_NE(0, size); + ASSERT_NE(0u, size); // parse into second instance upb_test_TestMapFieldExtra* test_msg_extra2 = upb_test_TestMapFieldExtra_parse(serialized, size, arena.ptr()); @@ -793,13 +793,13 @@ TEST(MessageTest, AdjacentAliasedUnknown) { uintptr_t iter = kUpb_Message_UnknownBegin; ASSERT_TRUE(upb_Message_NextUnknown(msg, &data, &iter)); EXPECT_EQ(region, data.data); - EXPECT_EQ(300, data.size); + EXPECT_EQ(300u, data.size); ASSERT_TRUE(upb_Message_NextUnknown(msg, &data, &iter)); EXPECT_EQ(region + 300, data.data); - EXPECT_EQ(300, data.size); + EXPECT_EQ(300u, data.size); ASSERT_TRUE(upb_Message_NextUnknown(msg, &data, &iter)); EXPECT_EQ(region + 600, data.data); - EXPECT_EQ(300, data.size); + EXPECT_EQ(300u, data.size); ASSERT_FALSE(upb_Message_NextUnknown(msg, &data, &iter)); } } @@ -822,7 +822,7 @@ TEST(MessageTest, Freeze) { upb_Array* arr = _upb_test_TestFreeze_array_int_mutable_upb_array( raw, &size, arena.ptr()); ASSERT_NE(arr, nullptr); - ASSERT_EQ(size, 0); + ASSERT_EQ(size, 0u); ASSERT_FALSE(upb_Array_IsFrozen(arr)); upb_Map* map = _upb_test_TestFreeze_map_int_mutable_upb_map(raw, arena.ptr()); @@ -845,7 +845,7 @@ TEST(MessageTest, Freeze) { upb_Array* arr = _upb_test_TestFreeze_array_int_mutable_upb_array( raw, &size, arena.ptr()); ASSERT_NE(arr, nullptr); - ASSERT_EQ(size, 0); + ASSERT_EQ(size, 0u); ASSERT_FALSE(upb_Array_IsFrozen(arr)); upb_Map* map = _upb_test_TestFreeze_map_int_mutable_upb_map(raw, arena.ptr()); @@ -985,5 +985,5 @@ TEST(MessageTest, ArenaSpaceAllocatedAfterDecode) { EXPECT_NE(msg, nullptr); uintptr_t space_allocated_after = upb_Arena_SpaceAllocated(arena.ptr(), nullptr); - EXPECT_GT(space_allocated_after, space_allocated_before + 297); + EXPECT_GT(space_allocated_after, space_allocated_before + 297u); } diff --git a/upb/mini_descriptor/internal/encode_test.cc b/upb/mini_descriptor/internal/encode_test.cc index 7f97b2a253..1959c98d8f 100644 --- a/upb/mini_descriptor/internal/encode_test.cc +++ b/upb/mini_descriptor/internal/encode_test.cc @@ -49,7 +49,7 @@ TEST_P(MiniTableTest, AllScalarTypes) { upb::Arena arena; upb::MtDataEncoder e; ASSERT_TRUE(e.StartMessage(0)); - int count = 0; + uint32_t count = 0; for (int i = kUpb_FieldType_Double; i < kUpb_FieldType_SInt64; i++) { ASSERT_TRUE(e.PutField(static_cast(i), i, 0)); count++; @@ -62,7 +62,7 @@ TEST_P(MiniTableTest, AllScalarTypes) { absl::flat_hash_set offsets; for (int i = 0; i < 16; i++) { const upb_MiniTableField* f = &table->UPB_PRIVATE(fields)[i]; - EXPECT_EQ(i + 1, upb_MiniTableField_Number(f)); + EXPECT_EQ(i + 1u, upb_MiniTableField_Number(f)); EXPECT_TRUE(upb_MiniTableField_IsScalar(f)); EXPECT_TRUE(offsets.insert(f->UPB_PRIVATE(offset)).second); EXPECT_TRUE(f->UPB_PRIVATE(offset) < table->UPB_PRIVATE(size)); @@ -74,7 +74,7 @@ TEST_P(MiniTableTest, AllRepeatedTypes) { upb::Arena arena; upb::MtDataEncoder e; ASSERT_TRUE(e.StartMessage(0)); - int count = 0; + uint32_t count = 0; for (int i = kUpb_FieldType_Double; i < kUpb_FieldType_SInt64; i++) { ASSERT_TRUE(e.PutField(static_cast(i), i, kUpb_FieldModifier_IsRepeated)); @@ -88,7 +88,7 @@ TEST_P(MiniTableTest, AllRepeatedTypes) { absl::flat_hash_set offsets; for (int i = 0; i < 16; i++) { const upb_MiniTableField* f = &table->UPB_PRIVATE(fields)[i]; - EXPECT_EQ(i + 1, upb_MiniTableField_Number(f)); + EXPECT_EQ(i + 1u, upb_MiniTableField_Number(f)); EXPECT_TRUE(upb_MiniTableField_IsArray(f)); EXPECT_TRUE(offsets.insert(f->UPB_PRIVATE(offset)).second); EXPECT_TRUE(f->UPB_PRIVATE(offset) < table->UPB_PRIVATE(size)); @@ -100,10 +100,10 @@ TEST_P(MiniTableTest, Skips) { upb::Arena arena; upb::MtDataEncoder e; ASSERT_TRUE(e.StartMessage(0)); - int count = 0; - std::vector field_numbers; + uint32_t count = 0; + std::vector field_numbers; for (int i = 0; i < 25; i++) { - int field_number = 1 << i; + uint32_t field_number = 1u << i; field_numbers.push_back(field_number); ASSERT_TRUE(e.PutField(kUpb_FieldType_Float, field_number, 0)); count++; @@ -129,7 +129,7 @@ TEST_P(MiniTableTest, AllScalarTypesOneof) { upb::Arena arena; upb::MtDataEncoder e; ASSERT_TRUE(e.StartMessage(0)); - int count = 0; + uint32_t count = 0; for (int i = kUpb_FieldType_Double; i < kUpb_FieldType_SInt64; i++) { ASSERT_TRUE(e.PutField(static_cast(i), i, 0)); count++; @@ -146,7 +146,7 @@ TEST_P(MiniTableTest, AllScalarTypesOneof) { absl::flat_hash_set offsets; for (int i = 0; i < 16; i++) { const upb_MiniTableField* f = &table->UPB_PRIVATE(fields)[i]; - EXPECT_EQ(i + 1, upb_MiniTableField_Number(f)); + EXPECT_EQ(i + 1u, upb_MiniTableField_Number(f)); EXPECT_TRUE(upb_MiniTableField_IsScalar(f)); // For a oneof all fields have the same offset. EXPECT_EQ(table->UPB_PRIVATE(fields)[0].UPB_PRIVATE(offset), diff --git a/upb/test/length_prefixed_test.cc b/upb/test/length_prefixed_test.cc index 0ea1f11887..07de37c77e 100644 --- a/upb/test/length_prefixed_test.cc +++ b/upb/test/length_prefixed_test.cc @@ -31,7 +31,7 @@ static void TestEncodeDecodeRoundTrip( ASSERT_TRUE(upb_EncodeLengthPrefixed(UPB_UPCAST(msg), kTestMiniTable, 0, arena, &buf, &size) == kUpb_EncodeStatus_Ok); - ASSERT_GT(size, 0); // Even empty messages are 1 byte in this encoding. + ASSERT_GT(size, 0u); // Even empty messages are 1 byte in this encoding. s.append(std::string(buf, size)); } @@ -44,7 +44,7 @@ static void TestEncodeDecodeRoundTrip( ASSERT_TRUE(upb_DecodeLengthPrefixed( s.data(), s.length(), UPB_UPCAST(msg), &num_bytes_read, kTestMiniTable, nullptr, 0, arena) == kUpb_DecodeStatus_Ok); - ASSERT_GT(num_bytes_read, 0); + ASSERT_GT(num_bytes_read, 0u); decoded.push_back(msg); s = s.substr(num_bytes_read); } diff --git a/upb/test/test_cpp.cc b/upb/test/test_cpp.cc index b7df32aa51..f33441ab92 100644 --- a/upb/test/test_cpp.cc +++ b/upb/test/test_cpp.cc @@ -55,7 +55,7 @@ TEST(Cpp, Default) { upb_test_TestMessage* msg = upb_test_TestMessage_new(arena.ptr()); size_t size = upb_JsonEncode(UPB_UPCAST(msg), md.ptr(), nullptr, 0, nullptr, 0, nullptr); - EXPECT_EQ(2, size); // "{}" + EXPECT_EQ(2u, size); // "{}" } TEST(Cpp, JsonNull) { @@ -67,7 +67,7 @@ TEST(Cpp, JsonNull) { ASSERT_TRUE(str_f); EXPECT_EQ(5, i32_f.default_value().int32_val); EXPECT_EQ(0, strcmp(str_f.default_value().str_val.data, "abc")); - EXPECT_EQ(3, str_f.default_value().str_val.size); + EXPECT_EQ(3u, str_f.default_value().str_val.size); } TEST(Cpp, TimestampEncoder) { diff --git a/upb/wire/decode_test.cc b/upb/wire/decode_test.cc index ec7dadd0d1..600eb45b25 100644 --- a/upb/wire/decode_test.cc +++ b/upb/wire/decode_test.cc @@ -330,7 +330,7 @@ TEST(RepeatedFieldTest, RepeatedMessageFallback) { const upb_Array* arr = upb_Message_GetArray(msg, field); ASSERT_NE(arr, nullptr); - EXPECT_EQ(upb_Array_Size(arr), 2); + EXPECT_EQ(upb_Array_Size(arr), 2u); } TEST(RepeatedFieldTest, LongRepeatedField) { diff --git a/upb/wire/encode_test.cc b/upb/wire/encode_test.cc index 13ce5d72b8..6da6d5d25a 100644 --- a/upb/wire/encode_test.cc +++ b/upb/wire/encode_test.cc @@ -65,7 +65,7 @@ TEST(EncodeTest, EncodeFieldSuccess) { upb_EncodeStatus status = UPB_PRIVATE(_upb_Encode_Field)( &e, (upb_Message*)msg, field, &buf, &size, e.options); EXPECT_EQ(status, kUpb_EncodeStatus_Ok); - EXPECT_GT(size, 0); + EXPECT_GT(size, 0u); // Verify that the encoded field can be decoded back to the original message // with the same value. @@ -96,7 +96,7 @@ TEST(EncodeTest, EncodeFieldSuccessEmptyMessage) { upb_EncodeStatus status = UPB_PRIVATE(_upb_Encode_Field)( &e, (upb_Message*)msg, field, &buf, &size, e.options); EXPECT_EQ(status, kUpb_EncodeStatus_Ok); - EXPECT_EQ(size, 0); + EXPECT_EQ(size, 0u); _upb_mapsorter_destroy(&e.sorter); upb_Arena_Free(arena); @@ -141,7 +141,7 @@ TEST(EncodeTest, EncodeExtensionSuccess) { upb_EncodeStatus status = UPB_PRIVATE(_upb_Encode_Extension)( &e, ext, ext_val, false, &buf, &size, e.options); EXPECT_EQ(status, kUpb_EncodeStatus_Ok); - EXPECT_GT(size, 0); + EXPECT_GT(size, 0u); // Verify that the encoded extension can be decoded back to the original // extension value. @@ -177,7 +177,7 @@ TEST(EncodeTest, EncodeExtensionSuccessEmptyMessage) { upb_EncodeStatus status = UPB_PRIVATE(_upb_Encode_Extension)( &e, ext, ext_val, false, &buf, &size, e.options); EXPECT_EQ(status, kUpb_EncodeStatus_Ok); - EXPECT_GT(size, 0); + EXPECT_GT(size, 0u); _upb_mapsorter_destroy(&e.sorter); upb_Arena_Free(arena);