From: sungwook79.park Date: Wed, 29 Jun 2016 07:56:28 +0000 (+0900) Subject: fix detected potential errors through static code analysis tool SVACE X-Git-Tag: submit/tizen/20160629.110623~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Finputdelegator.git;a=commitdiff_plain;h=d9a3622dcfbeef6778958109dea9fe8b062d3892 fix detected potential errors through static code analysis tool SVACE Change-Id: I3ab512aa3eb4d1c72447384f12dca9a425ff7138 Signed-off-by: sungwook79.park --- diff --git a/src/MicEffector.cpp b/src/MicEffector.cpp index 5c5bb1a..f12d1ff 100755 --- a/src/MicEffector.cpp +++ b/src/MicEffector.cpp @@ -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); } } diff --git a/src/SttFeedback.cpp b/src/SttFeedback.cpp index ffc16cc..1af1796 100755 --- a/src/SttFeedback.cpp +++ b/src/SttFeedback.cpp @@ -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); diff --git a/src/SttManager.cpp b/src/SttManager.cpp index 2ef1128..1be05a3 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -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)); diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index 32a7f4c..87d691f 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -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(); diff --git a/src/w-input-stt-tos.cpp b/src/w-input-stt-tos.cpp index 908038c..0fc51fa 100755 --- a/src/w-input-stt-tos.cpp +++ b/src/w-input-stt-tos.cpp @@ -327,7 +327,7 @@ std::string getFontStyle(const char *code) snprintf(strColor, 256, "", r, g, b, a); // ea_theme_font_get(code,&fontStyle,&fontSize); - +/* if (fontStyle) { snprintf(strFont, 256, "", 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"), " ","","",""); + snprintf(body_str, sizeof(body_str), gettext("LDS_IME_BODY_INFORMATION_PROVISION_AGREEMENT_P1_LEGALPHRASE_WC1"), " ","","",""); terms = tagging(std::string(body_str)); terms = replaceAll(terms , std::string("\n"), std::string("
")); 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);