From: Vitaliy Cherepanov Date: Fri, 7 Mar 2014 08:43:21 +0000 (+0400) Subject: [IMPROVE] add write_to_buf check result X-Git-Tag: Tizen_SDK_2.3~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0eb1b6a14e68fb32751aa62705133d95ab171f7a;p=platform%2Fcore%2Fsystem%2Fswap-manager.git [IMPROVE] add write_to_buf check result for all write_to_buf calls add LOGE messages on fail Change-Id: Iafeafa6411f149da7b79a1859f948928404e6f76 Signed-off-by: Vitaliy Cherepanov --- diff --git a/daemon/da_protocol.c b/daemon/da_protocol.c index abb7701..e3952b6 100644 --- a/daemon/da_protocol.c +++ b/daemon/da_protocol.c @@ -562,7 +562,8 @@ static int send_reply(struct msg_t *msg) static void write_msg_error(const char *err_str) { struct msg_data_t *err_msg = gen_message_error(err_str); - write_to_buf(err_msg); + if (write_to_buf(err_msg) != 0) + LOGE("write to buf fail\n"); free_msg_data(err_msg); } diff --git a/daemon/daemon.c b/daemon/daemon.c index af1490c..0e11fd4 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -325,7 +325,8 @@ static void terminate_error(char *errstr, int send_to_host) if (send_to_host != 0) { msg = gen_message_error(errstr); if (msg) { - write_to_buf(msg); + if (write_to_buf(msg) != 0) + LOGE("write to buf fail\n"); free_msg_data(msg); } else { LOGI("cannot generate error message\n"); diff --git a/daemon/input_events.c b/daemon/input_events.c index e382bee..0335837 100644 --- a/daemon/input_events.c +++ b/daemon/input_events.c @@ -189,7 +189,8 @@ static int deviceEventHandler(input_dev *dev, int input_type) input_type == INPUT_ID_KEY ? STR_KEY : STR_TOUCH); log = gen_message_event(in_ev, count, input_type); printBuf((char *)log, MSG_DATA_HDR_LEN + log->len); - write_to_buf(log); + if (write_to_buf(log) != 0) + LOGE("write to buf fail\n"); free_msg_data(log); } } else { diff --git a/daemon/threads.c b/daemon/threads.c index 23bb195..a3175f9 100644 --- a/daemon/threads.c +++ b/daemon/threads.c @@ -90,7 +90,8 @@ static void* recvThread(void* data) recvLen = recv(target->socket, (char *)msg + MSG_DATA_HDR_LEN, msg->len, MSG_WAITALL); - write_to_buf(msg); + if (write_to_buf(msg) != 0) + LOGE("write to buf fail\n"); free(msg); continue; } @@ -156,7 +157,8 @@ static void* recvThread(void* data) fill_data_msg_head(msg, NMSG_TERMINATE, 0, sizeof(uint32_t)); *(uint32_t *) msg->payload = (uint32_t) target->pid; - write_to_buf(msg); + if (write_to_buf(msg) != 0) + LOGE("write to buf fail\n"); free(msg); break; } else if (log.type == MSG_MSG) { @@ -263,7 +265,8 @@ static void *samplingThread(void *data) continue; } - write_to_buf(msg); + if (write_to_buf(msg) != 0) + LOGE("write to buf fail\n"); printBuf((char *)msg, MSG_DATA_HDR_LEN + msg->len);