From d149ce8b84a37bb8654f7014bc8e4f229f106f72 Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Wed, 1 Jul 2009 23:57:02 +0000 Subject: Fix 15 coverity complaints. Most of the changes are cosmetic, but there is also a memory leak in CreateExpiredServer. BUG=none TEST=none Review URL: http://codereview.chromium.org/153001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19788 0039d316-1c4b-4281-b951-d872f2087c98 --- net/tools/dump_cache/dump_cache.cc | 14 +++++++------- net/tools/dump_cache/dump_files.cc | 16 ++++++++-------- net/tools/dump_cache/upgrade.cc | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'net/tools') diff --git a/net/tools/dump_cache/dump_cache.cc b/net/tools/dump_cache/dump_cache.cc index 8a58cf5..f14c7a9 100644 --- a/net/tools/dump_cache/dump_cache.cc +++ b/net/tools/dump_cache/dump_cache.cc @@ -25,11 +25,11 @@ enum Errors { TOOL_NOT_FOUND, }; -int GetMajorVersion(const std::wstring input_path); -int DumpContents(const std::wstring input_path); -int DumpHeaders(const std::wstring input_path); -int RunSlave(const std::wstring input_path, const std::wstring pipe_number); -int Upgrade(const std::wstring output_path, HANDLE pipe); +int GetMajorVersion(const std::wstring& input_path); +int DumpContents(const std::wstring& input_path); +int DumpHeaders(const std::wstring& input_path); +int RunSlave(const std::wstring& input_path, const std::wstring& pipe_number); +int Upgrade(const std::wstring& output_path, HANDLE pipe); HANDLE CreateServer(std::wstring* pipe_number); const char kUpgradeHelp[] = @@ -67,8 +67,8 @@ int Help() { } // Starts a new process, to generate the files. -int LaunchSlave(const CommandLine& command_line, const std::wstring pipe_number, - int version) { +int LaunchSlave(const CommandLine& command_line, + const std::wstring& pipe_number, int version) { // TODO(port): remove this string-munging hackery. std::wstring hacked_command_line = command_line.command_line_string(); const std::wstring old_exe(L"dump_cache.exe"); diff --git a/net/tools/dump_cache/dump_files.cc b/net/tools/dump_cache/dump_files.cc index 1d8555a..50db69a 100644 --- a/net/tools/dump_cache/dump_files.cc +++ b/net/tools/dump_cache/dump_files.cc @@ -23,7 +23,7 @@ const wchar_t kIndexName[] = L"index"; const wchar_t kDataPrefix[] = L"data_"; // Reads the |header_size| bytes from the beginning of file |name|. -bool ReadHeader(const std::wstring name, char* header, int header_size) { +bool ReadHeader(const std::wstring& name, char* header, int header_size) { net::FileStream file; file.Open(FilePath::FromWStringHack(name), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); @@ -40,7 +40,7 @@ bool ReadHeader(const std::wstring name, char* header, int header_size) { return true; } -int GetMajorVersionFromFile(const std::wstring name) { +int GetMajorVersionFromFile(const std::wstring& name) { disk_cache::IndexHeader header; if (!ReadHeader(name, reinterpret_cast(&header), sizeof(header))) return 0; @@ -49,7 +49,7 @@ int GetMajorVersionFromFile(const std::wstring name) { } // Dumps the contents of the Index-file header. -void DumpIndexHeader(const std::wstring name) { +void DumpIndexHeader(const std::wstring& name) { disk_cache::IndexHeader header; if (!ReadHeader(name, reinterpret_cast(&header), sizeof(header))) return; @@ -75,7 +75,7 @@ void DumpIndexHeader(const std::wstring name) { } // Dumps the contents of a block-file header. -void DumpBlockHeader(const std::wstring name) { +void DumpBlockHeader(const std::wstring& name) { disk_cache::BlockFileHeader header; if (!ReadHeader(name, reinterpret_cast(&header), sizeof(header))) return; @@ -105,7 +105,7 @@ void DumpBlockHeader(const std::wstring name) { // Simple class that interacts with the set of cache files. class CacheDumper { public: - explicit CacheDumper(const std::wstring path) + explicit CacheDumper(const std::wstring& path) : path_(path), block_files_(path), index_(NULL) {} bool Init(); @@ -251,7 +251,7 @@ void DumpRankings(const disk_cache::RankingsNode& rankings) { // ----------------------------------------------------------------------- -int GetMajorVersion(const std::wstring input_path) { +int GetMajorVersion(const std::wstring& input_path) { std::wstring index_name(input_path); file_util::AppendToPath(&index_name, kIndexName); @@ -273,7 +273,7 @@ int GetMajorVersion(const std::wstring input_path) { } // Dumps the headers of all files. -int DumpHeaders(const std::wstring input_path) { +int DumpHeaders(const std::wstring& input_path) { std::wstring index_name(input_path); file_util::AppendToPath(&index_name, kIndexName); DumpIndexHeader(index_name); @@ -291,7 +291,7 @@ int DumpHeaders(const std::wstring input_path) { } // Dumps all entries from the cache. -int DumpContents(const std::wstring input_path) { +int DumpContents(const std::wstring& input_path) { DumpHeaders(input_path); // We need a message loop, although we really don't run any task. diff --git a/net/tools/dump_cache/upgrade.cc b/net/tools/dump_cache/upgrade.cc index 6b4a2da..bf27c9d 100644 --- a/net/tools/dump_cache/upgrade.cc +++ b/net/tools/dump_cache/upgrade.cc @@ -23,7 +23,7 @@ const int kNumStreams = 4; #define DEBUGMSG(...) { printf(__VA_ARGS__); } #endif -HANDLE OpenServer(const std::wstring pipe_number) { +HANDLE OpenServer(const std::wstring& pipe_number) { std::wstring pipe_name(kPipePrefix); pipe_name.append(pipe_number); return CreateFile(pipe_name.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, @@ -760,7 +760,7 @@ HANDLE CreateServer(std::wstring* pipe_number) { } // This is the controller process for an upgrade operation. -int Upgrade(const std::wstring output_path, HANDLE pipe) { +int Upgrade(const std::wstring& output_path, HANDLE pipe) { MessageLoop loop(MessageLoop::TYPE_IO); disk_cache::BackendImpl cache(output_path); if (!cache.Init()) { @@ -779,7 +779,7 @@ int Upgrade(const std::wstring output_path, HANDLE pipe) { } // This process will only execute commands from the controller. -int RunSlave(const std::wstring input_path, const std::wstring pipe_number) { +int RunSlave(const std::wstring& input_path, const std::wstring& pipe_number) { MessageLoop loop(MessageLoop::TYPE_IO); ScopedHandle pipe(OpenServer(pipe_number)); -- cgit v1.1