ECS: removed unused code & added error handling 80/18680/1
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 28 Mar 2014 04:43:58 +0000 (13:43 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 28 Mar 2014 04:43:58 +0000 (13:43 +0900)
Change-Id: I5d3e738d12b993ebdc8760702b625a3c0094f532
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
tizen/src/debug_ch.c
tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_msg.c
tizen/src/hw/maru_virtio_evdi.c
tizen/src/hw/maru_virtio_nfc.c
tizen/src/hw/maru_virtio_sensor.c

index 32fb5f2..2451993 100644 (file)
@@ -313,6 +313,10 @@ static void debug_init(void)
         if(fseek(fp, 0, SEEK_SET) != 0) {
             fclose(fp);
             fprintf(stderr, "failed to fseek()\n");
+
+            if (tmp != NULL)
+                free(tmp);
+
             return;
         }
         const char* str = fgets(tmp, 1024, fp);
@@ -480,6 +484,7 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel,
         fprintf(stderr, "Can't open logfile: %s\n", log_path);
         /* commented out for prevent shutdown when log directory is removed on runtime. */
         //exit(1);
+        return -1;
     }
 
     ret_write = qemu_write_full(fd, buf_msg, ret);
index 87b5145..4162af9 100644 (file)
@@ -72,7 +72,6 @@
 #define COMMAND_TYPE_TETHERING  "tethering"
 
 #define MSG_TYPE_SENSOR         "sensor"
-#define MSG_TYPE_SENSOR_LEN     10
 #define MSG_TYPE_NFC            "nfc"
 #define MSG_TYPE_SIMUL_NFC      "simul_nfc"
 
index d1e624c..b9419b5 100644 (file)
@@ -265,7 +265,7 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg)
                 goto injector_send;
             }
             LOG("status : %s", data);
-            send_status_injector_ntf(MSG_TYPE_SENSOR, MSG_TYPE_SENSOR_LEN, action, data);
+            send_status_injector_ntf(MSG_TYPE_SENSOR, 6, action, data);
             ret = true;
             goto injector_req_success;
         } else {
@@ -472,20 +472,31 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg)
         } else {
             if (data != NULL) {
                 set_injector_data(data);
+            } else {
+                LOG("sensor set data is null");
             }
         }
         msgproc_device_ans(ccli, cmd, true);
     } else if (!strncmp(cmd, "Network", 7)) {
-        LOG(">>> Network msg: '%s'", data);
-        if(net_slirp_redir(data) < 0) {
-            LOG( "redirect [%s] fail \n", data);
+        if (data != NULL) {
+            LOG(">>> Network msg: '%s'", data);
+            if(net_slirp_redir(data) < 0) {
+                LOG( "redirect [%s] fail", data);
+            } else {
+                LOG("redirect [%s] success", data);
+            }
         } else {
-            LOG("redirect [%s] success\n", data);
+            LOG("Network redirection data is null.");
         }
     } else if (!strncmp(cmd, "HKeyboard", 8)) {
         if (group == MSG_GROUP_STATUS) {
             send_host_keyboard_ntf(mloop_evcmd_get_hostkbd_status());
         } else {
+            if (data == NULL) {
+                LOG("HKeyboard data is NULL");
+                return false;
+            }
+
             if (!strncmp(data, "1", 1)) {
                 is_on = 1;
             }
@@ -502,6 +513,11 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg)
         // TODO:
 #endif
 
+        if (data == NULL) {
+            LOG("gesture data is NULL");
+            return false;
+        }
+
         LOG("%s\n", data);
 
         char token[] = "#";
@@ -560,13 +576,9 @@ bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg)
         print_binary(data, datalen);
     }
 
-    if (data != NULL) {
-        send_to_nfc(ccli->client_id, ccli->client_type, data, msg->data.len);
-        g_free(data);
-        return true;
-    } else {
-        return false;
-    }
+    send_to_nfc(ccli->client_id, ccli->client_type, data, msg->data.len);
+    g_free(data);
+    return true;
 }
 
 bool ntf_to_injector(const char* data, const int len) {
index 0ff4fbc..ad2da18 100644 (file)
@@ -192,11 +192,6 @@ static void virtio_evdi_send(VirtIODevice *vdev, VirtQueue *vq)
 
         //INFO("<< virtqueue pop. index: %d, out_num : %d, in_num : %d\n", index,  elem.out_num, elem.in_num);
 
-        if (index == 0) {
-            INFO("<< virtqueue break\n");
-            break;
-        }
-
         //INFO("<< use=%d, iov_len = %d\n", _msg.use, elem.out_sg[0].iov_len);
 
         memset(&_msg, 0x00, sizeof(_msg));
index 8c2faa1..08c9a64 100644 (file)
@@ -175,11 +175,6 @@ static void virtio_nfc_send(VirtIODevice *vdev, VirtQueue *vq)
 
         INFO("<< virtqueue pop. index: %d, out_num : %d, in_num : %d\n", index,  elem.out_num, elem.in_num);
 
-        if (index == 0) {
-            INFO("<< virtqueue break\n");
-            break;
-        }
-
         INFO("<< iov_len = %d\n", elem.out_sg[0].iov_len);
 
         memset(&_msg, 0x00, sizeof(_msg));
index ee2c3a6..a700b61 100644 (file)
@@ -110,7 +110,7 @@ static void send_sensor_to_ecs(const char* data, enum sensor_types type)
     length = (unsigned short) buf_len;
     action = get_action(type);
 
-    memcpy(ecs_message, MESSAGE_TYPE_SENSOR, 10);
+    memcpy(ecs_message, MESSAGE_TYPE_SENSOR, 6);
     memcpy(ecs_message + 10, &length, sizeof(unsigned short));
     memcpy(ecs_message + 12, &group, sizeof(unsigned char));
     memcpy(ecs_message + 13, &action, sizeof(unsigned char));