Hotfix: build error fix on emul64 by sign-compare warning 00/62100/1 accepted/tizen/common/20160315.074317 accepted/tizen/ivi/20160314.100649 accepted/tizen/mobile/20160314.100557 accepted/tizen/tv/20160314.100615 accepted/tizen/wearable/20160314.100636 submit/tizen/20160314.094033
authorKyungwook Tak <k.tak@samsung.com>
Mon, 14 Mar 2016 09:32:00 +0000 (18:32 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 14 Mar 2016 09:32:00 +0000 (18:32 +0900)
Change-Id: I7e34b3e278db8d1da6f6949e0438a52030262e7d
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/server/service/policy-file.cpp

index f3c38d34629f8309667b7ae18282c1aed19b027f..3c96320fff234593d4f3a1a998dd73dc09454515 100644 (file)
@@ -24,6 +24,7 @@
 #include <policy-file.h>
 
 #include <fstream>
+#include <vector>
 #include <regex.h>
 
 #include <fcntl.h>
@@ -212,25 +213,20 @@ namespace AuthPasswd
         m_policy.minComplexCharNumber = minComplexCharNumber;
     }
 
-    // policy maxCharOccurrences
     bool PolicyFile::checkMaxCharOccurrences(const std::string &password) const
     {
-        unsigned int i = 0;
-        unsigned char ch;
-        char occurrence[256]= {0, };
+        std::vector<unsigned int> occurrence(256, 0);
 
         if (m_policy.maxCharOccurrences == 0)
             return true;
 
-        for (i = 0; i < password.size(); i++) {
-            ch = (unsigned char)password[i];
-            occurrence[ch]++;
-        }
+        for (auto ch : password)
+            occurrence[static_cast<unsigned char>(ch)]++;
 
-        for (i = 0; i<256; i++) {
-            if(occurrence[i] > m_policy.maxCharOccurrences)
+        for (auto item : occurrence)
+            if (item > m_policy.maxCharOccurrences)
                 return false;
-        }
+
         return true;
     }