Skip to content

Commit 03590d0

Browse files
timarmstrongcloudera-hudson
authored andcommitted
Fix some warnings on GCC7
I tried compiling with GCC7 to see what warnings popped up. Fix some ambiguous else warnings resulting from gtest macros. See google/googletest#1119. Add a missing include that broke compilation on the release build. Fix some warnings that detect missing returns when there is a DCHECK (these warnings already occurred in release builds, but they now happen in gcc7 debug builds). Change-Id: I39a12bc5ed6957c147b7f0dba85c7687cc989439 Reviewed-on: http://gerrit.cloudera.org:8080/12132 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]>
1 parent 60dbb16 commit 03590d0

13 files changed

+38
-17
lines changed

be/src/exec/delimited-text-parser-test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ void Validate(TupleDelimitedTextParser* parser, const string& data,
4242
} else {
4343
EXPECT_TRUE(data[offset - 1] == '\n' || data[offset - 1] == '\r')
4444
<< data[offset - 1] << endl << data;
45-
if (data[offset - 1] == '\r' && offset < data.size()) EXPECT_NE(data[offset], '\n');
45+
if (data[offset - 1] == '\r' && offset < data.size()) {
46+
EXPECT_NE(data[offset], '\n');
47+
}
4648
}
4749

4850
data_ptr += offset;

be/src/exec/hash-table-test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ class HashTableTest : public testing::Test {
170170
int32_t val = *reinterpret_cast<int32_t*>(build_expr_evals_[0]->GetValue(row));
171171
EXPECT_GE(val, min);
172172
EXPECT_LT(val, max);
173-
if (all_unique) EXPECT_TRUE(results[val] == nullptr);
173+
if (all_unique) {
174+
EXPECT_TRUE(results[val] == nullptr);
175+
}
174176
EXPECT_EQ(row->GetTuple(0), expected[val]->GetTuple(0));
175177
results[val] = row;
176178
iter.Next();

be/src/exprs/decimal-operators-ir.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ IR_ALWAYS_INLINE DecimalVal DecimalOperators::CastToDecimalVal(
582582
return DecimalVal::null();
583583
}
584584

585-
DCHECK(result == StringParser::PARSE_SUCCESS || StringParser::PARSE_UNDERFLOW);
585+
DCHECK(result == StringParser::PARSE_SUCCESS
586+
|| result == StringParser::PARSE_UNDERFLOW);
586587
return dv;
587588
}
588589

be/src/exprs/string-functions-ir.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "exprs/string-functions.h"
1919

2020
#include <cctype>
21+
#include <numeric>
2122
#include <stdint.h>
2223
#include <re2/re2.h>
2324
#include <re2/stringpiece.h>

be/src/exprs/timezone_db.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <regex>
2525
#include <boost/algorithm/string.hpp>
2626

27+
#include "common/compiler-util.h"
2728
#include "common/logging.h"
2829
#include "kudu/util/path_util.h"
2930
#include "gutil/strings/ascii_ctype.h"
@@ -214,7 +215,7 @@ Status TimezoneDatabase::LoadZoneInfoFromHdfs(const string& hdfs_zone_info_zip,
214215
Status status = CopyHdfsFile(hdfs_conn, hdfs_zone_info_zip, local_conn,
215216
local_path.data());
216217
if (!status.ok()) {
217-
(void)FileSystemUtil::RemovePaths({local_path.data()});
218+
discard_result(FileSystemUtil::RemovePaths({local_path.data()}));
218219
return status;
219220
}
220221

be/src/runtime/bufferpool/reservation-tracker-test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ TEST_F(ReservationTrackerTest, MemTrackerIntegrationMultiLevel) {
412412
ASSERT_TRUE(reservations[level].IncreaseReservation(amount));
413413
ASSERT_EQ(amount, reservations[level].GetReservation());
414414
ASSERT_EQ(0, reservations[level].GetUsedReservation());
415-
if (level != 0) ASSERT_EQ(amount, mem_trackers[level]->consumption());
415+
if (level != 0) {
416+
ASSERT_EQ(amount, mem_trackers[level]->consumption());
417+
}
416418
for (int ancestor = 0; ancestor < level; ++ancestor) {
417419
ASSERT_EQ(0, reservations[ancestor].GetUsedReservation());
418420
ASSERT_EQ(amount, reservations[ancestor].GetChildReservations());

be/src/runtime/fragment-instance-state.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void FragmentInstanceState::PublishFilter(const TPublishFilterParams& params) {
469469
runtime_state_->filter_bank()->PublishGlobalFilter(params);
470470
}
471471

472-
string FragmentInstanceState::ExecStateToString(FInstanceExecStatePB state) {
472+
const string& FragmentInstanceState::ExecStateToString(FInstanceExecStatePB state) {
473473
// Labels to send to the debug webpages to display the current state to the user.
474474
static const string finstance_state_labels[] = {
475475
"Waiting for Exec", // WAITING_FOR_EXEC
@@ -483,10 +483,10 @@ string FragmentInstanceState::ExecStateToString(FInstanceExecStatePB state) {
483483
"Finished" // FINISHED
484484
};
485485
/// Make sure we have a label for every possible state.
486-
static_assert(sizeof(finstance_state_labels) / sizeof(char*) ==
486+
static_assert(sizeof(finstance_state_labels) / sizeof(string) ==
487487
FInstanceExecStatePB::FINISHED + 1, "");
488488

489-
DCHECK_LT(state, sizeof(finstance_state_labels) / sizeof(char*))
489+
DCHECK_LT(state, sizeof(finstance_state_labels) / sizeof(string))
490490
<< "Unknown instance state";
491491
return finstance_state_labels[state];
492492
}

be/src/runtime/fragment-instance-state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class FragmentInstanceState {
101101
PlanRootSink* root_sink() { return root_sink_; }
102102

103103
/// Returns a string description of 'state'.
104-
static string ExecStateToString(FInstanceExecStatePB state);
104+
static const string& ExecStateToString(FInstanceExecStatePB state);
105105

106106
/// Name of the counter that is tracking per query, per host peak mem usage.
107107
/// TODO: this doesn't look like it belongs here

be/src/service/impala-server.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,8 +1452,9 @@ Status ImpalaServer::AuthorizeProxyUser(const string& user, const string& do_as_
14521452
if (authorized_proxy_user_config_.size() == 0 &&
14531453
authorized_proxy_group_config_.size() == 0) {
14541454
error_msg << " User/group delegation is disabled.";
1455-
VLOG(1) << error_msg;
1456-
return Status::Expected(error_msg.str());
1455+
string error_msg_str = error_msg.str();
1456+
VLOG(1) << error_msg_str;
1457+
return Status::Expected(error_msg_str);
14571458
}
14581459

14591460
// Get the short version of the user name (the user name up to the first '/' or '@')
@@ -1505,8 +1506,9 @@ Status ImpalaServer::AuthorizeProxyUser(const string& user, const string& do_as_
15051506
}
15061507
}
15071508

1508-
VLOG(1) << error_msg;
1509-
return Status::Expected(error_msg.str());
1509+
string error_msg_str = error_msg.str();
1510+
VLOG(1) << error_msg_str;
1511+
return Status::Expected(error_msg_str);
15101512
}
15111513

15121514
void ImpalaServer::CatalogUpdateVersionInfo::UpdateCatalogVersionMetrics()

be/src/statestore/statestore.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ const char* Statestore::GetUpdateKindName(UpdateKind kind) {
832832
return "heartbeat";
833833
}
834834
DCHECK(false);
835+
return "";
835836
}
836837

837838
ThreadPool<Statestore::ScheduledSubscriberUpdate>* Statestore::GetThreadPool(
@@ -845,6 +846,7 @@ ThreadPool<Statestore::ScheduledSubscriberUpdate>* Statestore::GetThreadPool(
845846
return &subscriber_heartbeat_threadpool_;
846847
}
847848
DCHECK(false);
849+
return nullptr;
848850
}
849851

850852
Status Statestore::SendHeartbeat(Subscriber* subscriber) {

be/src/util/decompress-test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ class DecompressorTest : public ::testing::Test {
229229

230230
EXPECT_EQ(0, compressed_bytes_remaining);
231231
EXPECT_EQ(stream_end, expected_stream_end);
232-
if (stream_end) EXPECT_EQ(decompressed_len, uncompressed_len);
232+
if (stream_end) {
233+
EXPECT_EQ(decompressed_len, uncompressed_len);
234+
}
233235
if (bytes_decompressed != NULL) *bytes_decompressed = decompressed_len;
234236

235237
return Status::OK();

be/src/util/metrics-test.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,12 @@ void AssertJson(const Value& val, const string& name, const string& value,
267267
EXPECT_EQ(val["name"].GetString(), name);
268268
EXPECT_EQ(val["human_readable"].GetString(), value);
269269
EXPECT_EQ(val["description"].GetString(), description);
270-
if (!kind.empty()) EXPECT_EQ(val["kind"].GetString(), kind);
271-
if (!units.empty()) EXPECT_EQ(val["units"].GetString(), units);
270+
if (!kind.empty()) {
271+
EXPECT_EQ(val["kind"].GetString(), kind);
272+
}
273+
if (!units.empty()) {
274+
EXPECT_EQ(val["units"].GetString(), units);
275+
}
272276
}
273277

274278
TEST_F(MetricsTest, CountersJson) {

be/src/util/webserver.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,9 @@ const string Webserver::GetMimeType(const ContentType& content_type) {
505505
case HTML: return "text/html; charset=UTF-8";
506506
case PLAIN: return "text/plain; charset=UTF-8";
507507
case JSON: return "application/json";
508-
default: DCHECK(false) << "Invalid content_type: " << content_type;
508+
default:
509+
DCHECK(false) << "Invalid content_type: " << content_type;
510+
return "";
509511
}
510512
}
511513
}

0 commit comments

Comments
 (0)