From e3c2501313d98ff9f4519116e6d2f36314e0240e Mon Sep 17 00:00:00 2001 From: ManikandanC Date: Tue, 18 Oct 2016 15:43:44 +0530 Subject: UnitTest: Updates Gateway Logstorage Event Handler Signed-off-by: Christoph Lipka Signed-off-by: S. Hameed Signed-off-by: Aditya Paluri Signed-off-by: Saya Sugiura Signed-off-by: ManikandanC --- src/daemon/dlt_daemon_client.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/daemon/dlt_daemon_client.c') diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 120d2af..55b775b 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -110,10 +110,9 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, int verbose) { int j, sent = 0; - DltConnection* temp = NULL; + DltConnection *temp = NULL; int type_mask = (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL); - char local_str[DLT_DAEMON_TEXTBUFSIZE]; uint8_t *tmp_buffer = NULL; if ((daemon == NULL) || (daemon_local == NULL)) @@ -144,13 +143,19 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, DLT_DAEMON_SEM_FREE(); if ((ret != DLT_DAEMON_ERROR_OK) && - DLT_CONNECTION_CLIENT_MSG_TCP == temp->type) + (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) { if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) { if (temp->receiver->bytes_sent < (size1 + size2)) { tmp_buffer = (uint8_t*)calloc(size1 + size2, sizeof(uint8_t)); + + if (tmp_buffer == NULL) + { + dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__); + return 0; + } memcpy(tmp_buffer, data1, size1); memcpy(tmp_buffer + size1, data2, size2); DLT_DAEMON_SEM_LOCK(); @@ -158,10 +163,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (dlt_buffer_push3(&(daemon->client_ringbuffer), tmp_buffer + temp->receiver->bytes_sent, (size1 + size2 - temp->receiver->bytes_sent), - 0, - 0, - 0, - 0) < DLT_RETURN_OK) + 0, 0, 0, 0) < DLT_RETURN_OK) { dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__); dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL); @@ -178,11 +180,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (ret != DLT_DAEMON_ERROR_OK) { - snprintf(local_str, - DLT_DAEMON_TEXTBUFSIZE, - "%s: send dlt message failed\n", - __func__); - dlt_log(LOG_WARNING, local_str); + dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__); } else { -- cgit v1.2.1