diff --git a/src/cache.cc b/src/cache.cc index b6046cb6..46a44d36 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -36,7 +36,7 @@ std::unique_ptr LoadCachedIndex(IndexerConfig* config, const std::s optional LoadCachedFileContents(IndexerConfig* config, const std::string& filename) { if (!config->enableCacheRead) - return nullptr; + return nullopt; return ReadContent(GetCachedBaseFileName(config->cacheDirectory, filename) + ".txt"); } diff --git a/src/platform_linux.cc b/src/platform_linux.cc index 3cf0720f..1191b772 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -187,10 +187,6 @@ int64_t GetLastModificationTime(const std::string& absolute_path) { // See http://stackoverflow.com/q/13198627 void CopyFileTo(const std::string& dest, const std::string& source) { - char buf[4096]; - ssize_t nread; - int saved_errno; - int fd_from = open(source.c_str(), O_RDONLY); if (fd_from < 0) return; @@ -199,6 +195,8 @@ void CopyFileTo(const std::string& dest, const std::string& source) { if (fd_to < 0) goto out_error; + char buf[4096]; + ssize_t nread; while (nread = read(fd_from, buf, sizeof buf), nread > 0) { char *out_ptr = buf; ssize_t nwritten;