This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new bc43852f1 [c++ build] suppress deprecation warnings
bc43852f1 is described below
commit bc43852f158e0a3247022f2c9c889c699876d446
Author: Alexey Serbin <[email protected]>
AuthorDate: Thu Nov 3 20:48:04 2022 -0700
[c++ build] suppress deprecation warnings
With newer version of Xcode (at least starting with version 13.2.1),
building Kudu on macOS produces many warnings because of C++17-related
deprecations, so it's not easy to spot warnings attributed to updates
in the local workspace. This patch addresses the issue, adding pragmas
to disable deprecated declarations where appropriate.
In addition, this patch also silences warnings related to usage of
the deprecated Kudu API in src/kudu/client/schema.cc (it's used just
in the library implementation, so it's not a big deal). I also took the
liberty to replace include guards with 'pragma once' and address
some of clang-tidy's recommendations in a few affected files.
Change-Id: I069a0680b4bc981b311374cc08bb950578db0dd0
Reviewed-on: http://gerrit.cloudera.org:8080/19202
Tested-by: Kudu Jenkins
Reviewed-by: Yifan Zhang <[email protected]>
Reviewed-by: Attila Bukor <[email protected]>
---
src/kudu/client/schema.cc | 18 +++++++++---------
src/kudu/gutil/stl_util.h | 32 ++++++++++++++++----------------
src/kudu/security/gssapi.cc | 11 +++++++++++
src/kudu/util/mem_tracker.h | 8 ++++----
src/kudu/util/memory/arena.h | 5 ++++-
5 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/src/kudu/client/schema.cc b/src/kudu/client/schema.cc
index 203f360e2..1acb290c9 100644
--- a/src/kudu/client/schema.cc
+++ b/src/kudu/client/schema.cc
@@ -228,7 +228,6 @@ uint16_t KuduColumnTypeAttributes::length() const {
Status KuduColumnStorageAttributes::StringToEncodingType(
const string& encoding,
KuduColumnStorageAttributes::EncodingType* type) {
- Status s;
string encoding_uc;
ToUpperCase(encoding, &encoding_uc);
if (encoding_uc == "AUTO_ENCODING") {
@@ -246,16 +245,15 @@ Status KuduColumnStorageAttributes::StringToEncodingType(
} else if (encoding_uc == "GROUP_VARINT") {
*type = KuduColumnStorageAttributes::GROUP_VARINT;
} else {
- s = Status::InvalidArgument(Substitute(
+ return Status::InvalidArgument(Substitute(
"encoding type $0 is not supported", encoding));
}
- return s;
+ return Status::OK();
}
Status KuduColumnStorageAttributes::StringToCompressionType(
const string& compression,
KuduColumnStorageAttributes::CompressionType* type) {
- Status s;
string compression_uc;
ToUpperCase(compression, &compression_uc);
if (compression_uc == "DEFAULT_COMPRESSION") {
@@ -269,10 +267,10 @@ Status
KuduColumnStorageAttributes::StringToCompressionType(
} else if (compression_uc == "ZLIB") {
*type = KuduColumnStorageAttributes::ZLIB;
} else {
- s = Status::InvalidArgument(Substitute(
+ return Status::InvalidArgument(Substitute(
"compression type $0 is not supported", compression));
}
- return s;
+ return Status::OK();
}
////////////////////////////////////////////////////////////
@@ -711,7 +709,6 @@ string KuduColumnSchema::DataTypeToString(DataType type) {
Status KuduColumnSchema::StringToDataType(
const string& type_str, KuduColumnSchema::DataType* type) {
- Status s;
string type_uc;
ToUpperCase(type_str, &type_uc);
if (type_uc == "INT8") {
@@ -741,10 +738,10 @@ string KuduColumnSchema::DataTypeToString(DataType type) {
} else if (type_uc == "DATE") {
*type = DATE;
} else {
- s = Status::InvalidArgument(Substitute(
+ return Status::InvalidArgument(Substitute(
"data type $0 is not supported", type_str));
}
- return s;
+ return Status::OK();
}
KuduColumnSchema::KuduColumnSchema(const string &name,
@@ -843,8 +840,11 @@ KuduColumnStorageAttributes
KuduColumnSchema::storage_attributes() const {
KuduColumnStorageAttributes::StringToCompressionType(
kudu::CompressionType_Name(storage_attributes.compression),
&compression_type);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return KuduColumnStorageAttributes(encoding_type, compression_type,
storage_attributes.cfile_block_size);
+#pragma GCC diagnostic pop
}
const string& KuduColumnSchema::comment() const {
diff --git a/src/kudu/gutil/stl_util.h b/src/kudu/gutil/stl_util.h
index ae9df2930..2eeb6285b 100644
--- a/src/kudu/gutil/stl_util.h
+++ b/src/kudu/gutil/stl_util.h
@@ -25,13 +25,12 @@
// and Google friendly API.
//
-#ifndef UTIL_GTL_STL_UTIL_H_
-#define UTIL_GTL_STL_UTIL_H_
+#pragma once
-#include <stddef.h>
-#include <string.h> // for memcpy
#include <algorithm>
#include <cassert>
+#include <cstddef>
+#include <cstring> // for memcpy
#include <deque>
#include <functional>
#include <iterator>
@@ -309,7 +308,7 @@ inline T* vector_as_array(std::vector<T, Allocator>* v) {
# ifdef NDEBUG
return &*v->begin();
# else
- return v->empty() ? NULL : &*v->begin();
+ return v->empty() ? nullptr : &*v->begin();
# endif
}
@@ -318,7 +317,7 @@ inline const T* vector_as_array(const std::vector<T,
Allocator>* v) {
# ifdef NDEBUG
return &*v->begin();
# else
- return v->empty() ? NULL : &*v->begin();
+ return v->empty() ? nullptr : &*v->begin();
# endif
}
@@ -336,7 +335,7 @@ inline const T* vector_as_array(const std::vector<T,
Allocator>* v) {
// implementations.
inline char* string_as_array(std::string* str) {
// DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
- return str->empty() ? NULL : &*str->begin();
+ return str->empty() ? nullptr : &*str->begin();
}
// These are methods that test two hash maps/sets for equality. These exist
@@ -379,7 +378,7 @@ HashMapEquality(const HashMap& map_a,
// hash_set, or any other STL container which defines sensible begin(), end(),
// and clear() methods.
//
-// If container is NULL, this function is a no-op.
+// If container is nullptr, this function is a no-op.
//
// As an alternative to calling STLDeleteElements() directly, consider
// ElementDeleter (defined below), which ensures that your container's elements
@@ -393,7 +392,7 @@ void STLDeleteElements(T *container) {
// Given an STL container consisting of (key, value) pairs, STLDeleteValues
// deletes all the "value" components and clears the container. Does nothing
-// in the case it's given a NULL pointer.
+// in the case it's given a null pointer.
template <class T>
void STLDeleteValues(T *v) {
if (!v) return;
@@ -829,8 +828,8 @@ class STLCountingAllocator : public Alloc {
typedef typename Alloc::pointer pointer;
typedef typename Alloc::size_type size_type;
- STLCountingAllocator() : bytes_used_(NULL) { }
- STLCountingAllocator(int64* b) : bytes_used_(b) {} // TODO(user): explicit?
+ STLCountingAllocator() : bytes_used_(nullptr) { }
+ explicit STLCountingAllocator(int64* b) : bytes_used_(b) {}
// Constructor used for rebinding
template <class U>
@@ -839,15 +838,18 @@ class STLCountingAllocator : public Alloc {
bytes_used_(x.bytes_used()) {
}
- pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0) {
- assert(bytes_used_ != NULL);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ pointer allocate(size_type n, std::allocator<void>::const_pointer hint =
nullptr) {
+ assert(bytes_used_ != nullptr);
*bytes_used_ += n * sizeof(T);
return Alloc::allocate(n, hint);
}
+#pragma GCC diagnostic pop
void deallocate(pointer p, size_type n) {
Alloc::deallocate(p, n);
- assert(bytes_used_ != NULL);
+ assert(bytes_used_ != nullptr);
*bytes_used_ -= n * sizeof(T);
}
@@ -933,5 +935,3 @@ bool SortedRangesHaveIntersection(InputIterator1 begin1,
InputIterator1 end1,
}
return false;
}
-
-#endif // UTIL_GTL_STL_UTIL_H_
diff --git a/src/kudu/security/gssapi.cc b/src/kudu/security/gssapi.cc
index 6797ec3fa..116b8f969 100644
--- a/src/kudu/security/gssapi.cc
+++ b/src/kudu/security/gssapi.cc
@@ -29,6 +29,13 @@
using std::string;
+#if defined(__APPLE__)
+// Almost all functions in the krb5 API are marked as deprecated in favor
+// of GSS.framework in macOS.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif // #if defined(__APPLE__)
+
namespace kudu {
namespace gssapi {
@@ -162,3 +169,7 @@ Status SpnegoStep(const string& in_token_b64,
} // namespace gssapi
} // namespace kudu
+
+#if defined(__APPLE__)
+#pragma GCC diagnostic pop
+#endif // #if defined(__APPLE__)
diff --git a/src/kudu/util/mem_tracker.h b/src/kudu/util/mem_tracker.h
index fc83363c8..fca754001 100644
--- a/src/kudu/util/mem_tracker.h
+++ b/src/kudu/util/mem_tracker.h
@@ -14,8 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-#ifndef KUDU_UTIL_MEM_TRACKER_H
-#define KUDU_UTIL_MEM_TRACKER_H
+#pragma once
#include <cstdint>
#include <list>
@@ -223,6 +222,8 @@ class MemTrackerAllocator : public Alloc {
~MemTrackerAllocator() {
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
pointer allocate(size_type n, const_pointer hint = 0) {
// Ideally we'd use TryConsume() here to enforce the tracker's limit.
// However, that means throwing bad_alloc if the limit is exceeded, and
@@ -241,6 +242,7 @@ class MemTrackerAllocator : public Alloc {
struct rebind {
typedef MemTrackerAllocator<U, typename Alloc::template rebind<U>::other>
other;
};
+#pragma GCC diagnostic pop
const std::shared_ptr<MemTracker>& mem_tracker() const { return
mem_tracker_; }
@@ -277,5 +279,3 @@ class ScopedTrackedConsumption {
};
} // namespace kudu
-
-#endif // KUDU_UTIL_MEM_TRACKER_H
diff --git a/src/kudu/util/memory/arena.h b/src/kudu/util/memory/arena.h
index 6eaa477e5..aec712ef0 100644
--- a/src/kudu/util/memory/arena.h
+++ b/src/kudu/util/memory/arena.h
@@ -251,9 +251,12 @@ template<class T, bool THREADSAFE> class ArenaAllocator {
~ArenaAllocator() { }
- pointer allocate(size_type n, std::allocator<void>::const_pointer /*hint*/ =
0) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ pointer allocate(size_type n, std::allocator<void>::const_pointer /*hint*/ =
nullptr) {
return reinterpret_cast<T*>(arena_->AllocateBytes(n * sizeof(T)));
}
+#pragma GCC diagnostic pop
void deallocate(pointer p, size_type n) {}