Fix issues detected by static analysis tool 63/74763/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 15 Jun 2016 11:28:30 +0000 (20:28 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 15 Jun 2016 11:28:30 +0000 (20:28 +0900)
Change-Id: Iecb90d5f959f00c6f26d8df2384dd45b1ca83981

res/simple_debug.cpp
scl/gwes/efl/sclwindows-efl.cpp
scl/sclcontroller.cpp
scl/sclkeyfocushandler.cpp
scl/sclresourcecache.cpp
scl/scluibuilder.cpp
xml2binary/include/string_encoder.h
xmlresource/layout_parser.cpp

index 9831502..92b4f7e 100644 (file)
@@ -80,20 +80,18 @@ SclLog::log(enum LOG_LEVEL level, char* fmt, ...) {
      * log current time
      */
     time_t now;
-    struct tm *timenow = NULL;
+    struct tm timenow;
 
     time(&now);
-    localtime_r(&now, timenow);
+    localtime_r(&now, &timenow);
 
-    if (timenow) {
-        char buf[64] = { 0 };
-        asctime_r(timenow, buf);
+    char buf[64] = { 0 };
+    asctime_r(&timenow, buf);
 
-        fprintf(m_flog, "[ %s ] %s\n", log_message[level], buf);
-        fprintf(m_flog, "\t%s\n", str_log);
+    fprintf(m_flog, "[ %s ] %s\n", log_message[level], buf);
+    fprintf(m_flog, "\t%s\n", str_log);
 
-        fflush(m_flog);
-    }
+    fflush(m_flog);
 }
 
 void
index 7c43ff3..d7f73df 100644 (file)
@@ -511,12 +511,13 @@ CSCLWindowsImplEfl::show_window(const sclwindow window, sclboolean queue)
                     &format_return, &nitems_return, &bytes_after_return,
                     &data);
 
-            if (ret == Success) {
-                if ((type_return == XA_WINDOW) && (format_return == 32) && (data)) {
-                    app_window = *(Window *)data;
-                    if (data)
-                        XFree(data);
+            if (data) {
+                if (ret == Success) {
+                    if ((type_return == XA_WINDOW) && (format_return == 32) && (data)) {
+                        app_window = *(Window *)data;
+                    }
                 }
+                XFree(data);
             }
         }
 #endif
index f601c66..8cb53e2 100644 (file)
@@ -907,7 +907,7 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
                             SclPoint pos = {0, 0};
 
                             const SclLayout* layout = cache->get_cur_layout(window);
-                            if (layout) {
+                            if (utils && layout) {
                                 sclint scnWidth, scnHeight;
                                 utils->get_screen_resolution(&scnWidth, &scnHeight);
 
@@ -959,8 +959,10 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
         }
         if (ret) {
             context->set_cur_key_modifier(touch_id, KEY_MODIFIER_LONGKEY);
-            if (coordinate->button_type & BUTTON_TYPE_MULTITAP) {
-                button_context->multitap_index = 0;
+            if (coordinate && button_context) {
+                if (coordinate->button_type & BUTTON_TYPE_MULTITAP) {
+                    button_context->multitap_index = 0;
+                }
             }
         }
     }
index fd864bd..032efed 100644 (file)
@@ -137,7 +137,7 @@ CSCLKeyFocusHandler::popup_closed(sclwindow window)
         scl_check_arrindex(layout, MAX_SCL_LAYOUT) && scl_check_arrindex(m_focus_key, MAX_KEY)) {
             SclLayoutKeyCoordinatePointer cur = sclres_layout_key_coordinate_pointer_frame[layout][m_focus_key];
             SclWindowContext *window_context = windows->get_window_context(m_focus_window);
-            SclRectangle cur_key_coordinate;
+            SclRectangle cur_key_coordinate = {0, 0, 0, 0};
             if (window_context) {
                 cur_key_coordinate.x = cur->x + window_context->geometry.x;
                 cur_key_coordinate.y = cur->y + window_context->geometry.y;
@@ -416,6 +416,9 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
     CSCLEventHandler *handler = CSCLEventHandler::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
     SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+
+    if (!context || !windows || !handler || !cache || !sclres_manager) return;
+
     sclshort layout = NOT_USED;
 
     sclwindow prev_window = m_focus_window;
@@ -441,7 +444,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
 
         /* To compare with buttons in popup window, let's convert to global coordinates */
         SclWindowContext *window_context = windows->get_window_context(m_focus_window);
-        SclRectangle cur_key_coordinate;
+        SclRectangle cur_key_coordinate = {0, 0, 0, 0};
         if (window_context && cur && cache) {
             cur_key_coordinate.x = cur->x + window_context->geometry.x;
             cur_key_coordinate.y = cur->y + window_context->geometry.y;
@@ -513,7 +516,7 @@ CSCLKeyFocusHandler::process_navigation(SCLHighlightNavigationDirection directio
             SclWindowContext *base_window_context = windows->get_window_context(windows->get_base_window());
             SclWindowContext *popup_window_context = windows->get_window_context(popup_window);
 
-            SclRectangle base_key_coordinate;
+            SclRectangle base_key_coordinate = {0, 0, 0, 0};
             if (base_window_context) {
                 base_key_coordinate.x = base_key->x + base_window_context->geometry.x;
                 base_key_coordinate.y = base_key->y + base_window_context->geometry.y;
index 160684b..af31444 100644 (file)
@@ -1441,7 +1441,6 @@ CSCLResourceCache::clone_keyproperties(SclPrivateKeyProperties* priv, sclbyte in
 
     SCL_DEBUG();
     if (priv && sclres_layout_key_coordinate_pointer_frame) {
-        CSCLResourceCache *cache = CSCLResourceCache::get_instance();
         clear_privatekeyproperties(priv);
 
         /* gets the value of the previous key properties */
@@ -1458,7 +1457,10 @@ CSCLResourceCache::clone_keyproperties(SclPrivateKeyProperties* priv, sclbyte in
         scl_assert_return(keyCoordinate.valid == TRUE);
 
         /* Sets the default properties base on the properties values of the given context */
-        cache->copy_to_privatekeyproperties(&keyCoordinate, priv);
+        CSCLResourceCache *cache = CSCLResourceCache::get_instance();
+        if (cache) {
+            cache->copy_to_privatekeyproperties(&keyCoordinate, priv);
+        }
     }
 }
 
index 0d27b47..e920516 100644 (file)
@@ -961,6 +961,9 @@ CSCLUIBuilder::show_magnifier(const sclwindow window, scldrawctx draw_ctx)
     CSCLUtils *utils = CSCLUtils::get_instance();
     CSCLContext *context = CSCLContext::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
+
+    if (!utils || !context || !cache) return FALSE;
+
     sclwindow pressed_window = context->get_cur_pressed_window(context->get_last_touch_device_id());
     scl8 pressed_key = context->get_cur_pressed_key(context->get_last_touch_device_id());
 
index 52fb485..f7be516 100644 (file)
@@ -27,11 +27,11 @@ const int MAX_NUM_WIDTH = 4;
 class String_Encoder:public IString_Encoder{
     public:
         String_Encoder() {
-            m_file = NULL;
+            m_file.clear();
         }
 
         void set_path(const char* file) {
-            this->m_file = file;
+            m_file = file;
         }
 
         /* @ insert str to string vector */
@@ -56,13 +56,13 @@ class String_Encoder:public IString_Encoder{
         int encode() const {
             ResourceStorage storage;
             encode(storage);
-            storage.toFile(m_file);
+            storage.toFile(m_file.c_str());
             return storage.get_size();
         }
         int encode(int& offset) const {
             ResourceStorage storage;
             encode(storage);
-            storage.toFile(m_file, offset);
+            storage.toFile(m_file.c_str(), offset);
 
             return storage.get_size();
         }
@@ -82,6 +82,6 @@ class String_Encoder:public IString_Encoder{
 
     private:
         std::vector<std::string> m_vec_string;
-        const char* m_file;
+        std::string m_file;
 };
 #endif
index f9653e7..a39257b 100644 (file)
@@ -776,7 +776,7 @@ LayoutParserImpl::parsing_layout_row_node(
         SclLayoutKeyCoordinatePointer **cur_key) {
     assert(cur_node != NULL);
 
-    Row row;
+    Row row = {0};
     if (row_y) {
         set_default_row_value(&row, cur_rec_layout, *row_y);
     }
@@ -1127,14 +1127,16 @@ LayoutParserImpl::parsing_key_value_record_node(
                 for (int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
                     if ((shift_state == shift_loop || shift_state == -1)) {
                         xmlChar* key = xmlNodeGetContent(child_node);
-                        cur_rec->key_value[shift_loop][multichar_state] = (sclchar*)key;
-                        if (auto_upper) {
-                            if (xmlStrlen(key) == 1 && shift_loop != SCL_SHIFT_STATE_OFF) {
-                                /* Let's manipulate the string for auto_upper */
-                                *key = toupper(*(cur_rec->key_value[SCL_SHIFT_STATE_OFF][multichar_state]));
+                        if (key) {
+                            cur_rec->key_value[shift_loop][multichar_state] = (sclchar*)key;
+                            if (auto_upper) {
+                                if (xmlStrlen(key) == 1 && shift_loop != SCL_SHIFT_STATE_OFF) {
+                                    /* Let's manipulate the string for auto_upper */
+                                    *key = toupper(*(cur_rec->key_value[SCL_SHIFT_STATE_OFF][multichar_state]));
+                                }
                             }
+                            add_key_string(key);
                         }
-                        add_key_string(key);
                     }
                 }
             }