This is an automated email from the ASF dual-hosted git repository. joemcdonnell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit f39ddb1443eaa588ec85254d0a4aefe95f105b7a Author: Joe McDonnell <joemcdonn...@cloudera.com> AuthorDate: Tue May 19 19:39:43 2020 -0700 IMPALA-9761: Fix GCC7 ambiguous else warning for gtest macros On GCC7, a dangling-else warning is firing for code like: if (cond1) ASSERT_TRUE(cond2) This is true for several ASSERT_* and EXPECT_* gtest macros. gtest had some code to avoid warnings for code of this form, but that code is no longer effective. gtest now disables the dangling-else warning. Since this is just a matter of adding braces, this adds braces for all those locations. For consistency, this may include locations that were not failing. I found locations by doing: git grep EXPECT_ | grep if git grep ASSERT_ | grep if and manually looking through the output. Testing: - Builds successfully Change-Id: Ieb664afe83736a71508302575e8e66a1b506c985 Reviewed-on: http://gerrit.cloudera.org:8080/15964 Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> --- be/src/exec/parquet/parquet-common-test.cc | 8 ++++++-- be/src/runtime/buffered-tuple-stream-test.cc | 4 +++- be/src/runtime/bufferpool/buffer-pool-test.cc | 8 ++++++-- be/src/runtime/io/disk-io-mgr-test.cc | 4 +++- be/src/runtime/timestamp-test.cc | 12 ++++++++---- be/src/testutil/cpu-util.h | 4 +++- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/be/src/exec/parquet/parquet-common-test.cc b/be/src/exec/parquet/parquet-common-test.cc index b67603a..0dc519f 100644 --- a/be/src/exec/parquet/parquet-common-test.cc +++ b/be/src/exec/parquet/parquet-common-test.cc @@ -30,7 +30,9 @@ void ValidateRanges(RangeVec skip_ranges, int num_rows, const RangeVec& expected RangeVec result; bool success = ComputeCandidateRanges(num_rows, &skip_ranges, &result); EXPECT_EQ(should_succeed, success); - if (success) EXPECT_EQ(expected, result); + if (success) { + EXPECT_EQ(expected, result); + } } void ValidateRangesError(RangeVec skip_ranges, int num_rows, const RangeVec& expected) { @@ -76,7 +78,9 @@ void ValidatePages(const vector<int64_t>& first_row_indexes, const RangeVec& ran bool success = ComputeCandidatePages(page_locations, ranges, num_rows, &candidate_pages); EXPECT_EQ(should_succeed, success); - if (success) EXPECT_EQ(expected_page_indexes, candidate_pages); + if (success) { + EXPECT_EQ(expected_page_indexes, candidate_pages); + } } void ValidatePagesError(const vector<int64_t>& first_row_indexes, const RangeVec& ranges, diff --git a/be/src/runtime/buffered-tuple-stream-test.cc b/be/src/runtime/buffered-tuple-stream-test.cc index 37d0323..1c42f07 100644 --- a/be/src/runtime/buffered-tuple-stream-test.cc +++ b/be/src/runtime/buffered-tuple-stream-test.cc @@ -854,7 +854,9 @@ void SimpleTupleStreamTest::TestAttachMemory(bool pin_stream, bool attach_on_rea } else { EXPECT_EQ(0, num_buffers_attached) << "No buffers attached during iteration."; } - if (attach_on_read || !pin_stream) EXPECT_EQ(4, num_flushes); + if (attach_on_read || !pin_stream) { + EXPECT_EQ(4, num_flushes); + } out_batch->Reset(); stream.Close(out_batch, RowBatch::FlushMode::FLUSH_RESOURCES); if (attach_on_read) { diff --git a/be/src/runtime/bufferpool/buffer-pool-test.cc b/be/src/runtime/bufferpool/buffer-pool-test.cc index ea788c4..2c9add7 100644 --- a/be/src/runtime/bufferpool/buffer-pool-test.cc +++ b/be/src/runtime/bufferpool/buffer-pool-test.cc @@ -584,7 +584,9 @@ void BufferPoolTest::TestBufferAllocation(bool reserved) { BufferPool::ClientHandle client; ASSERT_OK(pool.RegisterClient("test client", NULL, &global_reservations_, NULL, TOTAL_MEM, NewProfile(), &client)); - if (reserved) ASSERT_TRUE(client.IncreaseReservationToFit(TOTAL_MEM)); + if (reserved) { + ASSERT_TRUE(client.IncreaseReservationToFit(TOTAL_MEM)); + } vector<BufferPool::BufferHandle> handles(NUM_BUFFERS); @@ -2095,7 +2097,9 @@ void BufferPoolTest::TestRandomInternalImpl(BufferPool* pool, TmpFileGroup* file int rand_pick = uniform_int_distribution<int>(0, pages.size() - 1)(*rng); PageHandle* page = &pages[rand_pick].first; if (!client.IncreaseReservationToFit(page->len())) continue; - if (!page->is_pinned() || multiple_pins) ASSERT_OK(pool->Pin(&client, page)); + if (!page->is_pinned() || multiple_pins) { + ASSERT_OK(pool->Pin(&client, page)); + } // Block on the pin and verify data for sync pins. if (p < 0.35) VerifyData(*page, pages[rand_pick].second); } else if (p < 0.70) { diff --git a/be/src/runtime/io/disk-io-mgr-test.cc b/be/src/runtime/io/disk-io-mgr-test.cc index 2cf4642..f549e19 100644 --- a/be/src/runtime/io/disk-io-mgr-test.cc +++ b/be/src/runtime/io/disk-io-mgr-test.cc @@ -888,7 +888,9 @@ TEST_F(DiskIoMgrTest, MemScarcity) { data_offset += buffer->len(); buffers.emplace_back(move(buffer)); } - if (status.ok()) ASSERT_EQ(DATA_BYTES, data_offset); + if (status.ok()) { + ASSERT_EQ(DATA_BYTES, data_offset); + } for (auto& buffer : buffers) range->ReturnBuffer(move(buffer)); })); // Let the thread start running before starting the next. diff --git a/be/src/runtime/timestamp-test.cc b/be/src/runtime/timestamp-test.cc index c2de827..8539695 100644 --- a/be/src/runtime/timestamp-test.cc +++ b/be/src/runtime/timestamp-test.cc @@ -237,8 +237,9 @@ void TestFromDoubleUnixTime( TimestampValue from_double = TimestampValue::FromSubsecondUnixTime( 1.0 * seconds + 0.001 * millis + nanos / NANOS_PER_SEC, UTCPTR); - if (!expected.HasDate()) EXPECT_FALSE(from_double.HasDate()); - else { + if (!expected.HasDate()) { + EXPECT_FALSE(from_double.HasDate()); + } else { // Conversion to double is lossy so the timestamp can be a bit different. int64_t expected_rounded_to_micros, from_double_rounded_to_micros; EXPECT_TRUE(expected.UtcToUnixTimeMicros(&expected_rounded_to_micros)); @@ -256,8 +257,11 @@ void TestFromDoubleUnixTime( void TestFromSubSecondFunctions(int64_t seconds, int64_t millis, const char* expected) { TimestampValue from_millis = TimestampValue::UtcFromUnixTimeMillis(seconds * 1000 + millis); - if (expected == nullptr) EXPECT_FALSE(from_millis.HasDate()); - else EXPECT_EQ(expected, from_millis.ToString()); + if (expected == nullptr) { + EXPECT_FALSE(from_millis.HasDate()); + } else { + EXPECT_EQ(expected, from_millis.ToString()); + } EXPECT_EQ(from_millis, TimestampValue::UtcFromUnixTimeMicros( seconds * MICROS_PER_SEC + millis * 1000)); diff --git a/be/src/testutil/cpu-util.h b/be/src/testutil/cpu-util.h index a995a8e..885e3ca 100644 --- a/be/src/testutil/cpu-util.h +++ b/be/src/testutil/cpu-util.h @@ -38,7 +38,9 @@ class CpuTestUtil { CPU_SET(core, &cpuset); ASSERT_EQ(0, pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) << core; - if (validate_current_cpu) ASSERT_EQ(core, CpuInfo::GetCurrentCore()); + if (validate_current_cpu) { + ASSERT_EQ(core, CpuInfo::GetCurrentCore()); + } } /// Reset the thread affinity of the current thread to all cores.