summaryrefslogtreecommitdiff
path: root/zen
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2019-05-12 22:44:22 +0000
committerDaniel Wilhelm <shieldwed@outlook.com>2019-05-12 22:44:22 +0000
commit2cb4599782d970f386a67dfd4f4dab0d531d4348 (patch)
treeb873b15f50a981aacf8bb49fd646bfded2e7a73b /zen
parentMerge branch '10.11' into 'master' (diff)
parent10.12 (diff)
downloadFreeFileSync-2cb4599782d970f386a67dfd4f4dab0d531d4348.tar.gz
FreeFileSync-2cb4599782d970f386a67dfd4f4dab0d531d4348.tar.bz2
FreeFileSync-2cb4599782d970f386a67dfd4f4dab0d531d4348.zip
Merge branch '10.12' into 'master'10.12
10.12 See merge request opensource-tracking/FreeFileSync!9
Diffstat (limited to 'zen')
-rw-r--r--zen/file_access.cpp4
-rw-r--r--zen/file_access.h1
-rw-r--r--zen/file_traverser.h2
-rw-r--r--zen/perf.h1
-rw-r--r--zen/recycler.h2
-rw-r--r--zen/ring_buffer.h2
-rw-r--r--zen/scope_guard.h10
-rw-r--r--zen/shell_execute.h7
-rw-r--r--zen/shutdown.cpp4
-rw-r--r--zen/shutdown.h2
-rw-r--r--zen/socket.h2
-rw-r--r--zen/utf.h2
-rw-r--r--zen/zlib_wrap.cpp3
-rw-r--r--zen/zstring.cpp9
-rw-r--r--zen/zstring.h6
15 files changed, 29 insertions, 28 deletions
diff --git a/zen/file_access.cpp b/zen/file_access.cpp
index 4536ec36..8ac9eb3b 100644
--- a/zen/file_access.cpp
+++ b/zen/file_access.cpp
@@ -453,7 +453,7 @@ void copySecurityContext(const Zstring& source, const Zstring& target, ProcSymli
{
security_context_t contextSource = nullptr;
const int rv = procSl == ProcSymlink::FOLLOW ?
- ::getfilecon(source.c_str(), &contextSource) :
+ ::getfilecon (source.c_str(), &contextSource) :
::lgetfilecon(source.c_str(), &contextSource);
if (rv < 0)
{
@@ -715,3 +715,5 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target
return result;
}
+
+
diff --git a/zen/file_access.h b/zen/file_access.h
index fc4b5833..8fdbde68 100644
--- a/zen/file_access.h
+++ b/zen/file_access.h
@@ -96,6 +96,7 @@ struct FileCopyResult
FileCopyResult copyNewFile(const Zstring& sourceFile, const Zstring& targetFile, bool copyFilePermissions, //throw FileError, ErrorTargetExisting, ErrorFileLocked, X
//accummulated delta != file size! consider ADS, sparse, compressed files
const IOCallback& notifyUnbufferedIO /*throw X*/);
+
}
#endif //FILE_ACCESS_H_8017341345614857
diff --git a/zen/file_traverser.h b/zen/file_traverser.h
index 5c1683f8..e49219f9 100644
--- a/zen/file_traverser.h
+++ b/zen/file_traverser.h
@@ -18,7 +18,7 @@ struct FileInfo
{
Zstring itemName;
Zstring fullPath;
- uint64_t fileSize; //[bytes]
+ uint64_t fileSize = 0; //[bytes]
time_t modTime = 0; //number of seconds since Jan. 1st 1970 UTC
};
diff --git a/zen/perf.h b/zen/perf.h
index 77251f8c..b6cb5bb0 100644
--- a/zen/perf.h
+++ b/zen/perf.h
@@ -28,7 +28,6 @@
namespace zen
{
-
//issue with wxStopWatch? https://freefilesync.org/forum/viewtopic.php?t=1426
// => wxStopWatch implementation uses QueryPerformanceCounter: https://github.com/wxWidgets/wxWidgets/blob/17d72a48ffd4d8ff42eed070ac48ee2de50ceabd/src/common/stopwatch.cpp
// => whatever the problem was, it's almost certainly not caused by QueryPerformanceCounter():
diff --git a/zen/recycler.h b/zen/recycler.h
index 0e5ebbb1..ad96aa53 100644
--- a/zen/recycler.h
+++ b/zen/recycler.h
@@ -21,7 +21,7 @@ namespace zen
Windows
-------
--> Recycler API always available: during runtime either SHFileOperation or IFileOperation (since Vista) will be dynamically selected
+-> Recycler API (IFileOperation) always available
-> COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize
Linux
diff --git a/zen/ring_buffer.h b/zen/ring_buffer.h
index e3dbd55f..8cce8e80 100644
--- a/zen/ring_buffer.h
+++ b/zen/ring_buffer.h
@@ -182,7 +182,7 @@ public:
Iterator(Container& container, size_t offset) : container_(&container), offset_(offset) {}
Iterator& operator++() { ++offset_; return *this; }
- Iterator& operator+=(ptrdiff_t offset) { offset_ += offset; }
+ Iterator& operator+=(ptrdiff_t offset) { offset_ += offset; return *this; }
inline friend bool operator==(const Iterator& lhs, const Iterator& rhs) { assert(lhs.container_ == rhs.container_); return lhs.offset_ == rhs.offset_; }
inline friend bool operator!=(const Iterator& lhs, const Iterator& rhs) { return !(lhs == rhs); }
inline friend ptrdiff_t operator-(const Iterator& lhs, const Iterator& rhs) { return lhs.offset_ - rhs.offset_; }
diff --git a/zen/scope_guard.h b/zen/scope_guard.h
index 9eff6c1f..3a79d841 100644
--- a/zen/scope_guard.h
+++ b/zen/scope_guard.h
@@ -38,7 +38,7 @@ enum class ScopeGuardRunMode
//partially specialize scope guard destructor code and get rid of those pesky MSVC "4127 conditional expression is constant"
template <typename F> inline
-void runScopeGuardDestructor(F& fun, int /*exeptionCountOld*/, std::integral_constant<ScopeGuardRunMode, ScopeGuardRunMode::ON_EXIT>)
+void runScopeGuardDestructor(F& fun, int /*exeptionCountOld*/, std::integral_constant<ScopeGuardRunMode, ScopeGuardRunMode::ON_EXIT>) noexcept
{
try { fun(); }
catch (...) { assert(false); } //consistency: don't expect exceptions for ON_EXIT even if "!failed"!
@@ -55,7 +55,7 @@ void runScopeGuardDestructor(F& fun, int exeptionCountOld, std::integral_constan
template <typename F> inline
-void runScopeGuardDestructor(F& fun, int exeptionCountOld, std::integral_constant<ScopeGuardRunMode, ScopeGuardRunMode::ON_FAIL>)
+void runScopeGuardDestructor(F& fun, int exeptionCountOld, std::integral_constant<ScopeGuardRunMode, ScopeGuardRunMode::ON_FAIL>) noexcept
{
const bool failed = std::uncaught_exceptions() > exeptionCountOld;
if (failed)
@@ -104,8 +104,8 @@ auto makeGuard(F&& fun) { return ScopeGuard<runMode, std::decay_t<F>>(std::forwa
#define ZEN_CHECK_CASE_FOR_CONSTANT_IMPL(X) L ## X
-#define ZEN_ON_SCOPE_EXIT(X) auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_EXIT >([&]{ X; }); (void)ZEN_CONCAT(scopeGuard, __LINE__);
-#define ZEN_ON_SCOPE_FAIL(X) auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_FAIL >([&]{ X; }); (void)ZEN_CONCAT(scopeGuard, __LINE__);
-#define ZEN_ON_SCOPE_SUCCESS(X) auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_SUCCESS>([&]{ X; }); (void)ZEN_CONCAT(scopeGuard, __LINE__);
+#define ZEN_ON_SCOPE_EXIT(X) [[maybe_unused]] auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_EXIT >([&]{ X; });
+#define ZEN_ON_SCOPE_FAIL(X) [[maybe_unused]] auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_FAIL >([&]{ X; });
+#define ZEN_ON_SCOPE_SUCCESS(X) [[maybe_unused]] auto ZEN_CONCAT(scopeGuard, __LINE__) = zen::makeGuard<zen::ScopeGuardRunMode::ON_SUCCESS>([&]{ X; });
#endif //SCOPE_GUARD_H_8971632487321434
diff --git a/zen/shell_execute.h b/zen/shell_execute.h
index 98824d70..19945a0b 100644
--- a/zen/shell_execute.h
+++ b/zen/shell_execute.h
@@ -27,7 +27,7 @@ namespace
{
-void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
+void shellExecute(const Zstring& command, ExecutionType type, bool hideConsole) //throw FileError
{
/*
we cannot use wxExecute due to various issues:
@@ -35,14 +35,13 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
- does not provide any reasonable error information
- uses a zero-sized dummy window as a hack to keep focus which leaves a useless empty icon in ALT-TAB list in Windows
*/
-
if (type == ExecutionType::SYNC)
{
//Posix ::system() - execute a shell command
const int rv = ::system(command.c_str()); //do NOT use std::system as its documentation says nothing about "WEXITSTATUS(rv)", etc...
if (rv == -1 || WEXITSTATUS(rv) == 127)
throw FileError(_("Incorrect command line:") + L"\n" + utfTo<std::wstring>(command));
- //http://linux.die.net/man/3/system "In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127)"
+ //http://linux.die.net/man/3/system "In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127)"
//Bonus: For an incorrect command line /bin/sh also returns with 127!
}
else
@@ -73,7 +72,7 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
inline
void openWithDefaultApplication(const Zstring& itemPath) //throw FileError
{
- shellExecute("xdg-open \"" + itemPath + '"', ExecutionType::ASYNC); //
+ shellExecute("xdg-open \"" + itemPath + '"', ExecutionType::ASYNC, false/*hideConsole*/); //
}
}
diff --git a/zen/shutdown.cpp b/zen/shutdown.cpp
index aecd4121..4fc687d6 100644
--- a/zen/shutdown.cpp
+++ b/zen/shutdown.cpp
@@ -18,7 +18,7 @@ void zen::shutdownSystem() //throw FileError
//https://linux.die.net/man/2/reboot => needs admin rights!
//"systemctl" should work without admin rights:
- shellExecute("systemctl poweroff", ExecutionType::SYNC); //throw FileError
+ shellExecute("systemctl poweroff", ExecutionType::SYNC, false/*hideConsole*/); //throw FileError
}
@@ -26,7 +26,7 @@ void zen::shutdownSystem() //throw FileError
void zen::suspendSystem() //throw FileError
{
//"systemctl" should work without admin rights:
- shellExecute("systemctl suspend", ExecutionType::SYNC); //throw FileError
+ shellExecute("systemctl suspend", ExecutionType::SYNC, false/*hideConsole*/); //throw FileError
}
diff --git a/zen/shutdown.h b/zen/shutdown.h
index 2d66d1e8..20354a14 100644
--- a/zen/shutdown.h
+++ b/zen/shutdown.h
@@ -14,7 +14,7 @@ namespace zen
{
void shutdownSystem(); //throw FileError
void suspendSystem(); //
-void terminateProcess(int exitCode); //will NOT return!
+[[noreturn]] void terminateProcess(int exitCode);
}
#endif //SHUTDOWN_H_3423847870238407783265
diff --git a/zen/socket.h b/zen/socket.h
index c77a4084..0b4c823d 100644
--- a/zen/socket.h
+++ b/zen/socket.h
@@ -46,7 +46,7 @@ public:
if (!servinfo)
throw SysError(L"getaddrinfo: empty server info");
- auto getConnectedSocket = [&](const auto& /*::addrinfo*/ ai)
+ const auto getConnectedSocket = [](const auto& /*::addrinfo*/ ai)
{
SocketType testSocket = ::socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol);
if (testSocket == invalidSocket)
diff --git a/zen/utf.h b/zen/utf.h
index 5a095874..37a866ab 100644
--- a/zen/utf.h
+++ b/zen/utf.h
@@ -180,7 +180,7 @@ size_t getUtf8Len(Char8 ch) //ch must be first code unit! returns 0 on error!
return 3;
if (ch >> 3 == 0x1e)
return 4;
- return 0; //innvalid begin of UTF8 encoding
+ return 0; //invalid begin of UTF8 encoding
}
diff --git a/zen/zlib_wrap.cpp b/zen/zlib_wrap.cpp
index 9eb4302f..ff5799c3 100644
--- a/zen/zlib_wrap.cpp
+++ b/zen/zlib_wrap.cpp
@@ -77,9 +77,8 @@ public:
~Impl()
{
- const int rv = ::deflateEnd(&gzipStream_);
+ [[maybe_unused]] const int rv = ::deflateEnd(&gzipStream_);
assert(rv == Z_OK);
- (void)rv;
}
size_t read(void* buffer, size_t bytesToRead) //throw ZlibInternalError, X; return "bytesToRead" bytes unless end of stream!
diff --git a/zen/zstring.cpp b/zen/zstring.cpp
index 62a0caef..3b33a21b 100644
--- a/zen/zstring.cpp
+++ b/zen/zstring.cpp
@@ -38,9 +38,8 @@ Zstring makeUpperCopy(const Zstring& str)
return output;
}
- catch (const SysError& e)
+ catch (SysError&)
{
- (void)e;
assert(false);
return str;
}
@@ -64,9 +63,8 @@ Zstring getUnicodeNormalForm(const Zstring& str)
return outStr;
}
- catch (const SysError& e)
+ catch (SysError&)
{
- (void)e;
assert(false);
return str;
}
@@ -102,7 +100,7 @@ Zstring replaceCpyAsciiNoCase(const Zstring& str, const Zstring& oldTerm, const
/*
-MSDN "Handling Sorting in Your Applications": https://msdn.microsoft.com/en-us/library/windows/desktop/dd318144
+https://docs.microsoft.com/de-de/windows/desktop/Intl/handling-sorting-in-your-applications
Perf test: compare strings 10 mio times; 64 bit build
-----------------------------------------------------
@@ -160,7 +158,6 @@ int compareNoCaseUtf8(const char* lhs, size_t lhsLen, const char* rhs, size_t rh
//unsigned underflow is well-defined!
}
}
-
}
diff --git a/zen/zstring.h b/zen/zstring.h
index 42487670..d5a8c29b 100644
--- a/zen/zstring.h
+++ b/zen/zstring.h
@@ -66,7 +66,7 @@ struct LessNativePath { bool operator()(const Zstring& lhs, const Zstring& rhs)
//------------------------------------------------------------------------------------------
int compareNatural(const Zstring& lhs, const Zstring& rhs);
-struct LessNaturalSort { bool operator()(const Zstring& lhs, const Zstring rhs) const { return compareNatural(lhs, rhs) < 0; } };
+struct LessNaturalSort { bool operator()(const Zstring& lhs, const Zstring& rhs) const { return compareNatural(lhs, rhs) < 0; } };
//------------------------------------------------------------------------------------------
@@ -148,4 +148,8 @@ const wchar_t MULT_SIGN = L'\u00D7'; //fancy "x"
//ZEN macro consistency checks:
+#if defined ZEN_WIN_PRE_VISTA || defined ZEN_WIN_VISTA_AND_LATER
+ #error these macros are obsolete!
+#endif
+
#endif //ZSTRING_H_73425873425789
bgstack15