Skip to content

Commit

Permalink
[#9279] YSQL: Enable -Wextra on yql folder
Browse files Browse the repository at this point in the history
Summary:
As a part of enabling -Wextra on entire code base this diff enables flags on yql directory.

All new warnings are fixed in context of this diff. Compilation was tested on GCC9.

Test Plan: Jenkins

Reviewers: sergei, timur, alex

Reviewed By: alex

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D12786
  • Loading branch information
d-uspenskiy committed Sep 8, 2021
1 parent 42bb2f2 commit 4fe7733
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,7 @@ set(YB_TEST_LINK_LIBS ${YB_MIN_TEST_LIBS})

# TODO(dmitry): Add YB_CMAKE_CXX_EXTRA_FLAGS to CMAKE_CXX_FLAGS when all source code will be
# compatible with with these flags #9279
# Note: YB_CMAKE_CXX_EXTRA_FLAGS almost equals to flags in ./src/yb/rocksdb/CMakeLists.txt
# Exceptions are:
# * No -Wsign-compare because for now YB uses -Wno-sign-compare explicitly
# * No -Wno-unused-variable and -Wno-missing-field-initializers because there are no
# such warnings in the YB code
set(YB_CMAKE_CXX_EXTRA_FLAGS "-Wextra -Wshadow -Woverloaded-virtual -Wno-unused-parameter")
set(YB_CMAKE_CXX_EXTRA_FLAGS "-Wextra -Wno-unused-parameter")

# For any C code, use the same flags as for C++.
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
Expand Down
7 changes: 7 additions & 0 deletions src/yb/util/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class Decimal {
bool is_positive = true)
: digits_(digits), exponent_(exponent), is_positive_(is_positive) { make_canonical(); }
Decimal(const Decimal& other) : Decimal(other.digits_, other.exponent_, other.is_positive_) {}
Decimal& operator=(const Decimal& other) {
digits_ = other.digits_;
exponent_ = other.exponent_;
is_positive_ = other.is_positive_;
make_canonical();
return *this;
}

// Ensure the type conversion is possible if you use these constructors. Use FromX() otherwise.
explicit Decimal(const std::string& string_val) { CHECK_OK(FromString(string_val)); }
Expand Down
3 changes: 3 additions & 0 deletions src/yb/yql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# under the License.
#

# TODO(dmitry): Remove next line after fixing #9279
set(CMAKE_CXX_FLAGS "${YB_CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS}")

# CQL service
add_subdirectory(cql/ql)
add_subdirectory(cql/cqlserver)
Expand Down
2 changes: 1 addition & 1 deletion src/yb/yql/cql/ql/audit/audit_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Result<LogEntry> AuditLogger::CreateLogEntry(const Type& type,
.operation = std::move(operation),
.error_message = std::move(error_message)
};
return std::move(entry);
return entry;
}

Status AuditLogger::StartBatchRequest(int statements_count,
Expand Down
4 changes: 2 additions & 2 deletions src/yb/yql/cql/ql/ptree/pt_grant_revoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class PTGrantRevokePermission : public TreeNode {
return role_name_;
}

const ResourceType resource_type() const {
ResourceType resource_type() const {
return resource_type_;
}

Expand All @@ -157,7 +157,7 @@ class PTGrantRevokePermission : public TreeNode {
return nullptr;
}

const PermissionType permission() const {
PermissionType permission() const {
return permission_;
}

Expand Down
2 changes: 1 addition & 1 deletion src/yb/yql/cql/ql/util/statement_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class StatementParameters {
return STATUS(RuntimeError, "no bind variable available");
}

const YBConsistencyLevel yb_consistency_level() const {
YBConsistencyLevel yb_consistency_level() const {
return yb_consistency_level_;
}

Expand Down
8 changes: 4 additions & 4 deletions src/yb/yql/cql/ql/util/statement_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ExecutedResult {
SCHEMA_CHANGE = 3
};

virtual const Type type() const = 0;
virtual Type type() const = 0;
};

// Callback to be called after a statement is executed. When execution fails, a not-ok status is
Expand All @@ -103,7 +103,7 @@ class SetKeyspaceResult : public ExecutedResult {
virtual ~SetKeyspaceResult() override { };

// Result type.
virtual const Type type() const override { return Type::SET_KEYSPACE; }
Type type() const override { return Type::SET_KEYSPACE; }

// Accessor function for keyspace.
const std::string& keyspace() const { return keyspace_; }
Expand All @@ -129,7 +129,7 @@ class RowsResult : public ExecutedResult {
virtual ~RowsResult() override;

// Result type.
virtual const Type type() const override { return Type::ROWS; }
Type type() const override { return Type::ROWS; }

// Accessor functions.
const client::YBTableName& table_name() const { return table_name_; }
Expand Down Expand Up @@ -178,7 +178,7 @@ class SchemaChangeResult : public ExecutedResult {
virtual ~SchemaChangeResult() override;

// Result type.
virtual const Type type() const override { return Type::SCHEMA_CHANGE; }
Type type() const override { return Type::SCHEMA_CHANGE; }

// Accessor functions.
const std::string& change_type() const { return change_type_; }
Expand Down
3 changes: 0 additions & 3 deletions src/yb/yql/pggate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
# We need access to the generated pg_type_d.h header from this directory.
include_directories("${YB_BUILD_ROOT}/postgres_build/src/include")

# TODO(dmitry): Remove next line after fixing #9279
set(CMAKE_CXX_FLAGS "${YB_CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS}")

# Utility functions that are specific for PGGate.
add_subdirectory(util)

Expand Down
3 changes: 0 additions & 3 deletions src/yb/yql/pgwrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# under the License.
#

# TODO(dmitry): Remove next line after fixing #9279
set(CMAKE_CXX_FLAGS "${YB_CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS}")

set(PGWRAPPER_SRCS
pg_wrapper.cc)
set(PGWRAPPER_LIBS
Expand Down

0 comments on commit 4fe7733

Please sign in to comment.