fix coverity issues

This commit is contained in:
Arvid Norberg 2015-04-29 04:05:29 +00:00
parent 42120014d0
commit 8aa3c22796
3 changed files with 10 additions and 9 deletions

View File

@ -902,14 +902,10 @@ int save_file(std::string const& filename, std::vector<char>& v)
return -1;
int w = fwrite(&v[0], 1, v.size(), f);
if (w < 0)
{
fclose(f);
return -1;
}
if (w != int(v.size())) return -3;
fclose(f);
if (w < 0) return -1;
if (w != int(v.size())) return -3;
return 0;
}

View File

@ -1416,7 +1416,7 @@ namespace libtorrent {
};
int op = operation;
if (op < 0 || op > int(sizeof(operation_names)/sizeof(operation_names[0])))
if (op < 0 || op >= int(sizeof(operation_names)/sizeof(operation_names[0])))
op = 0;
char msg[600];

View File

@ -202,6 +202,7 @@ const char* const job_action_name[] =
"load_torrent",
"clear_piece",
"tick_storage",
"resolve_links"
};
#if TORRENT_USE_ASSERTS
@ -341,7 +342,11 @@ block_cache::block_cache(int block_size, io_service& ios
, m_write_cache_size(0)
, m_send_buffer_blocks(0)
, m_pinned_blocks(0)
{}
{
// make sure the job names array covers all the job IDs
TORRENT_ASSERT(sizeof(job_action_name)/sizeof(job_action_name[0])
== disk_io_job::num_job_ids);
}
// returns:
// -1: not in cache