From 947b9bc4e047a2aea7617fd6bdf90fa24c27b564 Mon Sep 17 00:00:00 2001 From: Eric Hughes Date: Wed, 20 Sep 2023 11:26:01 -0600 Subject: [PATCH] Remove extraneous casts to void. This PR removes a number of extraneous casts to void, though not all in the same way. It does not have a goal of removing all of extraneous casts. The most frequent by far is to prevent unused variable warnings for function arguments that are not actually used. In this case changing to an anonymous argument solves the problem. It also indicates quite clearly that an argument isn't used. In some cases checks for the validity of unused arguments were also removed. In some cases a variable declaration (argument or otherwise) were annotated with `[[maybe_unused]]`. This was most often the case where the code varies with preprocessor definitions. In a few cases some argument checks were promoted from `assert` to throwing exceptions when invalid. A handful of ignored return values were replaced with `std::ignore`. --- tiledb/sm/array_schema/dimension.cc | 24 +++---- tiledb/sm/array_schema/domain.cc | 12 +--- tiledb/sm/c_api/tiledb.cc | 63 +++++-------------- tiledb/sm/c_api/tiledb_filestore.cc | 8 +-- tiledb/sm/compressors/dd_compressor.cc | 3 +- tiledb/sm/compressors/lz4_compressor.cc | 5 +- tiledb/sm/compressors/test/link_webp_test1.cc | 4 +- .../fragment_meta_consolidator.cc | 3 +- .../consolidator/group_meta_consolidator.cc | 8 +-- tiledb/sm/cpp_api/vfs.h | 3 +- tiledb/sm/filesystem/mem_filesystem.cc | 27 ++------ tiledb/sm/filesystem/posix.cc | 9 +-- tiledb/sm/filesystem/vfs.cc | 31 ++------- tiledb/sm/filter/bitshuffle_filter.cc | 3 +- tiledb/sm/filter/byteshuffle_filter.cc | 4 +- tiledb/sm/filter/compression_filter.cc | 4 +- .../sm/filter/encryption_aes256gcm_filter.cc | 3 +- tiledb/sm/filter/filter.cc | 14 ++--- tiledb/sm/filter/float_scaling_filter.cc | 3 +- tiledb/sm/filter/noop_filter.cc | 4 +- tiledb/sm/filter/xor_filter.cc | 4 +- tiledb/sm/fragment/fragment_metadata.cc | 6 +- tiledb/sm/global_state/signal_handlers.cc | 8 +-- tiledb/sm/group/group.h | 7 +++ tiledb/sm/group/group_details_v2.cc | 8 ++- tiledb/sm/group/group_directory.cc | 4 -- tiledb/sm/group/group_directory.h | 2 +- tiledb/sm/misc/utils.h | 7 +-- tiledb/sm/query/readers/result_tile.cc | 10 +-- tiledb/sm/query/test/unit_query_condition.cc | 4 +- tiledb/sm/rest/rest_client.cc | 3 +- tiledb/sm/rtree/rtree.cc | 6 +- tiledb/sm/serialization/config.cc | 4 +- tiledb/sm/serialization/query.cc | 6 +- 34 files changed, 87 insertions(+), 227 deletions(-) diff --git a/tiledb/sm/array_schema/dimension.cc b/tiledb/sm/array_schema/dimension.cc index 55d5ae39b0ea..8b86ff64b914 100644 --- a/tiledb/sm/array_schema/dimension.cc +++ b/tiledb/sm/array_schema/dimension.cc @@ -1080,10 +1080,7 @@ void Dimension::splitting_value( } template <> -uint64_t Dimension::tile_num(const Dimension* dim, const Range& range) { - (void)dim; - (void)range; - +uint64_t Dimension::tile_num(const Dimension*, const Range&) { return 1; } @@ -1171,10 +1168,9 @@ ByteVecValue Dimension::map_from_uint64( template ByteVecValue Dimension::map_from_uint64( - const Dimension* dim, uint64_t value, int bits, uint64_t max_bucket_val) { + const Dimension* dim, uint64_t value, int, uint64_t max_bucket_val) { assert(dim != nullptr); assert(!dim->domain().empty()); - (void)bits; // Not needed here ByteVecValue ret(sizeof(T)); @@ -1205,11 +1201,7 @@ ByteVecValue Dimension::map_from_uint64( template <> ByteVecValue Dimension::map_from_uint64( - const Dimension* dim, uint64_t value, int bits, uint64_t max_bucket_val) { - assert(dim != nullptr); - (void)dim; - (void)max_bucket_val; // Not needed here - + const Dimension*, uint64_t value, int bits, uint64_t) { std::vector ret(sizeof(uint64_t)); // 8 bytes uint64_t ret_uint64 = (value << (64 - bits)); @@ -1250,10 +1242,12 @@ bool Dimension::smaller_than( template <> bool Dimension::smaller_than( - const Dimension* dim, const ByteVecValue& value, const Range& range) { - assert(dim != nullptr); - assert(value); - (void)dim; + const Dimension*, const ByteVecValue& value, const Range& range) { + // verify precondition for `rvalue_as` + if (!value) { + throw DimensionException( + "smaller_than: operand `value` may not be empty"); + } auto value_str = value.rvalue_as(); auto range_start_str = range.start_str(); diff --git a/tiledb/sm/array_schema/domain.cc b/tiledb/sm/array_schema/domain.cc index c48cbe9da172..df2ff008f2bc 100644 --- a/tiledb/sm/array_schema/domain.cc +++ b/tiledb/sm/array_schema/domain.cc @@ -201,11 +201,7 @@ uint64_t Domain::cell_num_per_tile() const { template <> int Domain::cell_order_cmp_impl( - const Dimension* dim, const UntypedDatumView a, const UntypedDatumView b) { - // Must be var-sized - assert(dim->var_size()); - (void)dim; - + const Dimension*, const UntypedDatumView a, const UntypedDatumView b) { auto var_a{a.value_as()}; auto var_b{b.value_as()}; auto size_a{a.size()}; @@ -230,10 +226,7 @@ int Domain::cell_order_cmp_impl( template int Domain::cell_order_cmp_impl( - const Dimension* dim, const UntypedDatumView a, const UntypedDatumView b) { - assert(!dim->var_size()); - (void)dim; - + const Dimension*, const UntypedDatumView a, const UntypedDatumView b) { auto ca = a.template value_as(); auto cb = b.template value_as(); if (ca < cb) @@ -441,7 +434,6 @@ void Domain::get_end_of_cell_slab( } else { for (unsigned d = 0; d < dim_num_; ++d) end[d] = start[d]; - (void)subarray; } } diff --git a/tiledb/sm/c_api/tiledb.cc b/tiledb/sm/c_api/tiledb.cc index 9b7b05011218..90d1acb9ad4a 100644 --- a/tiledb/sm/c_api/tiledb.cc +++ b/tiledb/sm/c_api/tiledb.cc @@ -3416,11 +3416,8 @@ int32_t tiledb_deserialize_array( tiledb_ctx_t* ctx, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_array_t** array) { - // Currently unused: - (void)client_side; - // Sanity check if (sanity_check(ctx) == TILEDB_ERR) return TILEDB_ERR; @@ -3509,15 +3506,8 @@ int32_t tiledb_deserialize_array_schema( tiledb_ctx_t* ctx, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_array_schema_t** array_schema) { - // Currently unused: - (void)client_side; - - // Sanity check - if (sanity_check(ctx) == TILEDB_ERR) - return TILEDB_ERR; - api::ensure_buffer_is_valid(buffer); // Create array schema struct @@ -3547,11 +3537,10 @@ int32_t tiledb_serialize_array_open( tiledb_ctx_t* ctx, const tiledb_array_t* array, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_buffer_t** buffer) { // Currently no different behaviour is required if array open is serialized by // the client or the Cloud server, so the variable is unused - (void)client_side; // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, array) == TILEDB_ERR) { @@ -3579,11 +3568,10 @@ int32_t tiledb_deserialize_array_open( tiledb_ctx_t* ctx, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_array_t** array) { // Currently no different behaviour is required if array open is deserialized - // by the client or the Cloud server, so the variable is unused - (void)client_side; + // by the client or the Cloud server // Sanity check if (sanity_check(ctx) == TILEDB_ERR) { @@ -3674,11 +3662,8 @@ int32_t tiledb_deserialize_array_schema_evolution( tiledb_ctx_t* ctx, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_array_schema_evolution_t** array_schema_evolution) { - // Currently unused: - (void)client_side; - // Sanity check if (sanity_check(ctx) == TILEDB_ERR) return TILEDB_ERR; @@ -3857,11 +3842,8 @@ int32_t tiledb_serialize_array_nonempty_domain( const void* nonempty_domain, int32_t is_empty, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_buffer_t** buffer) { - // Currently unused: - (void)client_side; - // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, array) == TILEDB_ERR) return TILEDB_ERR; @@ -3890,12 +3872,9 @@ int32_t tiledb_deserialize_array_nonempty_domain( const tiledb_array_t* array, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, void* nonempty_domain, int32_t* is_empty) { - // Currently unused: - (void)client_side; - // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, array) == TILEDB_ERR) return TILEDB_ERR; @@ -3919,11 +3898,8 @@ int32_t tiledb_serialize_array_non_empty_domain_all_dimensions( tiledb_ctx_t* ctx, const tiledb_array_t* array, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_buffer_t** buffer) { - // Currently unused: - (void)client_side; - // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, array) == TILEDB_ERR) return TILEDB_ERR; @@ -3950,10 +3926,7 @@ int32_t tiledb_deserialize_array_non_empty_domain_all_dimensions( tiledb_array_t* array, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side) { - // Currently unused: - (void)client_side; - + int32_t) { // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, array) == TILEDB_ERR) return TILEDB_ERR; @@ -4162,11 +4135,11 @@ int32_t tiledb_serialize_fragment_info_request( tiledb_ctx_t* ctx, const tiledb_fragment_info_t* fragment_info, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_buffer_t** buffer) { // Currently no different behaviour is required if fragment info request is - // serialized by the client or the Cloud server, so the variable is unused - (void)client_side; + // serialized by the client or the Cloud server + // Sanity check if (sanity_check(ctx) == TILEDB_ERR || sanity_check(ctx, fragment_info) == TILEDB_ERR) { @@ -4194,11 +4167,10 @@ int32_t tiledb_deserialize_fragment_info_request( tiledb_ctx_t* ctx, const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, - int32_t client_side, + int32_t, tiledb_fragment_info_t* fragment_info) { // Currently no different behaviour is required if fragment info request is - // serialized by the client or the Cloud server, so the variable is unused - (void)client_side; + // serialized by the client or the Cloud server // Sanity check if (sanity_check(ctx) == TILEDB_ERR || @@ -4256,11 +4228,10 @@ int32_t tiledb_deserialize_fragment_info( const tiledb_buffer_t* buffer, tiledb_serialization_type_t serialize_type, const char* array_uri, - int32_t client_side, + int32_t, tiledb_fragment_info_t* fragment_info) { // Currently no different behaviour is required if fragment info is - // deserialized by the client or the Cloud server, so the variable is unused - (void)client_side; + // deserialized by the client or the Cloud server // Sanity check if (sanity_check(ctx) == TILEDB_ERR || diff --git a/tiledb/sm/c_api/tiledb_filestore.cc b/tiledb/sm/c_api/tiledb_filestore.cc index c62119af1b9b..368eb2b839b4 100644 --- a/tiledb/sm/c_api/tiledb_filestore.cc +++ b/tiledb/sm/c_api/tiledb_filestore.cc @@ -159,9 +159,7 @@ int32_t tiledb_filestore_uri_import( tiledb_ctx_t* ctx, const char* filestore_array_uri, const char* file_uri, - tiledb_mime_type_t mime_type) { - (void)mime_type; // Unused - + tiledb_mime_type_t) { if (sanity_check(ctx) == TILEDB_ERR || !filestore_array_uri || !file_uri) { return TILEDB_ERR; } @@ -435,9 +433,7 @@ int32_t tiledb_filestore_buffer_import( const char* filestore_array_uri, void* buf, size_t size, - tiledb_mime_type_t mime_type) { - (void)mime_type; // Unused - + tiledb_mime_type_t) { if (sanity_check(ctx) == TILEDB_ERR || !filestore_array_uri || !buf) { return TILEDB_ERR; } diff --git a/tiledb/sm/compressors/dd_compressor.cc b/tiledb/sm/compressors/dd_compressor.cc index 03a2d47ef17f..92c31029a169 100644 --- a/tiledb/sm/compressors/dd_compressor.cc +++ b/tiledb/sm/compressors/dd_compressor.cc @@ -188,9 +188,8 @@ Status DoubleDelta::decompress( "Cannot decompress tile with DoubleDelta; Not supported datatype")); } -uint64_t DoubleDelta::overhead(uint64_t nbytes) { +uint64_t DoubleDelta::overhead(uint64_t) { // DoubleDelta has a fixed size overhead - (void)nbytes; return DoubleDelta::OVERHEAD; } diff --git a/tiledb/sm/compressors/lz4_compressor.cc b/tiledb/sm/compressors/lz4_compressor.cc index 0533188a1f6f..361d812c172d 100644 --- a/tiledb/sm/compressors/lz4_compressor.cc +++ b/tiledb/sm/compressors/lz4_compressor.cc @@ -43,15 +43,12 @@ using namespace tiledb::common; namespace tiledb { namespace sm { -Status LZ4::compress( - int level, ConstBuffer* input_buffer, Buffer* output_buffer) { +Status LZ4::compress(int, ConstBuffer* input_buffer, Buffer* output_buffer) { // Sanity check if (input_buffer->data() == nullptr || output_buffer->data() == nullptr) return LOG_STATUS(Status_CompressionError( "Failed compressing with LZ4; invalid buffer format")); - // TODO: level is ignored using the simple api interface - (void)level; // Compress #if LZ4_VERSION_NUMBER >= 10705 int ret = LZ4_compress_default( diff --git a/tiledb/sm/compressors/test/link_webp_test1.cc b/tiledb/sm/compressors/test/link_webp_test1.cc index b52d8647286d..c693674ecf95 100644 --- a/tiledb/sm/compressors/test/link_webp_test1.cc +++ b/tiledb/sm/compressors/test/link_webp_test1.cc @@ -108,9 +108,7 @@ typedef void VP8LDecoder; extern "C" VP8LDecoder* VP8LNew(void); extern "C" void VP8LClear(VP8LDecoder*); -int main(int argc, const char* argv[]) { - (void)argv; - (void)argc; +int main(int, const char*[]) { int return_value = -1; const char *in_file = NULL, *out_file = NULL; FILE* out = NULL; diff --git a/tiledb/sm/consolidator/fragment_meta_consolidator.cc b/tiledb/sm/consolidator/fragment_meta_consolidator.cc index 71c799958d93..a9b62002cf5d 100644 --- a/tiledb/sm/consolidator/fragment_meta_consolidator.cc +++ b/tiledb/sm/consolidator/fragment_meta_consolidator.cc @@ -173,9 +173,8 @@ Status FragmentMetaConsolidator::consolidate( RETURN_NOT_OK(enc_key.set_key(encryption_type, encryption_key, key_length)); GenericTileIO tile_io(storage_manager_->resources(), uri); - uint64_t nbytes = 0; + [[maybe_unused]] uint64_t nbytes = 0; RETURN_NOT_OK(tile_io.write_generic(&tile, enc_key, &nbytes)); - (void)nbytes; RETURN_NOT_OK(storage_manager_->vfs()->close_file(uri)); return Status::Ok(); diff --git a/tiledb/sm/consolidator/group_meta_consolidator.cc b/tiledb/sm/consolidator/group_meta_consolidator.cc index cf3fd381870d..ae0db0fc97ae 100644 --- a/tiledb/sm/consolidator/group_meta_consolidator.cc +++ b/tiledb/sm/consolidator/group_meta_consolidator.cc @@ -62,13 +62,7 @@ GroupMetaConsolidator::GroupMetaConsolidator( /* ****************************** */ Status GroupMetaConsolidator::consolidate( - const char* group_name, - EncryptionType encryption_type, - const void* encryption_key, - uint32_t key_length) { - (void)encryption_type; - (void)encryption_key; - (void)key_length; + const char* group_name, EncryptionType, const void*, uint32_t) { auto timer_se = stats_->start_timer("consolidate_group_meta"); check_array_uri(group_name); diff --git a/tiledb/sm/cpp_api/vfs.h b/tiledb/sm/cpp_api/vfs.h index 166a61570e4c..f8eb19f43328 100644 --- a/tiledb/sm/cpp_api/vfs.h +++ b/tiledb/sm/cpp_api/vfs.h @@ -684,8 +684,7 @@ inline uint64_t VFSFilebuf::file_size() const { return 0; try { return vfs_.get().file_size(uri_); - } catch (TileDBError& e) { - (void)e; + } catch (TileDBError&) { return 0; } } diff --git a/tiledb/sm/filesystem/mem_filesystem.cc b/tiledb/sm/filesystem/mem_filesystem.cc index 26b6fc51e0a8..329f262ed16b 100644 --- a/tiledb/sm/filesystem/mem_filesystem.cc +++ b/tiledb/sm/filesystem/mem_filesystem.cc @@ -158,20 +158,15 @@ class MemFilesystem::File : public MemFilesystem::FSNode { /** Returns the full path to this file */ tuple>> ls( - const std::string& full_path) const override { + const std::string&) const override { assert(!mutex_.try_lock()); - (void)full_path; - auto st = LOG_STATUS(Status_MemFSError( std::string("Cannot get children, the path is a file"))); return {st, nullopt}; } - bool has_child(const std::string& child) const override { - assert(!mutex_.try_lock()); - - (void)child; + bool has_child(const std::string&) const override { return false; } @@ -308,33 +303,21 @@ class MemFilesystem::Directory : public MemFilesystem::FSNode { return children_.count(child) != 0; } - Status get_size(uint64_t* const size) const override { + Status get_size(uint64_t* const) const override { assert(!mutex_.try_lock()); - assert(size); - (void)size; return LOG_STATUS(Status_MemFSError( std::string("Cannot get size, the path is a directory"))); } - Status read(const uint64_t offset, void* buffer, const uint64_t nbytes) - const override { - assert(!mutex_.try_lock()); - assert(buffer); - - (void)offset; - (void)buffer; - (void)nbytes; + Status read(const uint64_t, void*, const uint64_t) const override { return LOG_STATUS(Status_MemFSError( std::string("Cannot read contents, the path is a directory"))); } - Status append(const void* const data, const uint64_t nbytes) override { + Status append(const void* const, const uint64_t) override { assert(!mutex_.try_lock()); - assert(data); - (void)data; - (void)nbytes; return LOG_STATUS(Status_MemFSError( std::string("Cannot append contents, the path is a directory"))); } diff --git a/tiledb/sm/filesystem/posix.cc b/tiledb/sm/filesystem/posix.cc index 698019f792ee..b9f350b0758f 100644 --- a/tiledb/sm/filesystem/posix.cc +++ b/tiledb/sm/filesystem/posix.cc @@ -193,14 +193,7 @@ std::string Posix::current_dir() { // TODO: it maybe better to use unlinkat for deeply nested recursive directories // but the path name length limit in TileDB may make this unnecessary -int Posix::unlink_cb( - const char* fpath, - const struct stat* sb, - int typeflag, - struct FTW* ftwbuf) { - (void)sb; - (void)typeflag; - (void)ftwbuf; +int Posix::unlink_cb(const char* fpath, const struct stat*, int, struct FTW*) { int rc = remove(fpath); if (rc) perror(fpath); diff --git a/tiledb/sm/filesystem/vfs.cc b/tiledb/sm/filesystem/vfs.cc index 85489919f968..7c227477430b 100644 --- a/tiledb/sm/filesystem/vfs.cc +++ b/tiledb/sm/filesystem/vfs.cc @@ -294,7 +294,6 @@ Status VFS::create_bucket(const URI& uri) const { #ifdef HAVE_S3 return s3_.create_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("S3 is not supported"))); #endif } @@ -302,7 +301,6 @@ Status VFS::create_bucket(const URI& uri) const { #ifdef HAVE_AZURE return azure_.create_container(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("Azure is not supported"))); #endif } @@ -310,7 +308,6 @@ Status VFS::create_bucket(const URI& uri) const { #ifdef HAVE_GCS return gcs_.create_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("GCS is not supported"))); #endif } @@ -324,7 +321,6 @@ Status VFS::remove_bucket(const URI& uri) const { #ifdef HAVE_S3 return s3_.remove_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("S3 is not supported"))); #endif } @@ -332,7 +328,6 @@ Status VFS::remove_bucket(const URI& uri) const { #ifdef HAVE_AZURE return azure_.remove_container(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("Azure is not supported"))); #endif } @@ -340,7 +335,6 @@ Status VFS::remove_bucket(const URI& uri) const { #ifdef HAVE_GCS return gcs_.remove_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("GCS is not supported"))); #endif } @@ -354,7 +348,6 @@ Status VFS::empty_bucket(const URI& uri) const { #ifdef HAVE_S3 return s3_.empty_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("S3 is not supported"))); #endif } @@ -362,7 +355,6 @@ Status VFS::empty_bucket(const URI& uri) const { #ifdef HAVE_AZURE return azure_.empty_container(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("Azure is not supported"))); #endif } @@ -370,7 +362,6 @@ Status VFS::empty_bucket(const URI& uri) const { #ifdef HAVE_GCS return gcs_.empty_bucket(uri); #else - (void)uri; return LOG_STATUS(Status_VFSError(std::string("GCS is not supported"))); #endif } @@ -379,13 +370,12 @@ Status VFS::empty_bucket(const URI& uri) const { uri.to_string())); } -Status VFS::is_empty_bucket(const URI& uri, bool* is_empty) const { +Status VFS::is_empty_bucket( + const URI& uri, [[maybe_unused]] bool* is_empty) const { if (uri.is_s3()) { #ifdef HAVE_S3 return s3_.is_empty_bucket(uri, is_empty); #else - (void)uri; - (void)is_empty; return LOG_STATUS(Status_VFSError(std::string("S3 is not supported"))); #endif } @@ -393,8 +383,6 @@ Status VFS::is_empty_bucket(const URI& uri, bool* is_empty) const { #ifdef HAVE_AZURE return azure_.is_empty_container(uri, is_empty); #else - (void)uri; - (void)is_empty; return LOG_STATUS(Status_VFSError(std::string("Azure is not supported"))); #endif } @@ -402,8 +390,6 @@ Status VFS::is_empty_bucket(const URI& uri, bool* is_empty) const { #ifdef HAVE_GCS return gcs_.is_empty_bucket(uri, is_empty); #else - (void)uri; - (void)is_empty; return LOG_STATUS(Status_VFSError(std::string("GCS is not supported"))); #endif } @@ -1216,13 +1202,11 @@ Status VFS::read_impl( const uint64_t offset, void* const buffer, const uint64_t nbytes, - const bool use_read_ahead) { + [[maybe_unused]] const bool use_read_ahead) { stats_->add_counter("read_ops_num", 1); // We only check to use the read-ahead cache for cloud-storage - // backends. No-op the `use_read_ahead` to prevent the unused - // variable compiler warning. - (void)use_read_ahead; + // backends. if (uri.is_file()) { #ifdef _WIN32 @@ -1535,12 +1519,10 @@ Status VFS::write( const URI& uri, const void* buffer, uint64_t buffer_size, - bool remote_global_order_write) { + [[maybe_unused]] bool remote_global_order_write) { stats_->add_counter("write_byte_num", buffer_size); stats_->add_counter("write_ops_num", 1); - (void)remote_global_order_write; - if (uri.is_file()) { #ifdef _WIN32 return win_.write(uri.to_path(), buffer, buffer_size); @@ -1649,8 +1631,7 @@ VFS::multipart_upload_state(const URI& uri) { } Status VFS::set_multipart_upload_state( - const URI& uri, const MultiPartUploadState& state) { - (void)state; + const URI& uri, [[maybe_unused]] const MultiPartUploadState& state) { if (uri.is_file()) { return Status::Ok(); } else if (uri.is_s3()) { diff --git a/tiledb/sm/filter/bitshuffle_filter.cc b/tiledb/sm/filter/bitshuffle_filter.cc index 65cb521994b0..ae3f23fb274c 100644 --- a/tiledb/sm/filter/bitshuffle_filter.cc +++ b/tiledb/sm/filter/bitshuffle_filter.cc @@ -168,8 +168,7 @@ Status BitshuffleFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; + const Config&) const { auto tile_type_size = static_cast(datatype_size(filter_data_type_)); // Get number of parts diff --git a/tiledb/sm/filter/byteshuffle_filter.cc b/tiledb/sm/filter/byteshuffle_filter.cc index d6d3012484a5..f92f46a9b6e6 100644 --- a/tiledb/sm/filter/byteshuffle_filter.cc +++ b/tiledb/sm/filter/byteshuffle_filter.cc @@ -113,9 +113,7 @@ Status ByteshuffleFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; - + const Config&) const { // Get number of parts uint32_t num_parts; RETURN_NOT_OK(input_metadata->read(&num_parts, sizeof(uint32_t))); diff --git a/tiledb/sm/filter/compression_filter.cc b/tiledb/sm/filter/compression_filter.cc index 1c14e7152197..ab14da94507a 100644 --- a/tiledb/sm/filter/compression_filter.cc +++ b/tiledb/sm/filter/compression_filter.cc @@ -310,9 +310,7 @@ Status CompressionFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; - + const Config&) const { // Easy case: no compression if (compressor_ == Compressor::NO_COMPRESSION) { RETURN_NOT_OK(output->append_view(input)); diff --git a/tiledb/sm/filter/encryption_aes256gcm_filter.cc b/tiledb/sm/filter/encryption_aes256gcm_filter.cc index dba2b9d19ce5..fd9ffc4483b9 100644 --- a/tiledb/sm/filter/encryption_aes256gcm_filter.cc +++ b/tiledb/sm/filter/encryption_aes256gcm_filter.cc @@ -146,8 +146,7 @@ Status EncryptionAES256GCMFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; + const Config&) const { if (key_bytes_ == nullptr) return LOG_STATUS(Status_FilterError("Encryption error; bad key.")); diff --git a/tiledb/sm/filter/filter.cc b/tiledb/sm/filter/filter.cc index f12933d5bc30..bbba192c075f 100644 --- a/tiledb/sm/filter/filter.cc +++ b/tiledb/sm/filter/filter.cc @@ -117,15 +117,11 @@ void Filter::serialize(Serializer& serializer) const { serialize_impl(serializer); } -Status Filter::get_option_impl(FilterOption option, void* value) const { - (void)option; - (void)value; +Status Filter::get_option_impl(FilterOption, void*) const { return LOG_STATUS(Status_FilterError("Filter does not support options.")); } -Status Filter::set_option_impl(FilterOption option, const void* value) { - (void)option; - (void)value; +Status Filter::set_option_impl(FilterOption, const void*) { return LOG_STATUS(Status_FilterError("Filter does not support options.")); } @@ -136,12 +132,10 @@ FilterType Filter::type() const { return type_; } -void Filter::init_compression_resource_pool(uint64_t size) { - (void)size; +void Filter::init_compression_resource_pool(uint64_t) { } -void Filter::init_decompression_resource_pool(uint64_t size) { - (void)size; +void Filter::init_decompression_resource_pool(uint64_t) { } } // namespace sm diff --git a/tiledb/sm/filter/float_scaling_filter.cc b/tiledb/sm/filter/float_scaling_filter.cc index 5030bf1e45e2..8948d04879e7 100644 --- a/tiledb/sm/filter/float_scaling_filter.cc +++ b/tiledb/sm/filter/float_scaling_filter.cc @@ -224,8 +224,7 @@ Status FloatScalingFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; + const Config&) const { auto tile_type_size = static_cast(datatype_size(filter_data_type_)); switch (tile_type_size) { case sizeof(float): { diff --git a/tiledb/sm/filter/noop_filter.cc b/tiledb/sm/filter/noop_filter.cc index 49277f795f08..26a36abe6e02 100644 --- a/tiledb/sm/filter/noop_filter.cc +++ b/tiledb/sm/filter/noop_filter.cc @@ -74,9 +74,7 @@ Status NoopFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; - + const Config&) const { RETURN_NOT_OK(output->append_view(input)); RETURN_NOT_OK(output_metadata->append_view(input_metadata)); return Status::Ok(); diff --git a/tiledb/sm/filter/xor_filter.cc b/tiledb/sm/filter/xor_filter.cc index 2f44ecdf49ab..96e67bd70838 100644 --- a/tiledb/sm/filter/xor_filter.cc +++ b/tiledb/sm/filter/xor_filter.cc @@ -181,9 +181,7 @@ Status XORFilter::run_reverse( FilterBuffer* input, FilterBuffer* output_metadata, FilterBuffer* output, - const Config& config) const { - (void)config; - + const Config&) const { // Since run_reverse interprets the filter's data as integers, we case on // the size of the type and pass in the corresponding integer type into // a templated function. diff --git a/tiledb/sm/fragment/fragment_metadata.cc b/tiledb/sm/fragment/fragment_metadata.cc index e3d484386bcc..7dbb763fe967 100644 --- a/tiledb/sm/fragment/fragment_metadata.cc +++ b/tiledb/sm/fragment/fragment_metadata.cc @@ -3696,11 +3696,10 @@ Status FragmentMetadata::load_v3_or_higher( } Status FragmentMetadata::load_footer( - const EncryptionKey& encryption_key, + const EncryptionKey&, Tile* fragment_metadata_tile, uint64_t offset, std::unordered_map> array_schemas) { - (void)encryption_key; // Not used for now, perhaps in the future std::lock_guard lock(mtx_); if (loaded_metadata_.footer_) @@ -4697,8 +4696,7 @@ void FragmentMetadata::write_has_delete_meta(Serializer& serializer) const { serializer.write(has_delete_meta_); } -Status FragmentMetadata::store_footer(const EncryptionKey& encryption_key) { - (void)encryption_key; // Not used for now, maybe in the future +Status FragmentMetadata::store_footer(const EncryptionKey&) { SizeComputationSerializer size_computation_serializer; RETURN_NOT_OK(write_footer(size_computation_serializer)); WriterTile tile{WriterTile::from_generic(size_computation_serializer.size())}; diff --git a/tiledb/sm/global_state/signal_handlers.cc b/tiledb/sm/global_state/signal_handlers.cc index 0bcaae283c39..ae8433150af7 100644 --- a/tiledb/sm/global_state/signal_handlers.cc +++ b/tiledb/sm/global_state/signal_handlers.cc @@ -127,9 +127,7 @@ Status SignalHandlers::initialize() { } void SignalHandlers::safe_stderr(const char* msg, size_t msg_len) { - auto retval = _write(2, msg, (unsigned int)msg_len); - // Ignore return value. - (void)retval; + std::ignore = _write(2, msg, (unsigned int)msg_len); } #else @@ -163,9 +161,7 @@ Status SignalHandlers::initialize() { } void SignalHandlers::safe_stderr(const char* msg, size_t msg_len) { - auto retval = write(2, msg, msg_len); - // Ignore return value. - (void)retval; + std::ignore = write(2, msg, msg_len); } #endif diff --git a/tiledb/sm/group/group.h b/tiledb/sm/group/group.h index b558481a6eac..1833ad63c0e2 100644 --- a/tiledb/sm/group/group.h +++ b/tiledb/sm/group/group.h @@ -50,6 +50,13 @@ using namespace tiledb::common; namespace tiledb { namespace sm { +class GroupDetailsException : public StatusException { + public: + explicit GroupDetailsException(const std::string& message) + : StatusException("Group Details", message) { + } +}; + class Group { public: Group(const URI& group_uri, StorageManager* storage_manager); diff --git a/tiledb/sm/group/group_details_v2.cc b/tiledb/sm/group/group_details_v2.cc index 8c7809d722b3..221d9d7e1db9 100644 --- a/tiledb/sm/group/group_details_v2.cc +++ b/tiledb/sm/group/group_details_v2.cc @@ -84,9 +84,11 @@ shared_ptr GroupDetailsV2::deserialize( for (auto& deserializer : deserializers) { // Read and assert version format_version_t details_version = deserializer->read(); - assert(details_version == 2); - // Avoid unused warning when in release mode and the assert doesn't exist. - (void)details_version; + if (details_version != 2) { + throw GroupDetailsException( + "Invalid version " + std::to_string(details_version) + + "; expected 2."); + } // Read members uint64_t member_count = deserializer->read(); diff --git a/tiledb/sm/group/group_directory.cc b/tiledb/sm/group/group_directory.cc index 6dddc476f34b..4395f6d65c75 100644 --- a/tiledb/sm/group/group_directory.cc +++ b/tiledb/sm/group/group_directory.cc @@ -116,10 +116,6 @@ const std::vector& GroupDirectory::group_detail_uris() const { Status GroupDirectory::load() { assert(!loaded_); - // We use mode here to avoid warning on errors - // Mode will be used for consolidation settings - (void)mode_; - std::vector tasks; std::vector root_dir_uris; std::vector commits_dir_uris; diff --git a/tiledb/sm/group/group_directory.h b/tiledb/sm/group/group_directory.h index 8ff915eee06c..4fe690d0d05b 100644 --- a/tiledb/sm/group/group_directory.h +++ b/tiledb/sm/group/group_directory.h @@ -196,7 +196,7 @@ class GroupDirectory { uint64_t timestamp_end_; /** Mode for the group directory. */ - GroupDirectoryMode mode_; + [[maybe_unused]] GroupDirectoryMode mode_; /** True if `load` has been run. */ bool loaded_; diff --git a/tiledb/sm/misc/utils.h b/tiledb/sm/misc/utils.h index 48918e08ad29..2dbae1d5f365 100644 --- a/tiledb/sm/misc/utils.h +++ b/tiledb/sm/misc/utils.h @@ -103,11 +103,8 @@ uint64_t cell_num(const T* rect, unsigned dim_num) { template < class T, typename std::enable_if::value, T>::type* = nullptr> -uint64_t cell_num(const T* rect, unsigned dim_num) { - assert(false); - (void)rect; - (void)dim_num; - return 0; +uint64_t cell_num(const T*, unsigned) { + throw std::logic_error("Invalid call to `cell_num` for non-integral type"); } /** diff --git a/tiledb/sm/query/readers/result_tile.cc b/tiledb/sm/query/readers/result_tile.cc index c2953b6ea528..91496c5bd0cf 100644 --- a/tiledb/sm/query/readers/result_tile.cc +++ b/tiledb/sm/query/readers/result_tile.cc @@ -761,10 +761,7 @@ void ResultTile::compute_results_sparse( unsigned dim_idx, const Range& range, std::vector* result_bitmap, - const Layout& cell_order) { - // We do not use `cell_order` for this template type. - (void)cell_order; - + const Layout&) { // For easy reference. auto coords_num = result_tile->cell_num(); auto r = (const T*)range.data(); @@ -1050,12 +1047,9 @@ void ResultTile::compute_results_count_sparse( const NDRange& ranges, const std::vector& range_indexes, std::vector& result_count, - const Layout& cell_order, + const Layout&, const uint64_t min_cell, const uint64_t max_cell) { - // We don't use cell_order for this template type. - (void)cell_order; - // For easy reference. auto stores_zipped_coords = result_tile->stores_zipped_coords(); auto dim_num = result_tile->domain()->dim_num(); diff --git a/tiledb/sm/query/test/unit_query_condition.cc b/tiledb/sm/query/test/unit_query_condition.cc index 8c5fb6260dbb..7f28ccbfade8 100644 --- a/tiledb/sm/query/test/unit_query_condition.cc +++ b/tiledb/sm/query/test/unit_query_condition.cc @@ -1595,9 +1595,7 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { * Non-specialized template type for `test_apply`. */ template -void test_apply(const Datatype type, bool var_size, bool nullable) { - (void)var_size; - (void)nullable; +void test_apply(const Datatype type, bool, bool) { const std::string field_name = "foo"; const uint64_t cells = 10; const T fill_value = 3; diff --git a/tiledb/sm/rest/rest_client.cc b/tiledb/sm/rest/rest_client.cc index 5556e568fa65..30fb9b63030d 100644 --- a/tiledb/sm/rest/rest_client.cc +++ b/tiledb/sm/rest/rest_client.cc @@ -82,8 +82,7 @@ RestClient::RestClient() , resubmit_incomplete_(true) { auto st = utils::parse::convert( Config::REST_SERIALIZATION_DEFAULT_FORMAT, &serialization_type_); - assert(st.ok()); - (void)st; + throw_if_not_ok(st); } Status RestClient::init( diff --git a/tiledb/sm/rtree/rtree.cc b/tiledb/sm/rtree/rtree.cc index 51fce4a40c7f..1761839f4be4 100644 --- a/tiledb/sm/rtree/rtree.cc +++ b/tiledb/sm/rtree/rtree.cc @@ -361,14 +361,12 @@ void RTree::deserialize_v1_v4( deserialized_buffer_size_ = deserializer.size(); // For backwards compatibility, ignored - auto dim_num_i = deserializer.read(); - (void)dim_num_i; + std::ignore = deserializer.read(); fanout_ = deserializer.read(); // For backwards compatibility, ignored - auto type_i = deserializer.read(); - (void)type_i; + std::ignore = deserializer.read(); auto level_num = deserializer.read(); levels_.clear(); diff --git a/tiledb/sm/serialization/config.cc b/tiledb/sm/serialization/config.cc index a8c66c5b68e8..9b1ff7102875 100644 --- a/tiledb/sm/serialization/config.cc +++ b/tiledb/sm/serialization/config.cc @@ -108,9 +108,7 @@ Status config_serialize( const Config& config, SerializationType serialize_type, Buffer* serialized_buffer, - const bool client_side) { - // Currently client_side is unused - (void)client_side; + const bool) { try { ::capnp::MallocMessageBuilder message; capnp::Config::Builder configBuilder = message.initRoot(); diff --git a/tiledb/sm/serialization/query.cc b/tiledb/sm/serialization/query.cc index 9d2772f9bf93..05c43207dca9 100644 --- a/tiledb/sm/serialization/query.cc +++ b/tiledb/sm/serialization/query.cc @@ -2676,9 +2676,8 @@ Status query_est_result_size_reader_from_capnp( Status query_est_result_size_serialize( Query* query, SerializationType serialize_type, - bool clientside, + bool, Buffer* serialized_buffer) { - (void)clientside; try { ::capnp::MallocMessageBuilder message; capnp::EstimatedResultSize::Builder est_result_size_builder = @@ -2728,9 +2727,8 @@ Status query_est_result_size_serialize( Status query_est_result_size_deserialize( Query* query, SerializationType serialize_type, - bool clientside, + bool, const Buffer& serialized_buffer) { - (void)clientside; try { switch (serialize_type) { case SerializationType::JSON: {