auto& -> const auto&; bool status -> bool status_ok

This commit is contained in:
Alexandra Latysheva 2020-10-19 10:36:47 +00:00
parent 9eb518c57a
commit 316828a219
3 changed files with 13 additions and 13 deletions

View File

@ -171,8 +171,8 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
TiffSapiSandbox sandbox(srcfile); TiffSapiSandbox sandbox(srcfile);
bool pixel_status = true; bool pixel_status_ok = true;
bool cluster_status = true; bool cluster_status_ok = true;
// initialize sapi vars after constructing TiffSapiSandbox // initialize sapi vars after constructing TiffSapiSandbox
sapi::v::UShort h; sapi::v::UShort h;
sapi::v::UShort v; sapi::v::UShort v;
@ -226,10 +226,10 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckCluster(id, buffer_, data); !status.ok()) { if (status = CheckCluster(id, buffer_, data); !status.ok()) {
LOG(ERROR) << "CheckCluster failed:\n" << status.ToString(); LOG(ERROR) << "CheckCluster failed:\n" << status.ToString();
} }
cluster_status &= status.ok(); cluster_status_ok &= status.ok();
} }
if (!cluster_status) { if (!cluster_status_ok) {
return absl::InternalError("One or more clusters failed the check"); return absl::InternalError("One or more clusters failed the check");
} }
@ -262,7 +262,7 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckRgbPixel(id, data, buffer2_); !status.ok()) { if (status = CheckRgbPixel(id, data, buffer2_); !status.ok()) {
LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString(); LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString();
} }
pixel_status &= status.ok(); pixel_status_ok &= status.ok();
} }
SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif)); SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif));
@ -290,12 +290,12 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckRgbaPixel(id, data, rgba_buffer_); !status.ok()) { if (status = CheckRgbaPixel(id, data, rgba_buffer_); !status.ok()) {
LOG(ERROR) << "CheckRgbaPixel failed:\n" << status.ToString(); LOG(ERROR) << "CheckRgbaPixel failed:\n" << status.ToString();
} }
pixel_status &= status.ok(); pixel_status_ok &= status.ok();
} }
SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif2)); SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif2));
if (!pixel_status) { if (!pixel_status_ok) {
return absl::InternalError("wrong encoding"); return absl::InternalError("wrong encoding");
} }

View File

@ -101,7 +101,7 @@ TEST(SandboxTest, LongTag) {
EXPECT_THAT(status_or_int.value(), IsTrue()) EXPECT_THAT(status_or_int.value(), IsTrue())
<< "Can't set PhotometricInterpretation tag"; << "Can't set PhotometricInterpretation tag";
for (auto& tag : kLongTags) { for (const auto& tag : kLongTags) {
status_or_int = api.TIFFSetFieldU1(&tif, tag.tag, tag.value); status_or_int = api.TIFFSetFieldU1(&tif, tag.tag, tag.value);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error"; ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error";
EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag; EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag;
@ -125,7 +125,7 @@ TEST(SandboxTest, LongTag) {
CheckLongField(api, tif2, TIFFTAG_IMAGELENGTH, kLength); CheckLongField(api, tif2, TIFFTAG_IMAGELENGTH, kLength);
CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip); CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip);
for (auto& tag : kLongTags) { for (const auto& tag : kLongTags) {
CheckLongField(api, tif2, tag.tag, tag.value); CheckLongField(api, tif2, tag.tag, tag.value);
} }

View File

@ -123,13 +123,13 @@ TEST(SandboxTest, ShortTag) {
EXPECT_THAT(status_or_int.value(), IsTrue()) EXPECT_THAT(status_or_int.value(), IsTrue())
<< "Can't set PhotometricInterpretation tag"; << "Can't set PhotometricInterpretation tag";
for (auto& tag : kShortSingleTags) { for (const auto& tag : kShortSingleTags) {
status_or_int = api.TIFFSetFieldUShort1(&tif, tag.tag, tag.value); status_or_int = api.TIFFSetFieldUShort1(&tif, tag.tag, tag.value);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error"; ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error";
EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag; EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag;
} }
for (auto& tag : kShortPairedTags) { for (const auto& tag : kShortPairedTags) {
status_or_int = status_or_int =
api.TIFFSetFieldUShort2(&tif, tag.tag, tag.values[0], tag.values[1]); api.TIFFSetFieldUShort2(&tif, tag.tag, tag.values[0], tag.values[1]);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort2 fatal error"; ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort2 fatal error";
@ -158,11 +158,11 @@ TEST(SandboxTest, ShortTag) {
CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip); CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip);
CheckShortField(api, tif2, TIFFTAG_PLANARCONFIG, kPlanarConfig); CheckShortField(api, tif2, TIFFTAG_PLANARCONFIG, kPlanarConfig);
for (auto& tag : kShortSingleTags) { for (const auto& tag : kShortSingleTags) {
CheckShortField(api, tif2, tag.tag, tag.value); CheckShortField(api, tif2, tag.tag, tag.value);
} }
for (auto& tag : kShortPairedTags) { for (const auto& tag : kShortPairedTags) {
CheckShortPairedField(api, tif2, tag.tag, tag.values); CheckShortPairedField(api, tif2, tag.tag, tag.values);
} }