Skip to content

Commit

Permalink
Remove unused-variable in velox/buffer/tests/BufferTest.cpp (facebook…
Browse files Browse the repository at this point in the history
…incubator#11398)

Summary:
Pull Request resolved: facebookincubator#11398

LLVM-15 has a warning `-Wunused-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code or (b) qualifies the variable with `[[maybe_unused]]`.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: aaronwlma, pedroerp

Differential Revision: D65144811

fbshipit-source-id: 79812cf160aaeeec514885c9a2bbfd860c87c1c7
  • Loading branch information
r-barnes authored and facebook-github-bot committed Oct 31, 2024
1 parent e03999f commit e6af8b6
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 12 deletions.
1 change: 0 additions & 1 deletion velox/buffer/tests/BufferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ TEST_F(BufferTest, testReallocate) {
int32_t numInPlace = 0;
int32_t numMoved = 0;
for (int32_t i = 0; i < buffers.size(); ++i) {
size_t oldSize = buffers[i]->size();
auto ptr = buffers[i].get();
if (i % 10 == 0) {
AlignedBuffer::reallocate<char>(&buffers[i], i + 10000);
Expand Down
2 changes: 2 additions & 0 deletions velox/common/base/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ DECLARE_CHECK_FAIL_TEMPLATES(::facebook::velox::VeloxRuntimeError);
#define VELOX_DCHECK_NE(e1, e2, ...) VELOX_CHECK_NE(e1, e2, ##__VA_ARGS__)
#define VELOX_DCHECK_NULL(e, ...) VELOX_CHECK_NULL(e, ##__VA_ARGS__)
#define VELOX_DCHECK_NOT_NULL(e, ...) VELOX_CHECK_NOT_NULL(e, ##__VA_ARGS__)
#define VELOX_DEBUG_ONLY
#else
#define VELOX_DCHECK(expr, ...) VELOX_CHECK(true)
#define VELOX_DCHECK_GT(e1, e2, ...) VELOX_CHECK(true)
Expand All @@ -344,6 +345,7 @@ DECLARE_CHECK_FAIL_TEMPLATES(::facebook::velox::VeloxRuntimeError);
#define VELOX_DCHECK_NE(e1, e2, ...) VELOX_CHECK(true)
#define VELOX_DCHECK_NULL(e, ...) VELOX_CHECK(true)
#define VELOX_DCHECK_NOT_NULL(e, ...) VELOX_CHECK(true)
#define VELOX_DEBUG_ONLY [[maybe_unused]]
#endif

#define VELOX_FAIL(...) \
Expand Down
2 changes: 1 addition & 1 deletion velox/common/process/tests/ProfilerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main(int argc, char** argv) {
});

int wstatus;
int w = waitpid(pid, &wstatus, WUNTRACED | WCONTINUED);
waitpid(pid, &wstatus, WUNTRACED | WCONTINUED);
LOG(INFO) << "Test completed";
completed = true;
sleepPromise.setValue(true);
Expand Down
3 changes: 2 additions & 1 deletion velox/dwio/common/FlatMapHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ void copyOffsetsFromConstInput(
const BaseVector& source,
vector_size_t sourceIndex,
vector_size_t count) {
auto nullCount = copyNulls(target, targetIndex, source, sourceIndex, count);
VELOX_DEBUG_ONLY const auto nullCount =
copyNulls(target, targetIndex, source, sourceIndex, count);
VELOX_DCHECK_EQ(nullCount, count, "Expecting constant null vector input");
// We cannot track the last non-null index efficiently across copy
// invocations. In order to make it easier for computing child offset, we
Expand Down
1 change: 0 additions & 1 deletion velox/expression/EvalCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ void EvalCtx::copyError(
vector_size_t fromIndex,
EvalErrorsPtr& to,
vector_size_t toIndex) const {
const auto fromSize = from.size();
if (from.hasErrorAt(fromIndex)) {
ensureErrorsVectorSize(to, toIndex + 1);
to->copyError(from, fromIndex, toIndex);
Expand Down
3 changes: 1 addition & 2 deletions velox/functions/lib/KllSketch-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ int KllSketch<T, A, C>::findLevelToCompact() const {

template <typename T, typename A, typename C>
void KllSketch<T, A, C>::addEmptyTopLevelToCompletelyFullSketch() {
const uint32_t curTotalCap = levels_.back();

VELOX_DEBUG_ONLY const uint32_t curTotalCap = levels_.back();
// Make sure that we are following a certain growth scheme.
VELOX_DCHECK_EQ(levels_[0], 0);
VELOX_DCHECK_EQ(items_.size(), curTotalCap);
Expand Down
1 change: 0 additions & 1 deletion velox/functions/sparksql/ArrayInsert.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct ArrayInsert {

out.reserve(newArrayLength);
int32_t posIdx = *pos - 1;
int32_t nextIdx = 0;
for (int32_t i = 0; i < newArrayLength; i++) {
if (i == posIdx) {
item ? out.push_back(*item) : out.add_null();
Expand Down
3 changes: 1 addition & 2 deletions velox/functions/sparksql/MaskFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ struct MaskFunction {
// it with the length of replacing character. Inequality indicates the
// replacing character includes more than one unicode characters.
int size;
auto codePoint = utf8proc_codepoint(
&maskCharData[0], maskCharData + maskCharSize, size);
utf8proc_codepoint(&maskCharData[0], maskCharData + maskCharSize, size);
VELOX_USER_CHECK_EQ(
maskCharSize,
size,
Expand Down
2 changes: 0 additions & 2 deletions velox/serializers/PrestoSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4245,8 +4245,6 @@ void PrestoVectorSerde::deserializeSingleColumn(
VELOX_CHECK_EQ(
prestoOptions.compressionKind,
common::CompressionKind::CompressionKind_NONE);
const bool useLosslessTimestamp = prestoOptions.useLosslessTimestamp;

if (*result && result->unique()) {
VELOX_CHECK(
*(*result)->type() == *type,
Expand Down
1 change: 0 additions & 1 deletion velox/vector/fuzzer/examples/ArrayGeneratorExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ int main() {
constexpr int sampleSize = 100;
constexpr int32_t lo = 100, hi = 1000;
constexpr double mu = 5.0, sigma = 2.0;
constexpr double p = 0.25;
constexpr double nullProbability = 0.38;

auto normal = std::normal_distribution<double>(mu, sigma);
Expand Down

0 comments on commit e6af8b6

Please sign in to comment.