Update code of system and text for reporting Klocwork.
authorHokwon Song <hokwon.song@samsung.com>
Tue, 1 Oct 2013 00:31:02 +0000 (09:31 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Tue, 1 Oct 2013 00:35:00 +0000 (09:35 +0900)
Change-Id: I7fae23062459e6f91b6189d98490166b16534d7f
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
12 files changed:
src/system-server/runtime/FSys_RuntimeInfo.cpp
src/system-server/setting/providers/FSys_SettingFontProvider.h
src/system-server/setting/providers/FSys_SettingNetworkProvider.cpp
src/system/FSys_PowerManagerImpl.cpp
src/system/FSys_RuntimeClient.cpp
src/system/FSys_RuntimeInfoImpl.cpp
src/system/FSys_SettingClient.cpp
src/system/FSys_SettingInfoImpl.cpp
src/system/FSys_SystemInfoImpl.cpp
src/system/FSys_SystemTimeImpl.cpp
src/text/FText_IcuEncodingCore.cpp
src/text/FText_Ucs2EncodingCore.cpp

index 1cb685d..efee27e 100644 (file)
@@ -113,10 +113,12 @@ _RuntimeInfo::GetDirectorySizeIteratively(const char* path)
        {
                return 0;
        }
-
+       SysLog(NID_SYS, "path %s", path);
        for (de = readdir(d); de != null; de = readdir(d))
        {
                char filePath[1024] = {0,};
+               int length = strlen(path) + strlen(de->d_name);
+               SysTryReturn(NID_SYS, length > 0 && length < 1023, 0, E_INVALID_ARG, "The file path is invalid");
                sprintf(filePath, "%s%s", path, de->d_name);
 
                if (lstat(filePath, &buf) == 0)
@@ -141,7 +143,6 @@ _RuntimeInfo::GetDirectorySizeIteratively(const char* path)
                                                        }
                                                }
                                                total_size += buf.st_size;
-
                                        }
                                        else
                                        {
index 57c6bdc..7bf632d 100644 (file)
@@ -34,8 +34,8 @@ class _SettingFontProvider
        : _ISettingProvider
 {
 public:
-       _SettingFontProvider();
-       ~_SettingFontProvider();
+       _SettingFontProvider(void);
+       virtual ~_SettingFontProvider(void);
 
 public:
        bool    HasKey(const Tizen::Base::String& key);
index 8b4219e..fbd36a5 100644 (file)
@@ -48,7 +48,6 @@ namespace Tizen { namespace System
 static const wchar_t* _NETWORK_FLIGHTMODE = L"http://tizen.org/setting/network.flight_mode";
 static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"http://tizen.org/setting/network.telephony.packet_service";
 static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"http://tizen.org/setting/network.telephony.roaming";
-static const wchar_t* _SYSTEM_TELEPHONY = L"http://tizen.org/feature/network.telephony";
 
 //Network Wi-Fi
 static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/setting/network.wifi";
@@ -60,9 +59,6 @@ static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"http://tizen.org/sett
 static const wchar_t* _USB_TETHERING = L"http://tizen.org/setting/usb.tethering"; //Especially, USB tethering is covered by this provider.
 static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/setting/network.wifi.direct";
 
-static const wchar_t* _SYSTEM_NETWORK_WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
-static const wchar_t* _SYSTEM_NETWORK_WIFI = L"http://tizen.org/feature/network.wifi";
-
 //Network Bluetooth
 static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/setting/network.bluetooth";
 static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"http://tizen.org/setting/network.bluetooth.tethering";
index 7066202..bcf55bd 100644 (file)
@@ -62,7 +62,6 @@ namespace Tizen { namespace System
 static const int _DEVICE_CPU = 1;
 static const int _DEVICE_POWER_LEVEL_ON = 1;
 static const int _DEVICE_POWER_LEVEL_OFF = 0;
-static const int _APPID_LENGTH = 10;
 static const int _DEACTIVATED_BRIGHTNESS_CONTROL = -1;
 static const float _BRIGHTNESS_RESOLUTION = 10.0;
 static const wchar_t* POWER_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.powermanager";
index 8f75f34..8ddb624 100644 (file)
@@ -42,11 +42,9 @@ using namespace Tizen::Io;
 namespace Tizen { namespace System
 {
 
-static const int _RUNTIME_GET_PARAM_TYPE = 1;
 static const wchar_t* _RUNTIME_SERVICE_ID = L"osp.sys.ipcserver.runtimeinfo";
 static const wchar_t* _RUNTIME_GET_SIZE = L"osp.system.command.runtime.get.size";
 static const wchar_t* _RUNTIME_RESULT_SUCCESS = L"osp.system.result.success";
-static const wchar_t* _RUNTIME_RESULT_SYSTEM = L"osp.system.result.system";
 
 _RuntimeClient* _RuntimeClient::__pRuntimeClient= null;
 
index f750706..9454f75 100644 (file)
@@ -378,10 +378,13 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
                return 0;
        }
 
-       char command[512] = {0,};
-       char fileName[512] = {0,};
+       char* pCommand = null;
+       char* pFileName = null;
+       int fileLength = 0;
+       int commandLength = 0;
        long long size = 0;
        int ret = 0;
+       FILE* pFile = null;
 
        Tizen::App::App* pApp = Tizen::App::App::GetInstance();
        if(pApp == null)
@@ -392,78 +395,57 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
        String appId(pApp->GetAppId());
        unique_ptr <char> appIdPath(_StringConverter::CopyToCharArrayN(appId));
 
-       ret = sprintf(fileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
-       if(ret < 1)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write file path.");
-               return 0;
-       }
-
-       ret = sprintf(command, "rm -rf %s", fileName);
-       if(ret < 1)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
-               return 0;
-       }
+       fileLength = strlen(appIdPath.get()) + 29;
+       pFileName = (char*)malloc(fileLength);
+       ret = sprintf(pFileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
+       SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write file path.");
 
-       ret = system(command);
+       commandLength = strlen(pFileName) + 8;
+       pCommand = (char*) malloc(commandLength);
+       ret = sprintf(pCommand, "rm -rf %s", pFileName);
+       SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write remove pCommand.");
 
+       ret = system(pCommand);
        if(ret == -1)
        {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
        }
+       free(pCommand);
+       pCommand = null;
 
-       ret = sprintf(command, "du -skb -P %s >> %s", path, fileName);
-       if(ret < 1)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write du command.");
-               return 0;
-       }
+       commandLength = strlen(pFileName) + strlen(path) + 16;
+       pCommand = (char*)malloc(commandLength);
+       ret = sprintf(pCommand, "du -skb -P %s >> %s", path, pFileName);
+       SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write du pCommand.");
 
-       ret = system(command);
-       if(ret == -1)
-       {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
-               return 0;
-       }
+       ret = system(pCommand);
+       SysTryCatch(NID_SYS, ret != -1, E_SYSTEM, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
 
-       FILE* pFile = null;
-       pFile = fopen(fileName, "r");
-       if(pFile == null)
-       {
-               return 0;
-       }
+       pFile = fopen(pFileName, "r");
+       SysTryCatch(NID_SYS, pFile != null, E_SYSTEM, E_SYSTEM, "It is failed to read file [%s].", pFileName);
 
        ret = fscanf(pFile, "%lld", &size);
-       if(ret < 1)
-       {
-               if(pFile != null)
-               {
-                       fclose(pFile);
-               }
+       SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to read file [%s].", pFileName);
 
-               return 0;
-       }
+       ret = sprintf(pCommand, "rm -rf %s", pFileName);
+       SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write remove pCommand.");
+
+       ret = system(pCommand);
+       SysTryCatch(NID_SYS, ret != -1, E_SYSTEM, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
 
-       if(pFile != null)
+CATCH:
+       if (pFileName)
        {
-               fclose(pFile);
+               free(pFileName);
        }
-
-       ret = sprintf(command, "rm -rf %s", fileName);
-       if(ret < 1)
+       if (pCommand)
        {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
-               return 0;
+               free(pFileName);
        }
-
-       ret = system(command);
-       if(ret == -1)
+       if (pFile)
        {
-               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+               fclose(pFile);
        }
-
-
        return size;
 }
 
index 4ac1a3a..f0a039f 100644 (file)
@@ -169,8 +169,6 @@ const static wchar_t* _SETTING_RESULT_SYSTEM = L"E_SYSTEM";
 
 _SettingClient* _SettingClient::__pSettingClient = null;
 
-int common_service = 1;
-
 void
 _SettingClient::InitSettingClient(void)
 {
index bc30c23..08eb519 100644 (file)
@@ -43,9 +43,6 @@ using namespace Tizen::Base::Utility;
 
 namespace Tizen { namespace System
 {
-//IDs for IPC
-static const int _SYSTEM_RESPONSE_DATA = 2;
-
 //Reserved key
 static const wchar_t* _SETTING_SCREEN_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper";
 static const wchar_t* _SETTING_SYSTEM_SOUND_VOLUME = L"SystemSoundVolume";
index 9d14647..5f9708f 100644 (file)
@@ -482,7 +482,6 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                        value = *pDuid;
 
-CATCH:
                        responseMessage.RemoveAll(true);
                }
        }
@@ -854,8 +853,6 @@ _SystemInfoImpl::GetImei(String& imei)
        SysTryReturn(NID_SYS, *pResult == _SYSTEM_RESULT_OK, r = E_SYSTEM, r, "It is failed to get IMEI value.");
 
        imei = *pImei;
-
-CATCH:
        responseMessage.RemoveAll(true);
 
        return r;
@@ -872,7 +869,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, String& value)
        SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " RegistryImpl construct is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue is failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue is failed, %ls", key.GetPointer());
 
        if(valStr == L"true" || valStr == L"false")
        {
@@ -897,8 +894,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed, %ls", key.GetPointer());
        r = Integer::Parse(valStr, value);
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, " Integer::Parse() is failed");
        return E_SUCCESS;
@@ -915,8 +911,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
 
        r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed, [%ls]", key.GetPointer());
        if(valStr == L"true")
        {
                value = true;
index 8377698..d59b4e7 100644 (file)
@@ -138,7 +138,7 @@ _SystemTimeImpl::SetCurrentTime(const DateTime& currentTime)
 
        ArrayList requestMessage;
        ArrayList responseMessage;
-       char datetime[32] = {0,};
+       char datetime[64] = {0,};
 
        LocaleManager localeManager;
        localeManager.Construct();
index c0cefb8..4f661e5 100644 (file)
@@ -30,11 +30,6 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 
-#define EXTRA_ENCODINGS_LENGTH 3
-static String extraEncodings[] = {
-"UCS4", "UCS4BE", "UCS4LE"
-};
-
 namespace Tizen { namespace Text
 {
 
index af9b1f2..ba3bea0 100644 (file)
 using namespace Tizen::Base;
 
 #define UCS2_BOM_SIZE 2
-#define SUPPORTED_ENCODINGS_LENGTH 3
-static String supportedEncodings[] = {
-"UCS2", "UCS2BE", "UCS2LE"
-};
 
 namespace Tizen { namespace Text
 {