Merge #19593: refactor: Drop unused CBufferedFile::Seek()

7b3851e9473e74043342d414c056c2ef87c2f261 refactor: Drop unused CBufferedFile::Seek() (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  practicalswift:
    ACK 7b3851e9473e74043342d414c056c2ef87c2f261 -- deleted code is better than unused untested code:)
  MarcoFalke:
    ACK 7b3851e9473e74043342d414c056c2ef87c2f261, assuming that removing this should either be correct or result in a compile failure
  jonasschnelli:
    utACK 7b3851e9473e74043342d414c056c2ef87c2f261
  promag:
    Code review ACK 7b3851e9473e74043342d414c056c2ef87c2f261.

Tree-SHA512: 7bfd172aa4bbe349855c1303fd9cd58093d66833fefe46bd29081bfcca4ab434b84c6b84e76e94d06b8749a5abe1dc1e184f5189136cd1403d0e5bc25ad6d456
This commit is contained in:
Wladimir J. van der Laan 2020-07-27 13:56:58 +02:00 committed by pasta
parent 2353920662
commit 8f0192f3cf
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
2 changed files with 4 additions and 20 deletions

View File

@ -819,18 +819,6 @@ public:
return true; return true;
} }
bool Seek(uint64_t nPos) {
long nLongPos = nPos;
if (nPos != (uint64_t)nLongPos)
return false;
if (fseek(src, nLongPos, SEEK_SET))
return false;
nLongPos = ftell(src);
nSrcPos = nLongPos;
nReadPos = nLongPos;
return true;
}
//! prevent reading beyond a certain position //! prevent reading beyond a certain position
//! no argument removes the limit //! no argument removes the limit
bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) { bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) {

View File

@ -31,7 +31,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
if (opt_buffered_file && fuzzed_file != nullptr) { if (opt_buffered_file && fuzzed_file != nullptr) {
bool setpos_fail = false; bool setpos_fail = false;
while (fuzzed_data_provider.ConsumeBool()) { while (fuzzed_data_provider.ConsumeBool()) {
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 5)) { switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 4)) {
case 0: { case 0: {
std::array<uint8_t, 4096> arr{}; std::array<uint8_t, 4096> arr{};
try { try {
@ -41,20 +41,16 @@ void test_one_input(const std::vector<uint8_t>& buffer)
break; break;
} }
case 1: { case 1: {
opt_buffered_file->Seek(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
break;
}
case 2: {
opt_buffered_file->SetLimit(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096)); opt_buffered_file->SetLimit(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
break; break;
} }
case 3: { case 2: {
if (!opt_buffered_file->SetPos(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096))) { if (!opt_buffered_file->SetPos(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096))) {
setpos_fail = true; setpos_fail = true;
} }
break; break;
} }
case 4: { case 3: {
if (setpos_fail) { if (setpos_fail) {
// Calling FindByte(...) after a failed SetPos(...) call may result in an infinite loop. // Calling FindByte(...) after a failed SetPos(...) call may result in an infinite loop.
break; break;
@ -65,7 +61,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
} }
break; break;
} }
case 5: { case 4: {
ReadFromStream(fuzzed_data_provider, *opt_buffered_file); ReadFromStream(fuzzed_data_provider, *opt_buffered_file);
break; break;
} }