Merge pull request #4381

4cb1d879 blockchain_blackball: s/return false;/return 0;/ (moneromooo-monero)
9bdc9109 blockchain_blackball: use %zu for size_t (moneromooo-monero)
db3db093 blockchain_blackball: use mdb_size_t where appropriate (moneromooo-monero)
b1f05f58 blockchain_blackball: error out on fgets error (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-09-14 22:22:43 +02:00
commit bb30a72367
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -558,7 +558,7 @@ static std::vector<output_data> get_spent_outputs(MDB_txn *txn)
int dbr = mdb_cursor_open(txn, dbi_spent, &cur); int dbr = mdb_cursor_open(txn, dbi_spent, &cur);
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open cursor for spent outputs: " + std::string(mdb_strerror(dbr))); CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open cursor for spent outputs: " + std::string(mdb_strerror(dbr)));
MDB_val k, v; MDB_val k, v;
uint64_t count = 0; mdb_size_t count = 0;
dbr = mdb_cursor_get(cur, &k, &v, MDB_FIRST); dbr = mdb_cursor_get(cur, &k, &v, MDB_FIRST);
if (dbr != MDB_NOTFOUND) if (dbr != MDB_NOTFOUND)
{ {
@ -898,7 +898,11 @@ static std::vector<std::pair<uint64_t, uint64_t>> load_outputs(const std::string
while (1) while (1)
{ {
char s[256]; char s[256];
fgets(s, sizeof(s), f); if (!fgets(s, sizeof(s), f))
{
MERROR("Error reading from " << filename << ": " << strerror(errno));
break;
}
if (feof(f)) if (feof(f))
break; break;
const size_t len = strlen(s); const size_t len = strlen(s);
@ -968,7 +972,7 @@ static bool export_spent_outputs(MDB_cursor *cur, const std::string &filename)
if (pending_offsets.size() == 1) if (pending_offsets.size() == 1)
fprintf(f, "%" PRIu64 "\n", pending_offsets.front()); fprintf(f, "%" PRIu64 "\n", pending_offsets.front());
else else
fprintf(f, "%" PRIu64 "*%" PRIu64 "\n", pending_offsets.front(), pending_offsets.size()); fprintf(f, "%" PRIu64 "*%zu\n", pending_offsets.front(), pending_offsets.size());
pending_offsets.clear(); pending_offsets.clear();
} }
if (pending_amount != amount) if (pending_amount != amount)
@ -983,7 +987,7 @@ static bool export_spent_outputs(MDB_cursor *cur, const std::string &filename)
if (pending_offsets.size() == 1) if (pending_offsets.size() == 1)
fprintf(f, "%" PRIu64 "\n", pending_offsets.front()); fprintf(f, "%" PRIu64 "\n", pending_offsets.front());
else else
fprintf(f, "%" PRIu64 "*%" PRIu64 "\n", pending_offsets.front(), pending_offsets.size()); fprintf(f, "%" PRIu64 "*%zu\n", pending_offsets.front(), pending_offsets.size());
pending_offsets.clear(); pending_offsets.clear();
} }
fclose(f); fclose(f);
@ -1396,7 +1400,7 @@ int main(int argc, char* argv[])
if (stop_requested) if (stop_requested)
{ {
MINFO("Stopping secondary passes. Secondary passes are not incremental, they will re-run fully."); MINFO("Stopping secondary passes. Secondary passes are not incremental, they will re-run fully.");
return false; return 0;
} }
} }
if (!blackballs.empty()) if (!blackballs.empty())