Fix compilation under gcc 4.8
authorPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Fri, 17 Jan 2014 12:27:17 +0000 (13:27 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:25 +0000 (17:13 +0100)
[Issue#]        N/A
[Bug/Feature]   Security-server does not build under GCC 4.8
[Cause]         * monotonic_clock was renamed in gcc 4.7 to steady_clock
                * lack of header files
                * invalid use of lambda capture
[Solution]      N/A
[Verification]  Build, run tests

Change-Id: I0c9235131e082eb7d053f13be4ead9b1ff044f4a

src/server/service/password-file-buffer.cpp
src/server/service/password-file.cpp
src/server/service/password-file.h

index 6a3c3d5..d315aa3 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <fcntl.h>
 #include <string.h>
+#include <unistd.h>
 
 namespace SecurityServer
 {
index 2ec6bf6..bb918d8 100644 (file)
@@ -162,7 +162,7 @@ namespace SecurityServer
 
     void PasswordFile::resetTimer()
     {
-        m_retryTimerStart = std::chrono::monotonic_clock::now();
+        m_retryTimerStart = ClockType::now();
         m_retryTimerStart -= TimeDiff(RETRY_TIMEOUT);
     }
 
@@ -330,7 +330,7 @@ namespace SecurityServer
             } else {
                 m_passwordCurrent.reset(new SHA256Password(oldFormatPasswords.front().m_hash));
                 std::for_each(++oldFormatPasswords.begin(), oldFormatPasswords.end(),
-                        [&m_passwordHistory] (const OldPassword& pwd)
+                        [&] (const OldPassword& pwd)
                         {m_passwordHistory.push_back(IPasswordPtr(new SHA256Password(pwd.m_hash)));}
                         );
             }
@@ -485,7 +485,7 @@ namespace SecurityServer
 
     bool PasswordFile::isIgnorePeriod() const
     {
-        TimePoint retryTimerStop = std::chrono::monotonic_clock::now();
+        TimePoint retryTimerStop = ClockType::now();
         TimeDiff diff = retryTimerStop - m_retryTimerStart;
 
         m_retryTimerStart = retryTimerStop;
index e9f743b..59839cb 100644 (file)
@@ -90,8 +90,13 @@ namespace SecurityServer
         bool isHistoryActive() const;
 
     private:
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7))
+        typedef std::chrono::steady_clock ClockType;
+#else
+        typedef std::chrono::monotonic_clock ClockType;
+#endif
         typedef std::chrono::duration<double> TimeDiff;
-        typedef std::chrono::time_point<std::chrono::monotonic_clock, TimeDiff> TimePoint;
+        typedef std::chrono::time_point<ClockType, TimeDiff> TimePoint;
 
         void loadMemoryFromFile();
         bool tryLoadMemoryFromOldFormatFile();