From af6064aab9fdd1b28cbd4e0b023a5e88da715570 Mon Sep 17 00:00:00 2001 From: William Ayd Date: Thu, 18 Apr 2024 13:39:16 -0400 Subject: [PATCH] GH-41112: [C++] Clean up unused parameter warnings (#41111) Noticed these when compiling the nanoarrow test suite with -Wextra * GitHub Issue: #41112 ### Rationale for this change Helps clean up build warnings when compiling with -Wextra ### What changes are included in this PR? Used Arrow macros to mark some parameters as unused ### Are these changes tested? N/A - just ensured program compiles cleanly ### Are there any user-facing changes? No Authored-by: Will Ayd Signed-off-by: Felipe Oliveira Carvalho --- cpp/src/arrow/array/builder_base.h | 5 +++-- cpp/src/arrow/array/builder_nested.h | 2 +- cpp/src/arrow/array/builder_primitive.h | 5 +++-- cpp/src/arrow/device.h | 8 +++++--- cpp/src/arrow/type.h | 12 +++++++++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cpp/src/arrow/array/builder_base.h b/cpp/src/arrow/array/builder_base.h index 11036797e014f..e6c0b2d2387f2 100644 --- a/cpp/src/arrow/array/builder_base.h +++ b/cpp/src/arrow/array/builder_base.h @@ -175,8 +175,9 @@ class ARROW_EXPORT ArrayBuilder { /// \brief Append a range of values from an array. /// /// The given array must be the same type as the builder. - virtual Status AppendArraySlice(const ArraySpan& array, int64_t offset, - int64_t length) { + virtual Status AppendArraySlice([[maybe_unused]] const ArraySpan& array, + [[maybe_unused]] int64_t offset, + [[maybe_unused]] int64_t length) { return Status::NotImplemented("AppendArraySlice for builder for ", *type()); } diff --git a/cpp/src/arrow/array/builder_nested.h b/cpp/src/arrow/array/builder_nested.h index 429aa5c0488cd..2c8c41c365f6a 100644 --- a/cpp/src/arrow/array/builder_nested.h +++ b/cpp/src/arrow/array/builder_nested.h @@ -250,7 +250,7 @@ class ARROW_EXPORT VarLengthListLikeBuilder : public ArrayBuilder { /// \brief Append dimensions for a single list slot. /// /// ListViewBuilder overrides this to also append the size. - virtual void UnsafeAppendDimensions(int64_t offset, int64_t size) { + virtual void UnsafeAppendDimensions(int64_t offset, [[maybe_unused]] int64_t size) { offsets_builder_.UnsafeAppend(static_cast(offset)); } diff --git a/cpp/src/arrow/array/builder_primitive.h b/cpp/src/arrow/array/builder_primitive.h index 29e01d55edeb1..db8d2cbaabb61 100644 --- a/cpp/src/arrow/array/builder_primitive.h +++ b/cpp/src/arrow/array/builder_primitive.h @@ -32,9 +32,10 @@ namespace arrow { class ARROW_EXPORT NullBuilder : public ArrayBuilder { public: explicit NullBuilder(MemoryPool* pool = default_memory_pool(), - int64_t alignment = kDefaultBufferAlignment) + [[maybe_unused]] int64_t alignment = kDefaultBufferAlignment) : ArrayBuilder(pool) {} - explicit NullBuilder(const std::shared_ptr& type, + + explicit NullBuilder([[maybe_unused]] const std::shared_ptr& type, MemoryPool* pool = default_memory_pool(), int64_t alignment = kDefaultBufferAlignment) : NullBuilder(pool, alignment) {} diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index 622551c6bd040..3003bad7c459c 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -139,7 +139,8 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// This should create the appropriate stream type for the device, /// derived from Device::Stream to allow for stream ordered events /// and memory allocations. - virtual Result> MakeStream(unsigned int flags) { + virtual Result> MakeStream( + [[maybe_unused]] unsigned int flags) { return NULLPTR; } @@ -149,8 +150,9 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// @param release_fn a function to call during destruction, `nullptr` or /// a no-op function can be passed to indicate ownership is maintained /// externally - virtual Result> WrapStream(void* device_stream, - Stream::release_fn_t release_fn) { + virtual Result> WrapStream( + [[maybe_unused]] void* device_stream, + [[maybe_unused]] Stream::release_fn_t release_fn) { return NULLPTR; } diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h index 3f651741d3e49..5629cade42335 100644 --- a/cpp/src/arrow/type.h +++ b/cpp/src/arrow/type.h @@ -1723,7 +1723,9 @@ class ARROW_EXPORT MonthIntervalType : public IntervalType { MonthIntervalType() : IntervalType(type_id) {} - std::string ToString(bool show_metadata = false) const override { return name(); } + std::string ToString([[maybe_unused]] bool show_metadata = false) const override { + return name(); + } std::string name() const override { return "month_interval"; } }; @@ -1759,7 +1761,9 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType { int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - std::string ToString(bool show_metadata = false) const override { return name(); } + std::string ToString([[maybe_unused]] bool show_metadata = false) const override { + return name(); + } std::string name() const override { return "day_time_interval"; } }; @@ -1799,7 +1803,9 @@ class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType { int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - std::string ToString(bool show_metadata = false) const override { return name(); } + std::string ToString([[maybe_unused]] bool show_metadata = false) const override { + return name(); + } std::string name() const override { return "month_day_nano_interval"; } };