From 1785e39d4b87abe74e691bba0b6932c660fea27f Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 08:20:40 +0000 Subject: [PATCH 01/14] add nolint to every include '*.h' that is added by this pr --- oss-internship-2020/libtiff/example/main_sandboxed.cc | 2 +- oss-internship-2020/libtiff/sandboxed.h | 2 +- oss-internship-2020/libtiff/test/check_tag.cc | 2 +- oss-internship-2020/libtiff/test/check_tag.h | 2 +- oss-internship-2020/libtiff/test/defer_strile_writing.cc | 2 +- oss-internship-2020/libtiff/test/helper.cc | 2 +- oss-internship-2020/libtiff/test/helper.h | 2 +- oss-internship-2020/libtiff/test/long_tag.cc | 2 +- oss-internship-2020/libtiff/test/raw_decode.cc | 2 +- oss-internship-2020/libtiff/test/short_tag.cc | 2 +- oss-internship-2020/libtiff/wrapper/CMakeLists.txt | 1 + oss-internship-2020/libtiff/wrapper/func.cc | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index ff255ff..26bf8fd 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -17,7 +17,7 @@ #include #include -#include "../sandboxed.h" +#include "../sandboxed.h" // NOLINT(build/include) #include "sandboxed_api/sandbox2/util/fileops.h" #include "sandboxed_api/sandbox2/util/path.h" #include "sandboxed_api/vars.h" diff --git a/oss-internship-2020/libtiff/sandboxed.h b/oss-internship-2020/libtiff/sandboxed.h index a4995b2..031c633 100644 --- a/oss-internship-2020/libtiff/sandboxed.h +++ b/oss-internship-2020/libtiff/sandboxed.h @@ -18,7 +18,7 @@ #include #include -#include "tiff_sapi.sapi.h" +#include "tiff_sapi.sapi.h" // NOLINT(build/include) namespace { diff --git a/oss-internship-2020/libtiff/test/check_tag.cc b/oss-internship-2020/libtiff/test/check_tag.cc index 5fad6d2..a18e0d6 100644 --- a/oss-internship-2020/libtiff/test/check_tag.cc +++ b/oss-internship-2020/libtiff/test/check_tag.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "check_tag.h" +#include "check_tag.h" // NOLINT(build/include) void CheckShortField(TiffApi& api, sapi::v::RemotePtr& tif, const ttag_t field, const uint16_t value) { diff --git a/oss-internship-2020/libtiff/test/check_tag.h b/oss-internship-2020/libtiff/test/check_tag.h index 688c6c1..234edf8 100644 --- a/oss-internship-2020/libtiff/test/check_tag.h +++ b/oss-internship-2020/libtiff/test/check_tag.h @@ -14,7 +14,7 @@ #include -#include "helper.h" +#include "helper.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) void CheckShortField(TiffApi&, sapi::v::RemotePtr& tif, const ttag_t field, diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index 7183e31..4c0e37f 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -14,7 +14,7 @@ #include -#include "helper.h" +#include "helper.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) namespace { diff --git a/oss-internship-2020/libtiff/test/helper.cc b/oss-internship-2020/libtiff/test/helper.cc index b39d274..18e1205 100644 --- a/oss-internship-2020/libtiff/test/helper.cc +++ b/oss-internship-2020/libtiff/test/helper.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "helper.h" +#include "helper.h" // NOLINT(build/include) std::string GetImagesFolder() { std::string cwd = sandbox2::file_util::fileops::GetCWD(); diff --git a/oss-internship-2020/libtiff/test/helper.h b/oss-internship-2020/libtiff/test/helper.h index 6edb612..589a150 100644 --- a/oss-internship-2020/libtiff/test/helper.h +++ b/oss-internship-2020/libtiff/test/helper.h @@ -15,7 +15,7 @@ #include #include -#include "../sandboxed.h" +#include "../sandboxed.h" // NOLINT(build/include) #include "gtest/gtest.h" #include "sandboxed_api/sandbox2/util/fileops.h" #include "sandboxed_api/sandbox2/util/path.h" diff --git a/oss-internship-2020/libtiff/test/long_tag.cc b/oss-internship-2020/libtiff/test/long_tag.cc index 544761e..5ce5fc0 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -14,7 +14,7 @@ #include -#include "check_tag.h" +#include "check_tag.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) namespace { diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 36836d2..74f1b7b 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -16,7 +16,7 @@ #include #include "gtest/gtest.h" -#include "helper.h" +#include "helper.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) namespace { diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index b36b9c2..e84eb37 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -15,7 +15,7 @@ #include #include -#include "check_tag.h" +#include "check_tag.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) namespace { diff --git a/oss-internship-2020/libtiff/wrapper/CMakeLists.txt b/oss-internship-2020/libtiff/wrapper/CMakeLists.txt index 6627455..7907fc6 100644 --- a/oss-internship-2020/libtiff/wrapper/CMakeLists.txt +++ b/oss-internship-2020/libtiff/wrapper/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(wrapped_tiff OBJECT func.h func.cc ) + set_target_properties(wrapped_tiff PROPERTIES LINKER_LANGUAGE C ) diff --git a/oss-internship-2020/libtiff/wrapper/func.cc b/oss-internship-2020/libtiff/wrapper/func.cc index 0015671..76c42e3 100644 --- a/oss-internship-2020/libtiff/wrapper/func.cc +++ b/oss-internship-2020/libtiff/wrapper/func.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "func.h" +#include "func.h" // NOLINT(build/include) int TIFFGetField1(TIFF* tif, unsigned tag, void* param) { return TIFFGetField(tif, tag, param); From d190abf2e29104f6e9271c91e34dbeff582eaf4c Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 09:40:47 +0000 Subject: [PATCH 02/14] using from .h to .cc --- oss-internship-2020/libtiff/test/check_tag.cc | 4 ++++ oss-internship-2020/libtiff/test/defer_strile_writing.cc | 5 +++++ oss-internship-2020/libtiff/test/helper.h | 7 ------- oss-internship-2020/libtiff/test/long_tag.cc | 5 +++++ oss-internship-2020/libtiff/test/raw_decode.cc | 7 ++++++- oss-internship-2020/libtiff/test/short_tag.cc | 5 +++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/oss-internship-2020/libtiff/test/check_tag.cc b/oss-internship-2020/libtiff/test/check_tag.cc index a18e0d6..821fab8 100644 --- a/oss-internship-2020/libtiff/test/check_tag.cc +++ b/oss-internship-2020/libtiff/test/check_tag.cc @@ -14,6 +14,10 @@ #include "check_tag.h" // NOLINT(build/include) +using ::sapi::IsOk; +using ::testing::Eq; +using ::testing::IsTrue; + void CheckShortField(TiffApi& api, sapi::v::RemotePtr& tif, const ttag_t field, const uint16_t value) { sapi::v::UShort tmp(123); diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index 4c0e37f..726b24e 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -19,6 +19,11 @@ namespace { +using ::sapi::IsOk; +using ::testing::Eq; +using ::testing::IsTrue; +using ::testing::NotNull; + constexpr unsigned kTileBufferSize = 256; constexpr uint16_t kWidth = 1; constexpr uint16_t kBps = 8; diff --git a/oss-internship-2020/libtiff/test/helper.h b/oss-internship-2020/libtiff/test/helper.h index 589a150..5c920f8 100644 --- a/oss-internship-2020/libtiff/test/helper.h +++ b/oss-internship-2020/libtiff/test/helper.h @@ -22,11 +22,4 @@ #include "sandboxed_api/sandbox2/util/temp_file.h" #include "sandboxed_api/util/status_matchers.h" -using ::sapi::IsOk; -using ::testing::Eq; -using ::testing::IsFalse; -using ::testing::IsTrue; -using ::testing::Ne; -using ::testing::NotNull; - std::string GetFilePath(const std::string& filename); diff --git a/oss-internship-2020/libtiff/test/long_tag.cc b/oss-internship-2020/libtiff/test/long_tag.cc index 5ce5fc0..59198f9 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -19,6 +19,11 @@ namespace { +using ::sapi::IsOk; +using ::testing::Ne; +using ::testing::IsTrue; +using ::testing::NotNull; + struct LongTag { ttag_t tag; short count; diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 74f1b7b..9086848 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -15,10 +15,15 @@ #include #include -#include "gtest/gtest.h" #include "helper.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) +using ::sapi::IsOk; +using ::testing::Eq; +using ::testing::IsFalse; +using ::testing::IsTrue; +using ::testing::NotNull; + namespace { struct ChannelLimits { diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index e84eb37..83bf1f8 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -20,6 +20,11 @@ namespace { +using ::sapi::IsOk; +using ::testing::Ne; +using ::testing::IsTrue; +using ::testing::NotNull; + constexpr unsigned kSamplePerPixel = 3; constexpr uint16_t kWidth = 1; constexpr uint16_t kLength = 1; From 69fbe3929326ff6ca49d83c7aee8905aebc11a9c Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 09:44:02 +0000 Subject: [PATCH 03/14] Declare all vars on separate lines --- oss-internship-2020/libtiff/example/main_sandboxed.cc | 3 ++- oss-internship-2020/libtiff/test/raw_decode.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index 26bf8fd..f5df92f 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -163,7 +163,8 @@ absl::Status LibTIFFMain(const std::string& srcfile) { bool pixel_status = true; bool cluster_status = true; // initialize sapi vars after constructing TiffSapiSandbox - sapi::v::UShort h, v; + sapi::v::UShort h; + sapi::v::UShort v; absl::StatusOr status_or_tif; absl::StatusOr status_or_int; absl::StatusOr status_or_long; diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 9086848..82518da 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -145,7 +145,8 @@ TEST(SandboxTest, RawDecode) { TiffSapiSandbox sandbox(srcfile); ASSERT_THAT(sandbox.Init(), IsOk()) << "Couldn't initialize Sandboxed API"; - sapi::v::UShort h, v; + sapi::v::UShort h; + sapi::v::UShort v; absl::StatusOr status_or_tif; absl::StatusOr status_or_int; absl::StatusOr status_or_long; From 6945f7304fd6d03cfaa8f09eeefa02e17a3f61b6 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:01:59 +0000 Subject: [PATCH 04/14] 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; From ab3f992c78cef78534689bdfd327f9e0fa58fac4 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:11:56 +0000 Subject: [PATCH 05/14] using auto* for pointers --- oss-internship-2020/libtiff/example/main_sandboxed.cc | 6 +++--- oss-internship-2020/libtiff/test/raw_decode.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index 3dfbfdd..b9c7698 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -60,7 +60,7 @@ absl::Status CheckCluster(uint32_t cluster, if (buffer.GetSize() <= cluster * kClusterSize) { return absl::InternalError("Buffer overrun\n"); } - auto target = buffer.GetData() + cluster * kClusterSize; + auto* target = buffer.GetData() + cluster * kClusterSize; if (!std::memcmp(target, expected_cluster.data(), kClusterSize)) { return absl::OkStatus(); @@ -80,7 +80,7 @@ absl::Status CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, if (buffer.GetSize() <= pixel * kChannelsInPixel) { return absl::InternalError("Buffer overrun\n"); } - auto rgb = buffer.GetData() + kChannelsInPixel * pixel; + auto* rgb = buffer.GetData() + kChannelsInPixel * pixel; if (rgb[0] >= limits.min_red && rgb[0] <= limits.max_red && rgb[1] >= limits.min_green && rgb[1] <= limits.max_green && @@ -104,7 +104,7 @@ absl::Status CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, return absl::InternalError("Buffer overrun\n"); } - auto rgba = buffer[adjusted_pixel]; + auto* rgba = buffer[adjusted_pixel]; if (TIFFGetR(rgba) >= static_cast(limits.min_red) && TIFFGetR(rgba) <= static_cast(limits.max_red) && TIFFGetG(rgba) >= static_cast(limits.min_green) && diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index dbf8638..36bf842 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -64,7 +64,7 @@ bool CheckCluster(uint32_t cluster, const sapi::v::Array& buffer, return true; } - auto target = buffer.GetData() + cluster * kClusterSize; + auto* target = buffer.GetData() + cluster * kClusterSize; bool comp = !(std::memcmp(target, expected_cluster.data(), kClusterSize) == 0); @@ -89,7 +89,7 @@ bool CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, return true; } - auto rgb = buffer.GetData() + pixel * kChannelsInPixel; + auto* rgb = buffer.GetData() + pixel * kChannelsInPixel; bool comp = !(rgb[0] >= limits.min_red && rgb[0] <= limits.max_red && rgb[1] >= limits.min_green && rgb[1] <= limits.max_green && rgb[2] >= limits.min_blue && rgb[2] <= limits.max_blue); @@ -115,7 +115,7 @@ bool CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, return true; } - auto rgba = buffer[adjusted_pixel]; + auto* rgba = buffer[adjusted_pixel]; bool comp = !(TIFFGetR(rgba) >= static_cast(limits.min_red) && TIFFGetR(rgba) <= static_cast(limits.max_red) && TIFFGetG(rgba) >= static_cast(limits.min_green) && From 466259a98598f8afd9ffa21aa0a0fa3034778ead Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:13:27 +0000 Subject: [PATCH 06/14] using auto* for pointers --- oss-internship-2020/libtiff/example/main_sandboxed.cc | 2 +- oss-internship-2020/libtiff/test/raw_decode.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index b9c7698..7b9b481 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -104,7 +104,7 @@ absl::Status CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, return absl::InternalError("Buffer overrun\n"); } - auto* rgba = buffer[adjusted_pixel]; + auto rgba = buffer[adjusted_pixel]; if (TIFFGetR(rgba) >= static_cast(limits.min_red) && TIFFGetR(rgba) <= static_cast(limits.max_red) && TIFFGetG(rgba) >= static_cast(limits.min_green) && diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 36bf842..f27658a 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -115,7 +115,7 @@ bool CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, return true; } - auto* rgba = buffer[adjusted_pixel]; + auto rgba = buffer[adjusted_pixel]; bool comp = !(TIFFGetR(rgba) >= static_cast(limits.min_red) && TIFFGetR(rgba) <= static_cast(limits.max_red) && TIFFGetG(rgba) >= static_cast(limits.min_green) && From 1d1c4b9579306159a3bcb77ffaa208a8e7acb3b8 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:18:53 +0000 Subject: [PATCH 07/14] clear array initialization --- oss-internship-2020/libtiff/test/defer_strile_writing.cc | 7 +++---- oss-internship-2020/libtiff/test/long_tag.cc | 2 +- oss-internship-2020/libtiff/test/short_tag.cc | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index 1428d50..e403112 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -214,8 +214,7 @@ void TestWriting(const char* mode, int tiled, int height) { for (int i = 0; i < (height + 15) / 16; ++i) { std::array tilebuffer; tilebuffer.fill(i); - sapi::v::Array tilebuffer_(tilebuffer.data(), - kTileBufferSize); + sapi::v::Array tilebuffer_(tilebuffer.data(), tilebuffer.size()); status_or_int = api.TIFFWriteEncodedTile(&tif, i, tilebuffer_.PtrBoth(), kTileBufferSize); @@ -255,8 +254,8 @@ void TestWriting(const char* mode, int tiled, int height) { uint8_t expected_c = static_cast(i); tilebuffer.fill(0); - sapi::v::Array tilebuffer_(tilebuffer.data(), - kTileBufferSize); + sapi::v::Array tilebuffer_(tilebuffer.data(), tilebuffer.size()); + status_or_long = api.TIFFReadEncodedTile( &tif2, i, tilebuffer_.PtrBoth(), kTileBufferSize); 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 04f7d16..99c0eb7 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -51,7 +51,7 @@ TEST(SandboxTest, LongTag) { ASSERT_THAT(sandbox.Init(), IsOk()) << "Couldn't initialize Sandboxed API"; std::array buffer = {0, 127, 255}; - sapi::v::Array buffer_(buffer.data(), kSamplePerPixel); + sapi::v::Array buffer_(buffer.data(), buffer.size()); absl::StatusOr status_or_int; absl::StatusOr status_or_tif; diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index 283a6ba..aa7d0c5 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -72,7 +72,7 @@ TEST(SandboxTest, ShortTag) { ASSERT_THAT(sandbox.Init(), IsOk()) << "Couldn't initialize Sandboxed API"; std::array buffer = {0, 127, 255}; - sapi::v::Array buffer_(buffer.data(), kSamplePerPixel); + sapi::v::Array buffer_(buffer.data(), buffer.size()); absl::StatusOr status_or_int; absl::StatusOr status_or_tif; From 64b74c97e0f28a6505a1003c86449062219102cd Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:23:42 +0000 Subject: [PATCH 08/14] 4 spaces -> 2 spaces --- oss-internship-2020/libtiff/CMakeLists.txt | 136 ++++++++++----------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/oss-internship-2020/libtiff/CMakeLists.txt b/oss-internship-2020/libtiff/CMakeLists.txt index 6915ad8..e46993a 100644 --- a/oss-internship-2020/libtiff/CMakeLists.txt +++ b/oss-internship-2020/libtiff/CMakeLists.txt @@ -36,90 +36,90 @@ set(SAPI_ENABLE_TESTS ${TIFF_SAPI_ENABLE_TESTS} CACHE BOOL "" FORCE) add_subdirectory(wrapper) add_subdirectory( - "${SAPI_ROOT}" - "${CMAKE_BINARY_DIR}/sandboxed-api-build" - # Omit this to have the full Sandboxed API in IDE - EXCLUDE_FROM_ALL + "${SAPI_ROOT}" + "${CMAKE_BINARY_DIR}/sandboxed-api-build" + # Omit this to have the full Sandboxed API in IDE + EXCLUDE_FROM_ALL ) add_sapi_library(tiff_sapi - # List of functions that we want to include in the - # generated sandboxed API class + # List of functions that we want to include in the + # generated sandboxed API class - FUNCTIONS TIFFOpen - TIFFClose + FUNCTIONS TIFFOpen + TIFFClose - TIFFGetField1 - TIFFGetField2 - TIFFGetField3 + TIFFGetField1 + TIFFGetField2 + TIFFGetField3 - TIFFSetFieldUChar1 - TIFFSetFieldUChar2 - TIFFSetFieldUChar3 - TIFFSetFieldSChar1 - TIFFSetFieldSChar2 - TIFFSetFieldSChar3 - TIFFSetFieldU1 - TIFFSetFieldU2 - TIFFSetFieldU3 - TIFFSetFieldS1 - TIFFSetFieldS2 - TIFFSetFieldS3 - TIFFSetFieldUShort1 - TIFFSetFieldUShort2 - TIFFSetFieldUShort3 - TIFFSetFieldSShort1 - TIFFSetFieldSShort2 - TIFFSetFieldSShort3 - TIFFSetFieldULLong1 - TIFFSetFieldULLong2 - TIFFSetFieldULLong3 - TIFFSetFieldSLLong1 - TIFFSetFieldSLLong2 - TIFFSetFieldSLLong3 - TIFFSetFieldFloat1 - TIFFSetFieldFloat2 - TIFFSetFieldFloat3 - TIFFSetFieldDouble1 - TIFFSetFieldDouble2 - TIFFSetFieldDouble3 + TIFFSetFieldUChar1 + TIFFSetFieldUChar2 + TIFFSetFieldUChar3 + TIFFSetFieldSChar1 + TIFFSetFieldSChar2 + TIFFSetFieldSChar3 + TIFFSetFieldU1 + TIFFSetFieldU2 + TIFFSetFieldU3 + TIFFSetFieldS1 + TIFFSetFieldS2 + TIFFSetFieldS3 + TIFFSetFieldUShort1 + TIFFSetFieldUShort2 + TIFFSetFieldUShort3 + TIFFSetFieldSShort1 + TIFFSetFieldSShort2 + TIFFSetFieldSShort3 + TIFFSetFieldULLong1 + TIFFSetFieldULLong2 + TIFFSetFieldULLong3 + TIFFSetFieldSLLong1 + TIFFSetFieldSLLong2 + TIFFSetFieldSLLong3 + TIFFSetFieldFloat1 + TIFFSetFieldFloat2 + TIFFSetFieldFloat3 + TIFFSetFieldDouble1 + TIFFSetFieldDouble2 + TIFFSetFieldDouble3 - TIFFReadRGBATile - TIFFReadEncodedTile - TIFFReadEncodedStrip - TIFFReadFromUserBuffer + TIFFReadRGBATile + TIFFReadEncodedTile + TIFFReadEncodedStrip + TIFFReadFromUserBuffer - TIFFTileSize - TIFFSetDirectory - TIFFFreeDirectory - TIFFCreateDirectory + TIFFTileSize + TIFFSetDirectory + TIFFFreeDirectory + TIFFCreateDirectory - TIFFForceStrileArrayWriting - TIFFDeferStrileArrayWriting + TIFFForceStrileArrayWriting + TIFFDeferStrileArrayWriting - TIFFWriteCheck - TIFFWriteScanline - TIFFWriteDirectory - TIFFWriteEncodedTile - TIFFWriteEncodedStrip + TIFFWriteCheck + TIFFWriteScanline + TIFFWriteDirectory + TIFFWriteEncodedTile + TIFFWriteEncodedStrip - TIFFGetStrileOffsetWithErr - TIFFGetStrileByteCountWithErr + TIFFGetStrileOffsetWithErr + TIFFGetStrileByteCountWithErr - TIFFCreateEXIFDirectory - TIFFWriteCustomDirectory + TIFFCreateEXIFDirectory + TIFFWriteCustomDirectory - INPUTS wrapper/libtiff/libtiff/tiffio.h - wrapper/func.h - # Header files or .cc files that should be parsed - LIBRARY wrapped_tiff # Library dependency from the add_library() above - LIBRARY_NAME Tiff # Name prefix for the generated header. Will be - # suffixed with "Api" and "Sandbox" as needed. - NAMESPACE "" # Optional C++ namespace to wrap the generated code + INPUTS wrapper/libtiff/libtiff/tiffio.h + wrapper/func.h + # Header files or .cc files that should be parsed + LIBRARY wrapped_tiff # Library dependency from the add_library() above + LIBRARY_NAME Tiff # Name prefix for the generated header. Will be + # suffixed with "Api" and "Sandbox" as needed. + NAMESPACE "" # Optional C++ namespace to wrap the generated code ) target_include_directories(tiff_sapi INTERFACE - "${PROJECT_BINARY_DIR}" # To find the generated SAPI header + "${PROJECT_BINARY_DIR}" # To find the generated SAPI header ) if (TIFF_SAPI_ENABLE_EXAMPLES) From 16d904e174eda9cec429be93ac65ecbf343a0e9d Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:24:55 +0000 Subject: [PATCH 09/14] code block --- oss-internship-2020/libtiff/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/oss-internship-2020/libtiff/README.md b/oss-internship-2020/libtiff/README.md index 87ac46c..4863b47 100644 --- a/oss-internship-2020/libtiff/README.md +++ b/oss-internship-2020/libtiff/README.md @@ -9,9 +9,11 @@ You should make sure the libtiff submodule is cloned. ## Usage #### build: -`mkdir -p build && cd build && cmake .. -DSAPI_ROOT=/path/to/sapi_root -DBUILD_SHARED_LIBS=OFF` - -`make -j 8` +``` + mkdir -p build && cd build && \ + cmake .. -DSAPI_ROOT=/path/to/sapi_root -DBUILD_SHARED_LIBS=OFF + make -j8 +``` #### to run the sandboxed example: `./example/sandboxed /absolute/path/to/project/dir` From 60541cc8eacb7ac5f53ed6aaeaac09e9501cd6a3 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:30:10 +0000 Subject: [PATCH 10/14] clang-format --- oss-internship-2020/libtiff/test/defer_strile_writing.cc | 3 ++- oss-internship-2020/libtiff/test/long_tag.cc | 4 ++-- oss-internship-2020/libtiff/test/short_tag.cc | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index e403112..5403d2a 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -254,7 +254,8 @@ void TestWriting(const char* mode, int tiled, int height) { uint8_t expected_c = static_cast(i); tilebuffer.fill(0); - sapi::v::Array tilebuffer_(tilebuffer.data(), tilebuffer.size()); + sapi::v::Array tilebuffer_(tilebuffer.data(), + tilebuffer.size()); status_or_long = api.TIFFReadEncodedTile( &tif2, i, tilebuffer_.PtrBoth(), kTileBufferSize); diff --git a/oss-internship-2020/libtiff/test/long_tag.cc b/oss-internship-2020/libtiff/test/long_tag.cc index 99c0eb7..fc1b644 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -15,13 +15,13 @@ #include #include "check_tag.h" // NOLINT(build/include) -#include "tiffio.h" // NOLINT(build/include) +#include "tiffio.h" // NOLINT(build/include) namespace { using ::sapi::IsOk; -using ::testing::Ne; using ::testing::IsTrue; +using ::testing::Ne; using ::testing::NotNull; struct LongTag { diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index aa7d0c5..5620ec5 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -16,13 +16,13 @@ #include #include "check_tag.h" // NOLINT(build/include) -#include "tiffio.h" // NOLINT(build/include) +#include "tiffio.h" // NOLINT(build/include) namespace { using ::sapi::IsOk; -using ::testing::Ne; using ::testing::IsTrue; +using ::testing::Ne; using ::testing::NotNull; constexpr uint16_t kSamplePerPixel = 3; From 554c03bec9d49d2bd7875b7eed5936f2afd27db0 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 10:53:08 +0000 Subject: [PATCH 11/14] use absl format string --- .../libtiff/example/main_sandboxed.cc | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index 7b9b481..0dec1ff 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -54,6 +54,21 @@ constexpr std::array, kTestCount> kLimits = { {64, {0, 0, 0, 0, 0, 2, 255, 255}}, {512, {5, 6, 34, 36, 182, 196, 255, 255}}}}; +constexpr absl::string_view kClusterErrorFormatStr = + "Cluster %d did not match expected results.\n" + "Expect:\t%3d\t%3d\t%3d\t%3d\t%3d\t%3d\n" + "Got:\t%3d\t%3d\t%3d\t%3d\t%3d\t%3d\n"; + +constexpr absl::string_view kRgbPixelErrorFormatStr = + "Pixel %d did not match expected results.\n" + "Got R=%d (expected %d..%d), G=%d (expected %d..%d), " + "B=%d (expected %d..%d)\n"; + +constexpr absl::string_view kRgbaPixelErrorFormatStr = + "Pixel %d did not match expected results.\n" + "Got R=%d (expected %d..%d), G=%d (expected %d..%d), " + "B=%d (expected %d..%d), A=%d (expected %d..%d)\n"; + absl::Status CheckCluster(uint32_t cluster, const sapi::v::Array& buffer, const ClusterData& expected_cluster) { @@ -67,12 +82,11 @@ absl::Status CheckCluster(uint32_t cluster, } // the image is split on 6-bit clusters because it has YCbCr color format - return absl::InternalError(absl::StrCat( - "Cluster ", cluster, " did not match expected results.\n", "Expect: ", - expected_cluster[0], "\t", expected_cluster[1], "\t", expected_cluster[2], - "\t", expected_cluster[3], "\t", expected_cluster[4], "\t", - expected_cluster[5], "\n", "Got: ", target[0], "\t", target[1], "\t", - target[2], "\t", target[3], "\t", target[4], "\t", target[5], "\n")); + return absl::InternalError(absl::StrFormat( + kClusterErrorFormatStr, cluster, expected_cluster[0], expected_cluster[1], + expected_cluster[2], expected_cluster[3], expected_cluster[4], + expected_cluster[5], target[0], target[1], target[2], target[3], + target[4], target[5])); } absl::Status CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, @@ -88,11 +102,10 @@ absl::Status CheckRgbPixel(uint32_t pixel, const ChannelLimits& limits, return absl::OkStatus(); } - return absl::InternalError(absl::StrCat( - "Pixel ", pixel, " did not match expected results.\n", "Got R=", rgb[0], - " (expected ", limits.min_red, "..=", limits.max_red, "), G=", rgb[1], - " (expected ", limits.min_green, "..=", limits.max_green, "), B=", rgb[2], - " (expected ", limits.min_blue, "..=", limits.max_blue, ")\n")); + return absl::InternalError(absl::StrFormat( + kRgbPixelErrorFormatStr, pixel, rgb[0], limits.min_red, limits.max_red, + rgb[1], limits.min_green, limits.max_green, rgb[2], limits.min_blue, + limits.max_blue)); } absl::Status CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, @@ -116,13 +129,11 @@ absl::Status CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits, return absl::OkStatus(); } - return absl::InternalError(absl::StrCat( - "Pixel ", pixel, " did not match expected results.\n", "Got R=", - TIFFGetR(rgba), " (expected ", limits.min_red, "..=", limits.max_red, - "), G=", TIFFGetG(rgba), " (expected ", limits.min_green, - "..=", limits.max_green, "), B=", TIFFGetB(rgba), " (expected ", - limits.min_blue, "..=", limits.max_blue, "), A=", TIFFGetA(rgba), - " (expected ", limits.min_alpha, "..=", limits.max_alpha, ")\n")); + return absl::InternalError(absl::StrFormat( + kRgbaPixelErrorFormatStr, pixel, TIFFGetR(rgba), limits.min_red, + limits.max_red, TIFFGetG(rgba), limits.min_green, limits.max_green, + TIFFGetB(rgba), limits.min_blue, limits.max_blue, TIFFGetA(rgba), + limits.min_alpha, limits.max_alpha)); } } // namespace From 7750b43c566da3b9bce100a4f3855cca4bda5bdf Mon Sep 17 00:00:00 2001 From: Latysheva Alexandra <35174583+alexelex@users.noreply.github.com> Date: Sun, 11 Oct 2020 16:54:37 +0600 Subject: [PATCH 12/14] remove tabs in readme --- oss-internship-2020/libtiff/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oss-internship-2020/libtiff/README.md b/oss-internship-2020/libtiff/README.md index 4863b47..73a3899 100644 --- a/oss-internship-2020/libtiff/README.md +++ b/oss-internship-2020/libtiff/README.md @@ -10,9 +10,9 @@ You should make sure the libtiff submodule is cloned. #### build: ``` - mkdir -p build && cd build && \ - cmake .. -DSAPI_ROOT=/path/to/sapi_root -DBUILD_SHARED_LIBS=OFF - make -j8 +mkdir -p build && cd build && \ + cmake .. -DSAPI_ROOT=/path/to/sapi_root -DBUILD_SHARED_LIBS=OFF +make -j8 ``` #### to run the sandboxed example: From 77c44f9c87b0d2226f0d0e8049bec67d806830da Mon Sep 17 00:00:00 2001 From: Latysheva Alexandra <35174583+alexelex@users.noreply.github.com> Date: Sun, 11 Oct 2020 17:02:47 +0600 Subject: [PATCH 13/14] add flags to readme --- oss-internship-2020/libtiff/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/oss-internship-2020/libtiff/README.md b/oss-internship-2020/libtiff/README.md index 73a3899..84b78ca 100644 --- a/oss-internship-2020/libtiff/README.md +++ b/oss-internship-2020/libtiff/README.md @@ -8,15 +8,17 @@ You should make sure the libtiff submodule is cloned. ## Usage -#### build: +#### Build: ``` mkdir -p build && cd build && \ cmake .. -DSAPI_ROOT=/path/to/sapi_root -DBUILD_SHARED_LIBS=OFF make -j8 ``` -#### to run the sandboxed example: -`./example/sandboxed /absolute/path/to/project/dir` +#### Example: +You should add `-DTIFF_SAPI_ENABLE_EXAMPLES=ON` to use the example.\ +run: `./example/sandboxed /absolute/path/to/project/dir` -#### to run tests: -`./test/tests` +#### Tests: +You should add `-DTIFF_SAPI_ENABLE_TESTS=ON` to use tests.\ +run: `./test/tests` From 9eb518c57a564fd8a484aa64b68e6aecff7e92b8 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Sun, 11 Oct 2020 11:06:18 +0000 Subject: [PATCH 14/14] move using to namespace --- oss-internship-2020/libtiff/test/raw_decode.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index f27658a..740e1e9 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -18,14 +18,14 @@ #include "helper.h" // NOLINT(build/include) #include "tiffio.h" // NOLINT(build/include) +namespace { + using ::sapi::IsOk; using ::testing::Eq; using ::testing::IsFalse; using ::testing::IsTrue; using ::testing::NotNull; -namespace { - struct ChannelLimits { uint8_t min_red; uint8_t max_red;