From a34dafe5ff53f7c30df9024417c5494375ee475a Mon Sep 17 00:00:00 2001 From: mrambacher Date: Fri, 26 Mar 2021 17:47:32 -0700 Subject: [PATCH] Fix clang analyze for trace replace GetPayload (#8121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: For some branches, I see an error during analyze on this code. I do not know why it is not persistent, but this should address the error: Logic error | Result of operation is garbage or undefined | trace_replay.cc | Replay | 436 | 30 | View Report DecodeCFAndKey(trace.payload, &get_payload.cf_id, &get_payload.get_key); -- 433 | } else { 434 | TracerHelper::DecodeGetPayload(&trace, &get_payload); | 25←Calling 'TracerHelper::DecodeGetPayload'→ | 25 | ← | Calling 'TracerHelper::DecodeGetPayload' | → 25 | ← | Calling 'TracerHelper::DecodeGetPayload' | → | 29←Returning from 'TracerHelper::DecodeGetPayload'→ | 29 | ← | Returning from 'TracerHelper::DecodeGetPayload' | → 29 | ← | Returning from 'TracerHelper::DecodeGetPayload' | → 435 | } 436 | if (get_payload.cf_id > 0 && | 30←The left operand of '>' is a garbage value | 30 | ← | The left operand of '>' is a garbage value 30 | ← | The left operand of '>' is a garbage value 437 | cf_map_.find(get_payload.cf_id) == cf_map_.end()) { 438 | return Status::Corruption("Invalid Column Family ID."); 439 | } Pull Request resolved: https://github.com/facebook/rocksdb/pull/8121 Reviewed By: zhichao-cao Differential Revision: D27366022 Pulled By: mrambacher fbshipit-source-id: 309c05dbab08cd7ab7f15389e8456f09196f37f6 --- trace_replay/trace_replay.cc | 1 + trace_replay/trace_replay.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/trace_replay/trace_replay.cc b/trace_replay/trace_replay.cc index bf00f0468..785e1fa56 100644 --- a/trace_replay/trace_replay.cc +++ b/trace_replay/trace_replay.cc @@ -427,6 +427,7 @@ Status Replayer::Replay() { ops++; } else if (trace.type == kTraceGet) { GetPayload get_payload; + get_payload.cf_id = 0; get_payload.get_key = 0; if (trace_file_version_ < 2) { DecodeCFAndKey(trace.payload, &get_payload.cf_id, &get_payload.get_key); diff --git a/trace_replay/trace_replay.h b/trace_replay/trace_replay.h index a42ec8fbb..3ae3e8e5b 100644 --- a/trace_replay/trace_replay.h +++ b/trace_replay/trace_replay.h @@ -105,12 +105,12 @@ struct WritePayload { }; struct GetPayload { - uint32_t cf_id; + uint32_t cf_id = 0; Slice get_key; }; struct IterPayload { - uint32_t cf_id; + uint32_t cf_id = 0; Slice iter_key; Slice lower_bound; Slice upper_bound;