Fix clang analyze for trace replace GetPayload (#8121)

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
This commit is contained in:
mrambacher 2021-03-26 17:47:32 -07:00 committed by Facebook GitHub Bot
parent c5f52714fb
commit a34dafe5ff
2 changed files with 3 additions and 2 deletions

View File

@ -427,6 +427,7 @@ Status Replayer::Replay() {
ops++; ops++;
} else if (trace.type == kTraceGet) { } else if (trace.type == kTraceGet) {
GetPayload get_payload; GetPayload get_payload;
get_payload.cf_id = 0;
get_payload.get_key = 0; get_payload.get_key = 0;
if (trace_file_version_ < 2) { if (trace_file_version_ < 2) {
DecodeCFAndKey(trace.payload, &get_payload.cf_id, &get_payload.get_key); DecodeCFAndKey(trace.payload, &get_payload.cf_id, &get_payload.get_key);

View File

@ -105,12 +105,12 @@ struct WritePayload {
}; };
struct GetPayload { struct GetPayload {
uint32_t cf_id; uint32_t cf_id = 0;
Slice get_key; Slice get_key;
}; };
struct IterPayload { struct IterPayload {
uint32_t cf_id; uint32_t cf_id = 0;
Slice iter_key; Slice iter_key;
Slice lower_bound; Slice lower_bound;
Slice upper_bound; Slice upper_bound;