[Filesystem] Fix crash in filesystem_provider_deviced.cc on emulator 15/72315/2 accepted/tizen/common/20160601.134121 accepted/tizen/ivi/20160602.023054 accepted/tizen/mobile/20160602.023237 accepted/tizen/tv/20160602.022918 accepted/tizen/wearable/20160602.023000 submit/tizen/20160601.063935
authorJakub Skowron <j.skowron@samsung.com>
Tue, 31 May 2016 10:46:57 +0000 (12:46 +0200)
committerJakub Skowron <j.skowron@samsung.com>
Tue, 31 May 2016 11:55:37 +0000 (13:55 +0200)
When generating id from UUID out_of_range was thrown by std::stoul,
because long is too short (4 bytes on 32 bit simulator).
Changed id to be hash of UUID. Previously only first two fields
(6 bytes) were used.

[Verification]
tct-filesystem-tizen-tests automated and manual test pass 100%
tct-systeminfo-tizen-tests automated test pass 100%

Change-Id: Iaadaf21760c48eb540b206d3d029bd8b6d53841f
Signed-off-by: Jakub Skowron <j.skowron@samsung.com>
src/common/filesystem/filesystem_provider_deviced.cc

index 87e04a5..4f17cc6 100644 (file)
@@ -225,10 +225,7 @@ std::string FilesystemProviderDeviced::GetNameFromPath(
 
 int FilesystemProviderDeviced::GetIdFromUUID(const char* const char_uuid) {
   LoggerD("Entered");
-  std::string uuid = char_uuid;
-  size_t hyphen = uuid.find("-");
-  std::string clear_uuid = uuid.substr(0, hyphen) + uuid.substr(hyphen + 1);
-  return static_cast<unsigned int>(std::stoul(clear_uuid, nullptr, 16));
+  return (int)std::hash<std::string>()( std::string(char_uuid) );
 }
 
 Storages FilesystemProviderDeviced::GetStorages() {