From 6945f7304fd6d03cfaa8f09eeefa02e17a3f61b6 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:01:59 +0000 Subject: [PATCH] replace all unsigned except in wrapper --- .../libtiff/example/main_sandboxed.cc | 28 +++++++++---------- oss-internship-2020/libtiff/test/check_tag.cc | 2 +- oss-internship-2020/libtiff/test/check_tag.h | 2 +- .../libtiff/test/defer_strile_writing.cc | 14 +++++----- oss-internship-2020/libtiff/test/long_tag.cc | 14 +++++----- .../libtiff/test/raw_decode.cc | 28 +++++++++---------- oss-internship-2020/libtiff/test/short_tag.cc | 2 +- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index f5df92f..3dfbfdd 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -36,25 +36,25 @@ struct ChannelLimits { uint8_t max_alpha; }; -constexpr unsigned kRawTileNumber = 9; -constexpr unsigned kClusterSize = 6; -constexpr unsigned kChannelsInPixel = 3; -constexpr unsigned kTestCount = 3; -constexpr unsigned kImageSize = 128 * 128; -constexpr unsigned kClusterImageSize = 64 * 64; +constexpr uint32_t kRawTileNumber = 9; +constexpr uint32_t kClusterSize = 6; +constexpr uint32_t kChannelsInPixel = 3; +constexpr uint32_t kTestCount = 3; +constexpr uint32_t kImageSize = 128 * 128; +constexpr uint32_t kClusterImageSize = 64 * 64; using ClusterData = std::array; -constexpr std::array, kTestCount> kClusters = { +constexpr std::array, kTestCount> kClusters = { {{0, {0, 0, 2, 0, 138, 139}}, {64, {0, 0, 9, 6, 134, 119}}, {128, {44, 40, 63, 59, 230, 95}}}}; -constexpr std::array, kTestCount> kLimits = { +constexpr std::array, kTestCount> kLimits = { {{0, {15, 18, 0, 0, 18, 41, 255, 255}}, {64, {0, 0, 0, 0, 0, 2, 255, 255}}, {512, {5, 6, 34, 36, 182, 196, 255, 255}}}}; -absl::Status CheckCluster(unsigned cluster, +absl::Status CheckCluster(uint32_t cluster, const sapi::v::Array& buffer, const ClusterData& expected_cluster) { if (buffer.GetSize() <= cluster * kClusterSize) { @@ -75,7 +75,7 @@ absl::Status CheckCluster(unsigned cluster, target[2], "\t", target[3], "\t", target[4], "\t", target[5], "\n")); } -absl::Status CheckRgbPixel(unsigned pixel, const ChannelLimits& limits, +absl::Status CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, const sapi::v::Array& buffer) { if (buffer.GetSize() <= pixel * kChannelsInPixel) { return absl::InternalError("Buffer overrun\n"); @@ -95,10 +95,10 @@ absl::Status CheckRgbPixel(unsigned pixel, const ChannelLimits& limits, " (expected ", limits.min_blue, "..=", limits.max_blue, ")\n")); } -absl::Status CheckRgbaPixel(unsigned pixel, const ChannelLimits& limits, - const sapi::v::Array& buffer) { +absl::Status CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, + const sapi::v::Array& buffer) { // RGBA images are upside down - adjust for normal ordering - unsigned adjusted_pixel = pixel % 128 + (127 - (pixel / 128)) * 128; + uint32_t adjusted_pixel = pixel % 128 + (127 - (pixel / 128)) * 128; if (buffer.GetSize() <= adjusted_pixel) { return absl::InternalError("Buffer overrun\n"); @@ -264,7 +264,7 @@ absl::Status LibTIFFMain(const std::string& srcfile) { return absl::InternalError(absl::StrCat("Could not reopen ", srcfile)); } - sapi::v::Array rgba_buffer_(kImageSize); + sapi::v::Array rgba_buffer_(kImageSize); // read as rgba SAPI_ASSIGN_OR_RETURN( diff --git a/oss-internship-2020/libtiff/test/check_tag.cc b/oss-internship-2020/libtiff/test/check_tag.cc index 821fab8..b30f23d 100644 --- a/oss-internship-2020/libtiff/test/check_tag.cc +++ b/oss-internship-2020/libtiff/test/check_tag.cc @@ -50,7 +50,7 @@ void CheckShortPairedField(TiffApi& api, sapi::v::RemotePtr& tif, } void CheckLongField(TiffApi& api, sapi::v::RemotePtr& tif, const ttag_t field, - const unsigned value) { + const uint32_t value) { sapi::v::UInt tmp(123); absl::StatusOr status_or_int; diff --git a/oss-internship-2020/libtiff/test/check_tag.h b/oss-internship-2020/libtiff/test/check_tag.h index 234edf8..b60cd74 100644 --- a/oss-internship-2020/libtiff/test/check_tag.h +++ b/oss-internship-2020/libtiff/test/check_tag.h @@ -23,4 +23,4 @@ void CheckShortPairedField(TiffApi& api, sapi::v::RemotePtr& tif, const ttag_t field, const std::array& values); void CheckLongField(TiffApi&, sapi::v::RemotePtr& tif, const ttag_t field, - const unsigned value); + const uint32_t value); diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index 726b24e..1428d50 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -24,7 +24,7 @@ using ::testing::Eq; using ::testing::IsTrue; using ::testing::NotNull; -constexpr unsigned kTileBufferSize = 256; +constexpr uint16_t kTileBufferSize = 256; constexpr uint16_t kWidth = 1; constexpr uint16_t kBps = 8; constexpr uint16_t kRowsPerStrip = 1; @@ -212,9 +212,9 @@ void TestWriting(const char* mode, int tiled, int height) { if (tiled) { for (int i = 0; i < (height + 15) / 16; ++i) { - std::array tilebuffer; + std::array tilebuffer; tilebuffer.fill(i); - sapi::v::Array tilebuffer_(tilebuffer.data(), + sapi::v::Array tilebuffer_(tilebuffer.data(), kTileBufferSize); status_or_int = api.TIFFWriteEncodedTile(&tif, i, tilebuffer_.PtrBoth(), @@ -251,11 +251,11 @@ void TestWriting(const char* mode, int tiled, int height) { if (tiled) { for (int i = 0; i < (height + 15) / 16; ++i) { for (int retry = 0; retry < 2; ++retry) { - std::array tilebuffer; - unsigned char expected_c = (unsigned char)i; + std::array tilebuffer; + uint8_t expected_c = static_cast(i); tilebuffer.fill(0); - sapi::v::Array tilebuffer_(tilebuffer.data(), + sapi::v::Array tilebuffer_(tilebuffer.data(), kTileBufferSize); status_or_long = api.TIFFReadEncodedTile( &tif2, i, tilebuffer_.PtrBoth(), kTileBufferSize); @@ -283,7 +283,7 @@ void TestWriting(const char* mode, int tiled, int height) { for (int i = 0; i < height; ++i) { for (int retry = 0; retry < 2; ++retry) { sapi::v::UChar c(0); - unsigned char expected_c = (unsigned char)i; + uint8_t expected_c = static_cast(i); status_or_long = api.TIFFReadEncodedStrip(&tif2, i, c.PtrBoth(), 1); ASSERT_THAT(status_or_long, IsOk()) diff --git a/oss-internship-2020/libtiff/test/long_tag.cc b/oss-internship-2020/libtiff/test/long_tag.cc index 59198f9..04f7d16 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -26,18 +26,18 @@ using ::testing::NotNull; struct LongTag { ttag_t tag; - short count; - unsigned value; + int16_t count; + uint32_t value; }; constexpr std::array kLongTags = { {TIFFTAG_SUBFILETYPE, 1, FILETYPE_REDUCEDIMAGE | FILETYPE_PAGE | FILETYPE_MASK}}; -constexpr unsigned kSamplePerPixel = 3; -constexpr unsigned kWidth = 1; -constexpr unsigned kLength = 1; -constexpr unsigned kBps = 8; -constexpr unsigned kRowsPerStrip = 1; +constexpr uint32_t kSamplePerPixel = 3; +constexpr uint32_t kWidth = 1; +constexpr uint32_t kLength = 1; +constexpr uint32_t kBps = 8; +constexpr uint32_t kRowsPerStrip = 1; TEST(SandboxTest, LongTag) { absl::StatusOr status_or_path = diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 82518da..dbf8638 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -37,25 +37,25 @@ struct ChannelLimits { uint8_t max_alpha; }; -constexpr unsigned kRawTileNumber = 9; -constexpr unsigned kClusterSize = 6; -constexpr unsigned kChannelsInPixel = 3; -constexpr unsigned kTestCount = 3; -constexpr unsigned kImageSize = 128 * 128; -constexpr unsigned kClusterImageSize = 64 * 64; +constexpr uint32_t kRawTileNumber = 9; +constexpr uint32_t kClusterSize = 6; +constexpr uint32_t kChannelsInPixel = 3; +constexpr uint32_t kTestCount = 3; +constexpr uint32_t kImageSize = 128 * 128; +constexpr uint32_t kClusterImageSize = 64 * 64; using ClusterData = std::array; -constexpr std::array, kTestCount> kClusters = { +constexpr std::array, kTestCount> kClusters = { {{0, {0, 0, 2, 0, 138, 139}}, {64, {0, 0, 9, 6, 134, 119}}, {128, {44, 40, 63, 59, 230, 95}}}}; -constexpr std::array, kTestCount> kLimits = { +constexpr std::array, kTestCount> kLimits = { {{0, {15, 18, 0, 0, 18, 41, 255, 255}}, {64, {0, 0, 0, 0, 0, 2, 255, 255}}, {512, {5, 6, 34, 36, 182, 196, 255, 255}}}}; -bool CheckCluster(unsigned cluster, const sapi::v::Array& buffer, +bool CheckCluster(uint32_t cluster, const sapi::v::Array& buffer, const ClusterData& expected_cluster) { bool is_overrun = (buffer.GetSize() <= cluster * kClusterSize); EXPECT_THAT(is_overrun, IsFalse()) << "Overrun"; @@ -80,7 +80,7 @@ bool CheckCluster(unsigned cluster, const sapi::v::Array& buffer, return comp; } -bool CheckRgbPixel(unsigned pixel, const ChannelLimits& limits, +bool CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, const sapi::v::Array& buffer) { bool is_overrun = (buffer.GetSize() <= pixel * kChannelsInPixel); EXPECT_THAT(is_overrun, IsFalse()) << "Overrun"; @@ -103,10 +103,10 @@ bool CheckRgbPixel(unsigned pixel, const ChannelLimits& limits, return comp; } -bool CheckRgbaPixel(unsigned pixel, const ChannelLimits& limits, - const sapi::v::Array& buffer) { +bool CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, + const sapi::v::Array& buffer) { // RGBA images are upside down - adjust for normal ordering - unsigned adjusted_pixel = pixel % 128 + (127 - (pixel / 128)) * 128; + uint32_t adjusted_pixel = pixel % 128 + (127 - (pixel / 128)) * 128; bool is_overrun = (buffer.GetSize() <= adjusted_pixel); EXPECT_THAT(is_overrun, IsFalse()) << "Overrun"; @@ -225,7 +225,7 @@ TEST(SandboxTest, RawDecode) { ASSERT_THAT(tif2.GetValue(), NotNull()) << "Could not open " << srcfile << ", TIFFOpen return NULL"; - sapi::v::Array rgba_buffer_(kImageSize); + sapi::v::Array rgba_buffer_(kImageSize); status_or_int = api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer_.PtrBoth()); diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index 83bf1f8..283a6ba 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -25,7 +25,7 @@ using ::testing::Ne; using ::testing::IsTrue; using ::testing::NotNull; -constexpr unsigned kSamplePerPixel = 3; +constexpr uint16_t kSamplePerPixel = 3; constexpr uint16_t kWidth = 1; constexpr uint16_t kLength = 1; constexpr uint16_t kBps = 8;