From: Michal Bloch Date: Mon, 6 Jul 2020 11:35:29 +0000 (+0200) Subject: dlog_logger: clear internal buffers properly X-Git-Tag: accepted/tizen/unified/20200723.161228~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36788432cfa7a9adbc8776f19f8a61b665b4cb21;p=platform%2Fcore%2Fsystem%2Fdlog.git dlog_logger: clear internal buffers properly Change-Id: I3f96812b1387f96f48055d01f951f7254e98e643 Signed-off-by: Michal Bloch --- diff --git a/src/logger/logger.c b/src/logger/logger.c index ccaa82d..38e43fa 100644 --- a/src/logger/logger.c +++ b/src/logger/logger.c @@ -1286,13 +1286,6 @@ static int service_writer_handle_req_util(struct logger* server, struct writer* if (r < 0) return r; - assert(wr); - if (wr->readed > msg->length) { - wr->readed -= msg->length; - memmove(wr->buffer, wr->buffer + msg->length, wr->readed); - } else - wr->readed = 0; - return 0; } @@ -1348,12 +1341,6 @@ static int service_writer_handle_req_clear(struct logger* server, struct writer* log_storage_clear(wr->buf_ptr->log_storage); - if (wr->readed > msg->length) { - wr->readed -= msg->length; - memmove(wr->buffer, wr->buffer + msg->length, wr->readed); - } else - wr->readed = 0; - return 0; } @@ -1367,20 +1354,27 @@ static int service_writer_handle_req_clear(struct logger* server, struct writer* */ static int service_writer_handle_req_ctrl(struct logger *server, struct writer *wr, struct dlog_control_msg *msg) { + assert(server); + assert(wr); assert(msg); + int ret; switch (msg->request) { - case DLOG_REQ_CLEAR: - return service_writer_handle_req_clear(server, wr, msg); - case DLOG_REQ_HANDLE_LOGUTIL: - return service_writer_handle_req_util(server, wr, msg); - case DLOG_REQ_GET_CAPACITY: - return service_writer_handle_req_get_capacity(server, wr, msg); - case DLOG_REQ_GET_USAGE: - return service_writer_handle_req_get_usage(server, wr, msg); - default: - return -EINVAL; + case DLOG_REQ_CLEAR: ret = service_writer_handle_req_clear (server, wr, msg); break; + case DLOG_REQ_HANDLE_LOGUTIL: ret = service_writer_handle_req_util (server, wr, msg); break; + case DLOG_REQ_GET_CAPACITY: ret = service_writer_handle_req_get_capacity(server, wr, msg); break; + case DLOG_REQ_GET_USAGE: ret = service_writer_handle_req_get_usage (server, wr, msg); break; + + default: ret = -EINVAL; } + + if (wr->readed > msg->length) { + wr->readed -= msg->length; + memmove(wr->buffer, wr->buffer + msg->length, wr->readed); + } else + wr->readed = 0; + + return ret; } /**