fix build warnings 90/238790/1
authorYoungjae Shin <yj99.shin@samsung.com>
Fri, 17 Jul 2020 09:03:25 +0000 (18:03 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Fri, 17 Jul 2020 09:03:34 +0000 (18:03 +0900)
revise string APIs
change deprecated APIs(readdir_r, auto_ptr)

Change-Id: Iae8dd3ab61410ae889aa92ad7ace1fbb7cbe2b2f

13 files changed:
db-service/download-db-svc-main.cpp
oma-parser/oma-parser-common.c
oma-parser/oma-parser-dd1.c
src/download-mgr-downloadItem.cpp
src/download-mgr-downloadItem.h
src/download-mgr-history-db.cpp
src/download-mgr-item.cpp
src/download-mgr-item.h
src/download-mgr-notification.cpp
src/download-mgr-notification.h
src/download-mgr-util.cpp
src/download-mgr-viewItem.cpp
src/download-mgr-viewItem.h

index 2efe1d9..cc41148 100644 (file)
@@ -52,17 +52,17 @@ bool DownloadHistoryDB::openDB()
        DM_LOGV("");
        int ret = 0;
        if (historyDb == NULL) {
-               DM_LOGD("TRY to open [%s]", DBDATADIR"/"HISTORYDB);
-               if (sqlite3_open_v2(DBDATADIR"/"HISTORYDB, &historyDb,
+               DM_LOGD("TRY to open [%s]", DBDATADIR "/" HISTORYDB);
+               if (sqlite3_open_v2(DBDATADIR "/" HISTORYDB, &historyDb,
                                SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK) {
-                       DM_LOGD("[ERROR][%s][%s]", DBDATADIR"/"HISTORYDB,
+                       DM_LOGD("[ERROR][%s][%s]", DBDATADIR "/" HISTORYDB,
                                sqlite3_errmsg(historyDb));
 
                        int errorcode = sqlite3_errcode(historyDb);
                        closeDB();
                        if (errorcode == SQLITE_CORRUPT) {
-                               DM_LOGD("unlink [%s]", DBDATADIR"/"HISTORYDB);
-                               //unlink(DBDATADIR"/"HISTORYDB);
+                               DM_LOGD("unlink [%s]", DBDATADIR "/" HISTORYDB);
+                               //unlink(DBDATADIR "/" HISTORYDB);
                                errorcode = SQLITE_CANTOPEN;
                        }
 
@@ -95,9 +95,9 @@ void DownloadHistoryDB::closeDB()
 
 bool DownloadHistoryDB::loadSqlSchema(void)
 {
-       if (sqlite3_open_v2(DBDATADIR"/"HISTORYDB, &historyDb,
+       if (sqlite3_open_v2(DBDATADIR "/" HISTORYDB, &historyDb,
                                SQLITE_OPEN_READWRITE |SQLITE_OPEN_CREATE, NULL) != SQLITE_OK) {
-               DM_LOGD("[ERROR][%s][%s]", DBDATADIR"/"HISTORYDB,
+               DM_LOGD("[ERROR][%s][%s]", DBDATADIR "/" HISTORYDB,
                                sqlite3_errmsg(historyDb));
                closeDB();
                return false;
index f0de4bc..cf19b97 100644 (file)
@@ -192,11 +192,9 @@ char *op_com_utils_concat(char *source, char *substring)
        char *ret_str = NULL;
        size_t ret_str_len = strlen(source) + strlen(substring) + 1;
 
-       ret_str = (char*)calloc(1, ret_str_len);
-       if (OP_NULL != ret_str) {
-               strncpy(ret_str, source, strlen(source) + 1);
-               strncat(ret_str, substring, ret_str_len - strlen(ret_str) - 1);
-       }
+       ret_str = calloc(1, ret_str_len);
+       if (OP_NULL != ret_str)
+               snprintf(ret_str, ret_str_len, "%s%s", source, substring);
 
        return ret_str;
 }
index 16c23e4..e374433 100644 (file)
@@ -419,7 +419,7 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                strncat(dd_info->name, ch_str, OP_MAX_URI_LEN
                                                - strlen(dd_info->name) - 1);
                        } else if (strlen(ch_str) < OP_MAX_STR_LEN) {
-                               strncpy(dd_info->name, ch_str, strlen(ch_str) + 1);
+                               snprintf(dd_info->name, sizeof(dd_info->name), "%s",  ch_str);
                        }
 
                        OP_SLOG("dd_info->name:[%s]", dd_info->name);
@@ -448,12 +448,11 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->vendor = temp;
                                }
                        } else {
-                               dd_info->vendor = (char*)calloc(1, strlen(ch_str) + 1);
+                               dd_info->vendor = strdup(ch_str);
                                if (OP_NULL == dd_info->vendor) {
                                        app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->vendor, ch_str, strlen(ch_str) + 1);
                        }
 
                        OP_SLOG("dd_info->vendor:[%s]", dd_info->vendor);
@@ -471,14 +470,11 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->install_notify_uri = temp;
                                }
                        } else {
-                               dd_info->install_notify_uri = (char*)calloc(1, strlen(ch_str) + 1);
+                               dd_info->install_notify_uri = strdup(ch_str);
                                if (OP_NULL == dd_info->install_notify_uri) {
-                                       app_data->parseError
-                                               = OP_ERR_FAIL_TO_MEMALLOC;
+                                       app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->install_notify_uri,
-                                               (const char*)ch_str, strlen(ch_str) + 1);
                        }
                        OP_SLOG("dd_info->install_notify_uri:[%s]",
                                        dd_info->install_notify_uri);
@@ -495,15 +491,11 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->description = temp;
                                }
                        } else {
-                               dd_info->description = (char*)calloc(1, strlen(
-                                       ch_str) + 1);
+                               dd_info->description = strdup(ch_str);
                                if (OP_NULL == dd_info->description) {
-                                       app_data->parseError
-                                               = OP_ERR_FAIL_TO_MEMALLOC;
+                                       app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->description,
-                                               (const char*)ch_str, strlen(ch_str) + 1);
                        }
                        OP_SLOG("dd_info->description:[%s]",
                                        dd_info->description);
@@ -522,15 +514,11 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->midlet_info_url = temp;
                                }
                        } else {
-                               dd_info->midlet_info_url = (char*)calloc(1,
-                                               strlen(ch_str) + 1);
+                               dd_info->midlet_info_url = strdup(ch_str);
                                if (OP_NULL == dd_info->midlet_info_url) {
-                                       app_data->parseError
-                                                       = OP_ERR_FAIL_TO_MEMALLOC;
+                                       app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->midlet_info_url,
-                                               (const char*)ch_str, strlen(ch_str) + 1);
                        }
                        OP_SLOG("dd_info->midlet_info_url:[%s]",
                                        dd_info->midlet_info_url);
@@ -549,17 +537,12 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->icon_uri = temp;
                                }
                        } else {
-                               dd_info->icon_uri = (char*)calloc(1, strlen(
-                                               ch_str) + 1);
+                               dd_info->icon_uri = strdup(ch_str);
                                if (OP_NULL == dd_info->icon_uri) {
-                                       app_data->parseError
-                                                       = OP_ERR_FAIL_TO_MEMALLOC;
+                                       app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->icon_uri, (const char*)ch_str,
-                                               strlen(ch_str) + 1);
-                               OP_SLOG("dd_info->icon_uri:[%s]",
-                                               dd_info->icon_uri);
+                               OP_SLOG("dd_info->icon_uri:[%s]", dd_info->icon_uri);
                        }
                        break;
 
@@ -575,15 +558,11 @@ void op_libxml_characters_dd1(void *userData, const xmlChar *s, int len)
                                        dd_info->next_url = temp;
                                }
                        } else {
-                               dd_info->next_url = (char*)calloc(1, strlen(
-                                               ch_str) + 1);
+                               dd_info->next_url = strdup(ch_str);
                                if (OP_NULL == dd_info->next_url) {
-                                       app_data->parseError
-                                                       = OP_ERR_FAIL_TO_MEMALLOC;
+                                       app_data->parseError = OP_ERR_FAIL_TO_MEMALLOC;
                                        goto ERR;
                                }
-                               strncpy(dd_info->next_url, (const char*)ch_str,
-                                               strlen(ch_str) + 1);
                        }
 
                        OP_SLOG("dd_info->next_url:[%s]",
index 42deeb6..e0e7d74 100644 (file)
@@ -344,8 +344,8 @@ void CbData::updateCompletedItem()
                                /* When parsing dd is failed, if the install notify url is existed,
                                 *      it shoud send the result to the server*/
                                if (dd_info->install_notify_uri) {
-                                       auto_ptr<OmaItem> omaItem;
-                                       omaItem = auto_ptr<OmaItem> (new OmaItem(dd_info));
+                                       unique_ptr<OmaItem> omaItem;
+                                       omaItem = unique_ptr<OmaItem> (new OmaItem(dd_info));
                                        downloadItem->setOmaItem(omaItem);
                                        downloadItem->sendInstallNotification(906);
                                }
@@ -358,8 +358,8 @@ void CbData::updateCompletedItem()
                        downloadItem->setState(DL_ITEM::FAILED);
                        downloadItem->setErrorCode(ERROR::NOT_ENOUGH_MEMORY);
                        if (dd_info->install_notify_uri) {
-                               auto_ptr<OmaItem> omaItem;
-                               omaItem = auto_ptr<OmaItem> (new OmaItem(dd_info));
+                               unique_ptr<OmaItem> omaItem;
+                               omaItem = unique_ptr<OmaItem> (new OmaItem(dd_info));
                                downloadItem->setOmaItem(omaItem);
                                downloadItem->sendInstallNotification(901);
                        }
@@ -372,8 +372,8 @@ void CbData::updateCompletedItem()
                                downloadItem->setState(DL_ITEM::FAILED);
                                downloadItem->setErrorCode(ERROR::PARSING_FAIL);
                                if (dd_info->install_notify_uri) {
-                                       auto_ptr<OmaItem> omaItem;
-                                       omaItem = auto_ptr<OmaItem> (new OmaItem(dd_info));
+                                       unique_ptr<OmaItem> omaItem;
+                                       omaItem = unique_ptr<OmaItem> (new OmaItem(dd_info));
                                        downloadItem->setOmaItem(omaItem);
                                        downloadItem->sendInstallNotification(951);
                                }
@@ -388,8 +388,8 @@ void CbData::updateCompletedItem()
                                downloadItem->setContentName(name);
                        }
                        downloadItem->setFileSize(dd_info->size);
-                       auto_ptr<OmaItem> omaItem;
-                       omaItem = auto_ptr<OmaItem> (new OmaItem(dd_info));
+                       unique_ptr<OmaItem> omaItem;
+                       omaItem = unique_ptr<OmaItem> (new OmaItem(dd_info));
                        downloadItem->setOmaItem(omaItem);
                        /* for extracting title */
                        downloadItem->setReceivedFileSize(0);
@@ -552,7 +552,7 @@ DownloadItem::DownloadItem()
 {
 }
 
-DownloadItem::DownloadItem(auto_ptr<DownloadRequest> request)
+DownloadItem::DownloadItem(shared_ptr<DownloadRequest> request)
        : m_aptr_request(request)
        , m_download_id(-1)
        , m_state(DL_ITEM::IGNORE)
index 6da43d8..06f9762 100644 (file)
@@ -101,7 +101,7 @@ private:
 class DownloadItem {
 public:
        DownloadItem(); /* FIXME remove after cleanup ecore_pipe */
-       DownloadItem(auto_ptr<DownloadRequest> request);
+       DownloadItem(shared_ptr<DownloadRequest> request);
        ~DownloadItem();
 
        bool start(int id);
@@ -179,7 +179,7 @@ public:
        inline void deSubscribe(Observer *o) { if (o) m_subject.detach(o); }
 #ifdef _ENABLE_OMA_DOWNLOAD
        inline void setUrl(string url) { if (m_aptr_request.get()) m_aptr_request->setUrl(url); }
-       inline void setOmaItem(auto_ptr<OmaItem> item) { m_oma_item = item; }
+       inline void setOmaItem(unique_ptr<OmaItem> &item) { m_oma_item = move(item); }
        string getUserMessage(void);
        inline void sendInstallNotification(int status)
        {
@@ -242,9 +242,9 @@ public:
 #endif
 
 private:
-       auto_ptr<DownloadRequest> m_aptr_request;
+       shared_ptr<DownloadRequest> m_aptr_request;
 #ifdef _ENABLE_OMA_DOWNLOAD
-       auto_ptr<OmaItem> m_oma_item;
+       unique_ptr<OmaItem> m_oma_item;
 #endif
        Subject m_subject;
        int m_download_id;
index 3028ef5..0146b14 100644 (file)
@@ -41,17 +41,17 @@ bool DownloadHistoryDB::openDB()
        DM_LOGV("");
        int ret = 0;
        if (historyDb == NULL) {
-               DM_LOGD("TRY to open [%s]", DBDATADIR"/"HISTORYDB);
-               if (sqlite3_open_v2(DBDATADIR"/"HISTORYDB, &historyDb,
+               DM_LOGD("TRY to open [%s]", DBDATADIR "/" HISTORYDB);
+               if (sqlite3_open_v2(DBDATADIR "/" HISTORYDB, &historyDb,
                                SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK) {
-                       DM_LOGD("[ERROR][%s][%s]", DBDATADIR"/"HISTORYDB,
+                       DM_LOGD("[ERROR][%s][%s]", DBDATADIR "/" HISTORYDB,
                                sqlite3_errmsg(historyDb));
 
                        int errorcode = sqlite3_errcode(historyDb);
                        closeDB();
                        if (errorcode == SQLITE_CORRUPT) {
-                               DM_LOGD("unlink [%s]", DBDATADIR"/"HISTORYDB);
-                               unlink(DBDATADIR"/"HISTORYDB);
+                               DM_LOGD("unlink [%s]", DBDATADIR "/" HISTORYDB);
+                               unlink(DBDATADIR "/" HISTORYDB);
                                errorcode = SQLITE_CANTOPEN;
                        }
 
@@ -978,9 +978,9 @@ bool DownloadHistoryDB::clearData(void)
 
 bool DownloadHistoryDB::loadSqlSchema(void)
 {
-       if (sqlite3_open_v2(DBDATADIR"/"HISTORYDB, &historyDb,
+       if (sqlite3_open_v2(DBDATADIR "/" HISTORYDB, &historyDb,
                                SQLITE_OPEN_READWRITE |SQLITE_OPEN_CREATE, NULL) != SQLITE_OK) {
-               DM_LOGD("[ERROR][%s][%s]", DBDATADIR"/"HISTORYDB,
+               DM_LOGD("[ERROR][%s][%s]", DBDATADIR "/" HISTORYDB,
                                sqlite3_errmsg(historyDb));
                closeDB();
                return false;
index a0e24e2..613898c 100644 (file)
@@ -65,8 +65,8 @@ Item::Item(DownloadRequest &rRequest)
 {
        m_title = string();
        m_iconPath = DM_UNKNOWN_ICON_PATH;
-       m_aptr_request = auto_ptr<DownloadRequest>(new DownloadRequest(rRequest));
-       m_aptr_noti = auto_ptr<DownloadNoti>(new DownloadNoti(this));
+       m_aptr_request = shared_ptr<DownloadRequest>(new DownloadRequest(rRequest));
+       m_aptr_noti = shared_ptr<DownloadNoti>(new DownloadNoti(this));
 #ifdef _ENABLE_OMA_DOWNLOAD
        m_installNotifyUrl = string();
 #endif
@@ -200,11 +200,11 @@ void Item::downloadFromQueuedState()
 
 void Item::createSubscribeData() // autoptr's variable of this class.
 {
-       m_aptr_downloadObserver = auto_ptr<Observer>(
+       m_aptr_downloadObserver = shared_ptr<Observer>(
                new Observer(updateCBForDownloadObserver, this, "downloadItemObserver"));
-       m_aptr_netEventObserver = auto_ptr<Observer>(
+       m_aptr_netEventObserver = shared_ptr<Observer>(
                new Observer(netEventCBObserver, this, "netMgrObserver"));
-       m_aptr_downloadItem = auto_ptr<DownloadItem>(new DownloadItem(m_aptr_request));
+       m_aptr_downloadItem = shared_ptr<DownloadItem>(new DownloadItem(m_aptr_request));
        if (!m_aptr_downloadItem.get()) {
                DM_LOGE("Fail to create download item");
                return;
@@ -822,7 +822,7 @@ bool Item::retry()
        if (m_aptr_downloadItem.get()) {
                setState(ITEM::PREPARE_TO_RETRY);
                if (!m_aptr_noti.get()) {
-                       m_aptr_noti = auto_ptr<DownloadNoti>(new DownloadNoti(this));
+                       m_aptr_noti = shared_ptr<DownloadNoti>(new DownloadNoti(this));
                }
                notify();
                /* Donot delete db, just update db. */
index 4b315a3..6c36dc8 100644 (file)
@@ -245,14 +245,14 @@ private:
        void handleFinishedItem(void);
        void checkQueuedItem(void);
 
-       auto_ptr<DownloadRequest> m_aptr_request;
-       auto_ptr<DownloadItem> m_aptr_downloadItem;
-       auto_ptr<DownloadNoti> m_aptr_noti;
+       shared_ptr<DownloadRequest> m_aptr_request;
+       shared_ptr<DownloadItem> m_aptr_downloadItem;
+       shared_ptr<DownloadNoti> m_aptr_noti;
        FileUtility m_fileObj;
 
        Subject m_subjectForView;
-       auto_ptr<Observer> m_aptr_downloadObserver;
-       auto_ptr<Observer> m_aptr_netEventObserver;
+       shared_ptr<Observer> m_aptr_downloadObserver;
+       shared_ptr<Observer> m_aptr_netEventObserver;
 
 #ifdef _ENABLE_OMA_DOWNLOAD
        static Eina_Bool checkInstallNotifyCB(void *data);
index 3ec2073..29e480a 100644 (file)
@@ -28,7 +28,7 @@ DownloadNoti::DownloadNoti(Item *item)
        DM_LOGD("");
 
        if (item) {
-               m_aptr_observer = auto_ptr<Observer>(
+               m_aptr_observer = shared_ptr<Observer>(
                        new Observer(updateCB, this, "notiObserver"));
                item->subscribe(m_aptr_observer.get());
        }
index 9cf5b36..858c771 100644 (file)
@@ -49,7 +49,7 @@ private:
        void deleteNotiData(notification_h notiHandle);
        notification_h m_notiHandle;
        Item *m_item;
-       auto_ptr<Observer> m_aptr_observer;
+       shared_ptr<Observer> m_aptr_observer;
 };
 
 #endif//DOWNLOAD_MANAGER_NOTIFICATION_H
index 6b72456..2a5f313 100644 (file)
@@ -75,10 +75,8 @@ struct MimeTableType MimeTable[]={
 
 void FileUtility::cleanTempDir()
 {
-    struct dirent entry;
-    struct dirent *dirInfo = NULL;
-
        DIR *dir;
+       struct dirent *dirInfo = NULL;
        string filePath = string();
        string defTempPath = FileUtility::getDefaultPath(true);
 
@@ -88,7 +86,7 @@ void FileUtility::cleanTempDir()
                        DM_LOGE("Fail to call opendir");
                        return;
                } else {
-                   while (readdir_r(dir, &entry, &dirInfo) == 0 && dirInfo != NULL) {
+                   while (nullptr != (dirInfo = readdir(dir))) {
                                DM_SLOGD("%s", dirInfo->d_name);
                                if (0 == strncmp(dirInfo->d_name, ".", strlen(".")) ||
                                                0 == strncmp(dirInfo->d_name, "..", strlen("..")))
index ba7ec02..1d9fe6a 100644 (file)
@@ -37,7 +37,7 @@ ViewItem::ViewItem(Item *item)
 {
        // FIXME need to makes exchange subject?? not yet, but keep it in mind!
        if (item) {
-               m_aptr_observer = auto_ptr<Observer>(
+               m_aptr_observer = shared_ptr<Observer>(
                        new Observer(updateCB, this, "viewItemObserver"));
                item->subscribe(m_aptr_observer.get());
        }
index 748b249..fc3c051 100644 (file)
@@ -162,7 +162,7 @@ private:
        static void cancelBtnClickedCB(void *data, Evas_Object *obj,
                void *event_info);
 
-       auto_ptr<Observer> m_aptr_observer;
+       shared_ptr<Observer> m_aptr_observer;
        Item *m_item;
 
        static Elm_Genlist_Item_Class dldGenlistStyle;