From 2ce6da855a541ba36b74dda9bfe4cd295629c82a Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 25 Mar 2009 03:55:18 +0000 Subject: Makes gtest compile without warning with gcc 4.0.3 and -Wall -Wextra. git-svn-id: http://googletest.googlecode.com/svn/trunk@226 861a406c-534a-0410-8894-cb66d6ee9925 --- src/gtest-filepath.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/gtest-filepath.cc') diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc index 32fd3bc..d0cc5ff 100644 --- a/src/gtest-filepath.cc +++ b/src/gtest-filepath.cc @@ -33,6 +33,7 @@ #include #include +#include #ifdef _WIN32_WCE #include @@ -166,20 +167,19 @@ FilePath FilePath::ConcatPaths(const FilePath& directory, // Returns true if pathname describes something findable in the file-system, // either a file, directory, or whatever. bool FilePath::FileOrDirectoryExists() const { -#if GTEST_OS_WINDOWS #ifdef _WIN32_WCE LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str()); const DWORD attributes = GetFileAttributes(unicode); delete [] unicode; return attributes != kInvalidFileAttributes; -#else +#elif GTEST_OS_WINDOWS struct _stat file_stat = {}; return _stat(pathname_.c_str(), &file_stat) == 0; -#endif // _WIN32_WCE #else - struct stat file_stat = {}; + struct stat file_stat; + memset(&file_stat, 0, sizeof(file_stat)); return stat(pathname_.c_str(), &file_stat) == 0; -#endif // GTEST_OS_WINDOWS +#endif // _WIN32_WCE } // Returns true if pathname describes a directory in the file-system @@ -205,7 +205,8 @@ bool FilePath::DirectoryExists() const { (_S_IFDIR & file_stat.st_mode) != 0; #endif // _WIN32_WCE #else - struct stat file_stat = {}; + struct stat file_stat; + memset(&file_stat, 0, sizeof(file_stat)); result = stat(pathname_.c_str(), &file_stat) == 0 && S_ISDIR(file_stat.st_mode); #endif // GTEST_OS_WINDOWS -- cgit v1.2.3