From 9332bfe2c9362ccdf86815e9ac142e6e281af4cd Mon Sep 17 00:00:00 2001 From: Jinhyung Choi Date: Fri, 28 Mar 2014 13:43:58 +0900 Subject: [PATCH] ECS: removed unused code & added error handling Change-Id: I5d3e738d12b993ebdc8760702b625a3c0094f532 Signed-off-by: Jinhyung Choi --- tizen/src/debug_ch.c | 5 +++++ tizen/src/ecs/ecs.h | 1 - tizen/src/ecs/ecs_msg.c | 36 ++++++++++++++++++++++++------------ tizen/src/hw/maru_virtio_evdi.c | 5 ----- tizen/src/hw/maru_virtio_nfc.c | 5 ----- tizen/src/hw/maru_virtio_sensor.c | 2 +- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/tizen/src/debug_ch.c b/tizen/src/debug_ch.c index 32fb5f2..2451993 100644 --- a/tizen/src/debug_ch.c +++ b/tizen/src/debug_ch.c @@ -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); diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h index 87b5145..4162af9 100644 --- a/tizen/src/ecs/ecs.h +++ b/tizen/src/ecs/ecs.h @@ -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" diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index d1e624c..b9419b5 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -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) { diff --git a/tizen/src/hw/maru_virtio_evdi.c b/tizen/src/hw/maru_virtio_evdi.c index 0ff4fbc..ad2da18 100644 --- a/tizen/src/hw/maru_virtio_evdi.c +++ b/tizen/src/hw/maru_virtio_evdi.c @@ -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)); diff --git a/tizen/src/hw/maru_virtio_nfc.c b/tizen/src/hw/maru_virtio_nfc.c index 8c2faa1..08c9a64 100644 --- a/tizen/src/hw/maru_virtio_nfc.c +++ b/tizen/src/hw/maru_virtio_nfc.c @@ -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)); diff --git a/tizen/src/hw/maru_virtio_sensor.c b/tizen/src/hw/maru_virtio_sensor.c index ee2c3a6..a700b61 100644 --- a/tizen/src/hw/maru_virtio_sensor.c +++ b/tizen/src/hw/maru_virtio_sensor.c @@ -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)); -- 2.7.4