From ea1c84285c1f91984fa3fdbfb8475dc23a6d0da3 Mon Sep 17 00:00:00 2001 From: "jlmiller@webrtc.org" Date: Thu, 22 Jan 2015 17:44:19 +0000 Subject: [PATCH] Correct GetDriveType error handling. BUG=4020 R=brucedawson@google.com, juberti@webrtc.org, pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/36899005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8127 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/base/win32filesystem.cc | 23 ++++++++++++----------- webrtc/base/win32filesystem.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/webrtc/base/win32filesystem.cc b/webrtc/base/win32filesystem.cc index 73f8ef0cf..9ca4c996d 100644 --- a/webrtc/base/win32filesystem.cc +++ b/webrtc/base/win32filesystem.cc @@ -378,8 +378,9 @@ bool Win32Filesystem::GetAppTempFolder(Pathname* path) { return GetTemporaryFolder(*path, true, &filename); } -bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { - if (!freebytes) { +bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, + int64 *free_bytes) { + if (!free_bytes) { return false; } char drive[4]; @@ -398,24 +399,24 @@ bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { // TODO: Add method to Pathname to determine if the path is relative. // TODO: Add method to Pathname to convert a path to absolute. } - UINT driveType = ::GetDriveType(target_drive); - if ( (driveType & DRIVE_REMOTE) || (driveType & DRIVE_UNKNOWN) ) { - LOG(LS_VERBOSE) << " remove or unknown drive " << drive; + UINT drive_type = ::GetDriveType(target_drive); + if ((drive_type == DRIVE_REMOTE) || (drive_type == DRIVE_UNKNOWN)) { + LOG(LS_VERBOSE) << "Remote or unknown drive: " << drive; return false; } - int64 totalNumberOfBytes; // receives the number of bytes on disk - int64 totalNumberOfFreeBytes; // receives the free bytes on disk + int64 total_number_of_bytes; // receives the number of bytes on disk + int64 total_number_of_free_bytes; // receives the free bytes on disk // make sure things won't change in 64 bit machine // TODO replace with compile time assert ASSERT(sizeof(ULARGE_INTEGER) == sizeof(uint64)); //NOLINT if (::GetDiskFreeSpaceEx(target_drive, - (PULARGE_INTEGER)freebytes, - (PULARGE_INTEGER)&totalNumberOfBytes, - (PULARGE_INTEGER)&totalNumberOfFreeBytes)) { + (PULARGE_INTEGER)free_bytes, + (PULARGE_INTEGER)&total_number_of_bytes, + (PULARGE_INTEGER)&total_number_of_free_bytes)) { return true; } else { - LOG(LS_VERBOSE) << " GetDiskFreeSpaceEx returns error "; + LOG(LS_VERBOSE) << "GetDiskFreeSpaceEx returns error."; return false; } } diff --git a/webrtc/base/win32filesystem.h b/webrtc/base/win32filesystem.h index 3cd5373e3..0ae921843 100644 --- a/webrtc/base/win32filesystem.h +++ b/webrtc/base/win32filesystem.h @@ -91,7 +91,7 @@ class Win32Filesystem : public FilesystemInterface { // Get a temporary folder that is unique to the current user and application. virtual bool GetAppTempFolder(Pathname* path); - virtual bool GetDiskFreeSpace(const Pathname& path, int64 *freebytes); + virtual bool GetDiskFreeSpace(const Pathname& path, int64 *free_bytes); virtual Pathname GetCurrentDirectory(); };