From e3ea5237d5e139ec93d5c4cb3d06fb38df6e562b Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 2 May 2024 15:58:03 -0500 Subject: [PATCH] Fix -Werror=type-limits. (#15635) I'm compiling cuDF as a part of another application and ran into errors from `-Werror=type-limits`. There are a few comparisons between unsigned types like `value < 0`, which is never true. This PR removes those impossible code paths. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - MithunR (https://github.com/mythrocks) - David Wendt (https://github.com/davidwendt) URL: https://github.com/rapidsai/cudf/pull/15635 --- cpp/src/io/comp/cpu_unbz2.cpp | 6 +++--- cpp/src/io/parquet/reader_impl_helpers.cpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cpp/src/io/comp/cpu_unbz2.cpp b/cpp/src/io/comp/cpu_unbz2.cpp index a116335b254..44535cff589 100644 --- a/cpp/src/io/comp/cpu_unbz2.cpp +++ b/cpp/src/io/comp/cpu_unbz2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, NVIDIA CORPORATION. + * Copyright (c) 2018-2024, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -221,7 +221,7 @@ int32_t bz2_decompress_block(unbz_state_s* s) if (getbits(s, 1)) return BZ_DATA_ERROR; // blockRandomized not supported (old bzip versions) s->origPtr = getbits(s, 24); - if (s->origPtr < 0 || s->origPtr > 10 + 100000 * s->blockSize100k) return BZ_DATA_ERROR; + if (s->origPtr > 10 + 100000 * s->blockSize100k) return BZ_DATA_ERROR; // Receive the mapping table inUse16 = getbits(s, 16); @@ -436,7 +436,7 @@ int32_t bz2_decompress_block(unbz_state_s* s) } // Now we know what nblock is, we can do a better sanity check on s->origPtr. - if (s->origPtr < 0 || s->origPtr >= nblock) return BZ_DATA_ERROR; + if (s->origPtr >= nblock) return BZ_DATA_ERROR; // compute the T^(-1) vector { diff --git a/cpp/src/io/parquet/reader_impl_helpers.cpp b/cpp/src/io/parquet/reader_impl_helpers.cpp index 402ccef7a15..c7659be1adb 100644 --- a/cpp/src/io/parquet/reader_impl_helpers.cpp +++ b/cpp/src/io/parquet/reader_impl_helpers.cpp @@ -205,7 +205,6 @@ void metadata::sanitize_schema() // This code attempts to make this less messy for the code that follows. std::function process = [&](size_t schema_idx) -> void { - if (schema_idx < 0) { return; } auto& schema_elem = schema[schema_idx]; if (schema_idx != 0 && schema_elem.type == UNDEFINED_TYPE) { auto const parent_type = schema[schema_elem.parent_idx].converted_type; @@ -723,7 +722,6 @@ aggregate_reader_metadata::select_columns(std::optional int schema_idx, std::vector& out_col_array, bool has_list_parent) { - if (schema_idx < 0) { return false; } auto const& schema_elem = get_schema(schema_idx); // if schema_elem is a stub then it does not exist in the column_name_info and column_buffer