fix detected potential errors through static code analysis tool SVACE 58/77258/1
authorsungwook79.park <sungwook79.park@samsung.com>
Wed, 29 Jun 2016 07:56:28 +0000 (16:56 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Wed, 29 Jun 2016 07:56:28 +0000 (16:56 +0900)
Change-Id: I3ab512aa3eb4d1c72447384f12dca9a425ff7138
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
src/MicEffector.cpp
src/SttFeedback.cpp
src/SttManager.cpp
src/w-input-emoticon.cpp
src/w-input-stt-tos.cpp

index 5c5bb1a..f12d1ff 100755 (executable)
@@ -409,7 +409,7 @@ void MicEffector::VolumeCheck(bool fake)
                volumes = ieffect.GetVolume();
        } else {
                for(unsigned int i = 0; i < spectrum_count; i++) {
-                       volumes.push_back(rand() % 2);
+                       volumes.push_back(rand_r((unsigned int*)time(NULL)) % 2);
                }
        }
 
index ffc16cc..1af1796 100755 (executable)
@@ -49,7 +49,7 @@ void SttFeedback::OnResult(
        // Partial result case : STT_RECOGNITION_TYPE_FREE_PARTIAL
        // Normal result case : STT_RECOGNITION_TYPE_FREE
 
-       if(results.size() < 0) {
+       if(results.size() < 1) {
                PRINTFUNC(DLOG_ERROR, "Result size : %d", results.size());
                vd.state = STT_STATE_VAL_NOT_RECOGNISED;
                set_animation_state(&vd);
index 2ef1128..1be05a3 100755 (executable)
@@ -123,17 +123,7 @@ void SttManager::Start() {
        */
        asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL;
        int ret;
-
-       bool bval = false;
-
-//     stt_is_samsung_asr(&bval);
-
-       if( bval == true && !language.compare("en_GB")) {
-               PRINTFUNC(DLOG_DEBUG, "en_GB requested, change to en_US");
-        ret = stt_start(handle, "en_US", asrtype.c_str());
-       } else {
         ret = stt_start(handle, language.c_str(), asrtype.c_str());
-       }
 
        if(ret != STT_ERROR_NONE)
                throw SttException(ret, ErrorString((stt_error_e)ret));
index 32a7f4c..87d691f 100755 (executable)
@@ -70,7 +70,7 @@ const char * get_emoticon_file_name(int index)
 
     int ipos = path.size()-9;
     char str_emoticon_code[10] = {0};
-    sprintf(str_emoticon_code, "%x", emoticon_info[index].code);
+    snprintf(str_emoticon_code, sizeof(str_emoticon_code), "%x", emoticon_info[index].code);
     path.erase(ipos, 5);
     path.insert(ipos, str_emoticon_code);
     return path.c_str();
index 908038c..0fc51fa 100755 (executable)
@@ -327,7 +327,7 @@ std::string getFontStyle(const char *code)
     snprintf(strColor, 256, "<color=#%02x%02x%02x%02x>", r, g, b, a);
 
 //    ea_theme_font_get(code,&fontStyle,&fontSize);
-
+/*
     if (fontStyle) {
         snprintf(strFont, 256, "<font=Tizen:style=%s><font_size=%d>", fontStyle, fontSize);
     } else {
@@ -341,6 +341,7 @@ std::string getFontStyle(const char *code)
         free(fontStyle);
         fontStyle = NULL;
     }
+*/
     return strRet;
 }
 
@@ -388,7 +389,7 @@ static void _language_changed_cb(void *_data, Evas_Object *_obj, void *_event_in
 
     switch (index) {
         case 1:
-            sprintf(body_str, gettext("LDS_IME_BODY_INFORMATION_PROVISION_AGREEMENT_P1_LEGALPHRASE_WC1"), " <a href=\"file://local-nuance-tos\">","</a>","<a href=\"http://www.vlingo.com/wap/samsung-asr-privacy-addendum\">","</a>");
+            snprintf(body_str, sizeof(body_str), gettext("LDS_IME_BODY_INFORMATION_PROVISION_AGREEMENT_P1_LEGALPHRASE_WC1"), " <a href=\"file://local-nuance-tos\">","</a>","<a href=\"http://www.vlingo.com/wap/samsung-asr-privacy-addendum\">","</a>");
             terms = tagging(std::string(body_str));
             terms = replaceAll(terms , std::string("\n"), std::string("<br>"));
             elm_entry_entry_set(elm_layout_content_get(_obj, "elm.swallow.content"), terms.c_str());
@@ -653,19 +654,19 @@ static void _n66_language_changed_cb(void *_data, Evas_Object *_obj, void *_even
     // 2. Set String ID depend on Count Code
     char* popup_title_id = NULL;
     char* popup_body_id = NULL;
-    if (country_code) {
-        if (!strcmp(country_code, "CN")) {
-            popup_title_id = TOS_TITLE_CHN;
-            popup_body_id = TOS_N66_BODY_CHN;
-        } else {
-            popup_title_id = TOS_TITLE;
-            popup_body_id = TOS_N66_BODY;
-        }
-    } else {
+//    if (country_code) {
+//        if (!strcmp(country_code, "CN")) {
+//            popup_title_id = TOS_TITLE_CHN;
+//            popup_body_id = TOS_N66_BODY_CHN;
+//        } else {
+//            popup_title_id = TOS_TITLE;
+//            popup_body_id = TOS_N66_BODY;
+//        }
+//    } else {
         PRINTFUNC(DLOG_ERROR, "Getting Count Code is Error!!! Set default TOS Text!");
         popup_title_id = TOS_TITLE;
         popup_body_id = TOS_N66_BODY;
-    }
+//    }
 
 //    ea_cutlink_h cutlink;
 //    ea_cutlink_create(&cutlink, entry, EA_CUTLINK_USER);
@@ -691,8 +692,8 @@ static void _n66_language_changed_cb(void *_data, Evas_Object *_obj, void *_even
     terms = tagging(std::string(gettext(txt)));
     elm_entry_entry_set(entry, terms.c_str());
 
-    if (txt)
-        free(txt);
+//    if (txt)
+//        free(txt);
 
     if (markup)
         free(markup);
@@ -726,19 +727,19 @@ Evas_Object *create_tos_n66_popup(void *data)
     // 2. Set String ID depend on Count Code
     char* popup_title_id = NULL;
     char* popup_body_id = NULL;
-    if (country_code) {
-        if (!strcmp(country_code, "CN")) {
-            popup_title_id = TOS_TITLE_CHN;
-            popup_body_id = TOS_N66_BODY_CHN;
-        } else {
-            popup_title_id = TOS_TITLE;
-            popup_body_id = TOS_N66_BODY;
-        }
-    } else {
+//    if (country_code) {
+//        if (!strcmp(country_code, "CN")) {
+//            popup_title_id = TOS_TITLE_CHN;
+//            popup_body_id = TOS_N66_BODY_CHN;
+//        } else {
+//            popup_title_id = TOS_TITLE;
+//            popup_body_id = TOS_N66_BODY;
+//        }
+//    } else {
         PRINTFUNC(DLOG_ERROR, "Getting Count Code is Error!!! Set default TOS Text!");
         popup_title_id = TOS_TITLE;
         popup_body_id = TOS_N66_BODY;
-    }
+//    }
 
 
 //------------outer layout----------------------
@@ -802,8 +803,8 @@ Evas_Object *create_tos_n66_popup(void *data)
     terms = tagging(std::string(gettext(txt)));
     elm_entry_entry_set(entry, terms.c_str());
 
-    if (txt)
-        free(txt);
+//    if (txt)
+//        free(txt);
 
     if (markup)
         free(markup);