diff options
author | Dinh Cong Toan <toan.dinhcong@vn.bosch.com> | 2021-05-25 16:28:21 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-06-30 10:54:59 +0900 |
commit | 1e7d374593ae34c5f1b343a213123d5385852fe7 (patch) | |
tree | 8df78ee5c1112874dc0d4d7c682ff559cbc2d04f | |
parent | 3bb7eb24092ff771ccfd1119f8c1088f3f78f981 (diff) | |
download | DLT-daemon-1e7d374593ae34c5f1b343a213123d5385852fe7.tar.gz |
dlt message header broken
This commit is to revert the following commits:
- de4a4234
- fb9ff078
- db9917b3
- e4467f0e
- a567e01d
Those commits are from improvement but they seem to
break the dlt message header in some cases.
Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
-rw-r--r-- | include/dlt/dlt_common.h | 24 | ||||
-rw-r--r-- | include/dlt/dlt_user.h.in | 2 | ||||
-rw-r--r-- | src/daemon/dlt-daemon.h | 2 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler.c | 8 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_offline_logstorage.c | 34 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_serial.c | 4 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_socket.c | 4 | ||||
-rw-r--r-- | src/examples/dlt-example-user.c | 6 | ||||
-rw-r--r-- | src/gateway/dlt_gateway.c | 40 | ||||
-rw-r--r-- | src/lib/dlt_env_ll.c | 6 | ||||
-rw-r--r-- | src/lib/dlt_filetransfer.c | 34 | ||||
-rw-r--r-- | src/offlinelogstorage/dlt_offline_logstorage.c | 64 | ||||
-rw-r--r-- | src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 68 | ||||
-rw-r--r-- | src/shared/dlt_common.c | 2 | ||||
-rw-r--r-- | src/shared/dlt_offline_trace.c | 12 | ||||
-rw-r--r-- | src/tests/dlt-test-stress-client.c | 2 |
17 files changed, 159 insertions, 159 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 049b6ee..7973ab1 100644 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -300,10 +300,10 @@ enum { # define DLT_MSG_READ_VALUE(dst, src, length, type) \ { \ - if ((length < 0) || ((length) < ((int32_t) sizeof(type)))) \ + if ((length < 0) || ((length) < ((int32_t)sizeof(type)))) \ { length = -1; } \ else \ - { dst = *((type *)src); src += sizeof(type); length -= (int32_t) sizeof(type); } \ + { dst = *((type *)src); src += sizeof(type); length -= sizeof(type); } \ } # define DLT_MSG_READ_ID(dst, src, length) \ @@ -322,7 +322,7 @@ enum { } \ else \ { \ - memcpy(dst, src, (size_t) length); \ + memcpy(dst, src, length); \ dlt_clean_string(dst, length); \ dst[length] = 0; \ src += length; \ @@ -500,14 +500,14 @@ typedef struct sDltMessage int32_t resync_offset; /* size parameters */ - uint32_t headersize; /**< size of complete header including storage header */ - uint32_t datasize; /**< size of complete payload */ + int32_t headersize; /**< size of complete header including storage header */ + int32_t datasize; /**< size of complete payload */ /* buffer for current loaded message */ uint8_t headerbuffer[sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltStandardHeaderExtra) + sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */ uint8_t *databuffer; /**< buffer for loading payload */ - uint32_t databuffersize; + int32_t databuffersize; /* header values of current loaded message */ DltStorageHeader *storageheader; /**< pointer to storage header of current loaded header */ @@ -778,12 +778,12 @@ typedef struct int32_t lastBytesRcvd; /**< bytes received in last receive call */ int32_t bytesRcvd; /**< received bytes */ int32_t totalBytesRcvd; /**< total number of received bytes */ - char *buffer; /**< pointer to receiver buffer */ - char *buf; /**< pointer to position within receiver buffer */ - char *backup_buf; /** pointer to the buffer with partial messages if any **/ - int fd; /**< connection handle */ + char *buffer; /**< pointer to receiver buffer */ + char *buf; /**< pointer to position within receiver buffer */ + char *backup_buf; /** pointer to the buffer with partial messages if any **/ + int fd; /**< connection handle */ DltReceiverType type; /**< type of connection handle */ - uint32_t buffersize; /**< size of receiver buffer */ + int32_t buffersize; /**< size of receiver buffer */ struct sockaddr_in addr; /**< socket address information */ } DltReceiver; @@ -1301,7 +1301,7 @@ DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader); * @param required size * @return negative value if required size is not sufficient * */ -DltReturnValue dlt_check_rcv_data_size(uint32_t received, uint32_t required); +DltReturnValue dlt_check_rcv_data_size(int received, int required); /** * Initialise static ringbuffer with a size of size. diff --git a/include/dlt/dlt_user.h.in b/include/dlt/dlt_user.h.in index 960b9f0..b4d508d 100644 --- a/include/dlt/dlt_user.h.in +++ b/include/dlt/dlt_user.h.in @@ -129,7 +129,7 @@ typedef struct { DltContext *handle; /**< pointer to DltContext */ unsigned char *buffer; /**< buffer for building log message*/ - size_t size; /**< payload size */ + int32_t size; /**< payload size */ int32_t log_level; /**< log level */ int32_t trace_status; /**< trace status */ int32_t args_num; /**< number of arguments for extended header*/ diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index bbee5ea..7a4b29c 100644 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -110,7 +110,7 @@ typedef struct int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */ char pathToECUSoftwareVersion[DLT_DAEMON_FLAG_MAX]; /**< (String: Filename) The file from which to read the ECU version from. */ int sendTimezone; /**< (Boolean) Send Timezone perdiodically */ - uint32_t offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */ + int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */ char offlineLogstorageDirPath[DLT_MOUNT_PATH_MAX]; /**< (String: Directory) DIR path to store offline logs */ int offlineLogstorageTimestamp; /**< (int) Append timestamp in offline logstorage filename */ char offlineLogstorageDelimiter; /**< (char) Append delimeter character in offline logstorage filename */ diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 78346fd..a438c03 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -86,7 +86,7 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn, case DLT_CONNECTION_CLIENT_MSG_TCP: ret = dlt_daemon_socket_sendreliable(conn->receiver->fd, msg, - (int) msg_size); + msg_size); return ret; default: return DLT_DAEMON_ERROR_UNKNOWN; @@ -125,10 +125,10 @@ int dlt_connection_send_multiple(DltConnection *con, sizeof(dltSerialHeader)); if ((data1 != NULL) && (ret == DLT_RETURN_OK)) - ret = dlt_connection_send(con, data1, (size_t) size1); + ret = dlt_connection_send(con, data1, size1); if ((data2 != NULL) && (ret == DLT_RETURN_OK)) - ret = dlt_connection_send(con, data2, (size_t) size2); + ret = dlt_connection_send(con, data2, size2); return ret; } diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c index 3cecf64..0d463da 100644 --- a/src/daemon/dlt_daemon_event_handler.c +++ b/src/daemon/dlt_daemon_event_handler.c @@ -109,9 +109,9 @@ int dlt_daemon_prepare_event_handling(DltEventHandler *ev) static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask) { if (ev->max_nfds <= ev->nfds) { - int i = (int) ev->nfds; - int max = (int) (2 * ev->max_nfds); - struct pollfd *tmp = realloc(ev->pfd, (size_t) (max) * sizeof(*ev->pfd)); + int i = ev->nfds; + int max = 2 * ev->max_nfds; + struct pollfd *tmp = realloc(ev->pfd, max * sizeof(*ev->pfd)); if (!tmp) { dlt_log(LOG_CRIT, @@ -143,7 +143,7 @@ static void dlt_event_handler_disable_fd(DltEventHandler *ev, int fd) { unsigned int i = 0; unsigned int j = 0; - unsigned int nfds = (unsigned int) ev->nfds; + unsigned int nfds = ev->nfds; for (; i < nfds; i++, j++) { if (ev->pfd[i].fd == fd) { diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c index b56aade..5d21a76 100644 --- a/src/daemon/dlt_daemon_offline_logstorage.c +++ b/src/daemon/dlt_daemon_offline_logstorage.c @@ -49,7 +49,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key, if ((len > (DLT_ID_SIZE + 2)) || (len < 2)) return DLT_RETURN_ERROR; - memcpy(ecuid, key, (size_t) (len - 2)); + memcpy(ecuid, key, (len - 2)); memcpy(apid, ".*", 2); memcpy(ctid, ".*", 2); @@ -76,7 +76,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key, if ((len > (DLT_ID_SIZE + 2)) || (len < 1)) return DLT_RETURN_ERROR; - strncpy(ctid, (key + 2), (size_t) (len - 1)); + strncpy(ctid, (key + 2), (len - 1)); memcpy(apid, ".*", 2); return DLT_RETURN_OK; @@ -101,7 +101,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key, if ((len > (DLT_ID_SIZE + 2)) || (len < 2)) return DLT_RETURN_ERROR; - strncpy(apid, key + 1, (size_t) (len - 2)); + strncpy(apid, key + 1, (len - 2)); memcpy(ctid, ".*", 2); return DLT_RETURN_OK; @@ -218,7 +218,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_multi(char *key, if (tok == NULL) return DLT_RETURN_ERROR; - len = (int) strlen(tok); + len = strlen(tok); if (key[len + 1] == ':') { strncpy(ecuid, tok, DLT_ID_SIZE); @@ -264,7 +264,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *apid, if ((key == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL)) return DLT_RETURN_WRONG_PARAMETER; - len = (int) strlen(key); + len = strlen(key); sep = strchr (key, ':'); @@ -336,7 +336,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context( dlt_set_id(req.apid, apid); dlt_set_id(req.ctid, ctid); - req.log_level = (uint8_t) loglevel; + req.log_level = loglevel; if (dlt_gateway_send_control_message(con, &ctrl, (void *)&req, verbose) != 0) { dlt_vlog(LOG_ERR, @@ -382,7 +382,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) { old_log_level = context->storage_log_level; - context->storage_log_level = (int8_t) DLT_OFFLINE_LOGSTORAGE_MAX(loglevel, + context->storage_log_level = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel, context->storage_log_level); if (context->storage_log_level > old_log_level) { @@ -487,7 +487,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae { int ll = DLT_LOG_DEFAULT; int num = 0; - uint32_t i = 0; + int i = 0; DltLogStorageFilterConfig *config[DLT_CONFIG_FILE_SECTIONS_MAX] = { 0 }; if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) || @@ -975,11 +975,11 @@ int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon, /* If logstorage configuration do not contain file name, * then it is non verbose control filter, so return level as in this filter */ if (config[j]->file_name == NULL) { - storage_loglevel = (int8_t) config[j]->log_level; + storage_loglevel = config[j]->log_level; break; } - configured_loglevel = (int8_t) config[j]->log_level; + configured_loglevel = config[j]->log_level; storage_loglevel = DLT_OFFLINE_LOGSTORAGE_MAX( configured_loglevel, storage_loglevel); @@ -1014,7 +1014,7 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon, unsigned char *data3, int size3) { - uint32_t i = 0; + int i = 0; DltLogStorageUserConfig file_config; if ((daemon == NULL) || (user_config == NULL) || @@ -1118,7 +1118,7 @@ int dlt_daemon_logstorage_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { - uint32_t i = 0; + int i = 0; PRINT_FUNCTION_VERBOSE(verbose); @@ -1152,7 +1152,7 @@ int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon, char *mnt_point, int verbose) { - uint32_t i = 0; + int i = 0; DltLogStorage *handle = NULL; PRINT_FUNCTION_VERBOSE(verbose); @@ -1210,7 +1210,7 @@ DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon, char *mnt_point, int verbose) { - uint32_t i = 0; + int i = 0; int len = 0; int len1 = 0; int len2 = 0; @@ -1220,17 +1220,17 @@ DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon, if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL)) return NULL; - len1 = (int) strlen(mnt_point); + len1 = strlen(mnt_point); for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) { - len2 = (int) strlen(daemon->storage_handle[i].device_mount_point); + len2 = strlen(daemon->storage_handle[i].device_mount_point); /* Check if the requested device path is already used as log storage * device. Check for strlen first, to avoid comparison errors when * final '/' is given or not */ len = len1 > len2 ? len2 : len1; - if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, (size_t) len) == 0) + if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, len) == 0) return &daemon->storage_handle[i]; } diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c index 1b6507d..36b7990 100644 --- a/src/daemon/dlt_daemon_serial.c +++ b/src/daemon/dlt_daemon_serial.c @@ -76,13 +76,13 @@ int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int si /* Send data */ if (data1 && (size1 > 0)) - if (0 > write(sock, data1, (size_t) size1)) + if (0 > write(sock, data1, size1)) return DLT_DAEMON_ERROR_SEND_FAILED; if (data2 && (size2 > 0)) - if (0 > write(sock, data2, (size_t) size2)) + if (0 > write(sock, data2, size2)) return DLT_DAEMON_ERROR_SEND_FAILED; return DLT_DAEMON_ERROR_OK; diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c index 0dd22a9..9db48b9 100644 --- a/src/daemon/dlt_daemon_socket.c +++ b/src/daemon/dlt_daemon_socket.c @@ -196,7 +196,7 @@ int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size while (data_sent < message_size) { ssize_t ret = send(sock, (uint8_t*)data_buffer + data_sent, - (size_t) (message_size - data_sent), + message_size - data_sent, 0); if (ret < 0) { @@ -204,7 +204,7 @@ int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size "%s: socket send failed [errno: %d]!\n", __func__, errno); return DLT_DAEMON_ERROR_SEND_FAILED; } else { - data_sent += (int) ret; + data_sent += ret; } } diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 9a9ab6d..6ede605 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -262,8 +262,8 @@ int main(int argc, char *argv[]) message = argv[index]; } else { /* allocate raw buffer */ - message = calloc(sizeof(char), (size_t) rvalue); - memset(message, 'X', (size_t) (rvalue - 1)) ; + message = calloc(sizeof(char), rvalue); + memset(message, 'X', rvalue - 1); } if (message == 0) { @@ -330,7 +330,7 @@ int main(int argc, char *argv[]) delay = 500; if (tvalue) - dlt_set_resend_timeout_atexit((uint32_t) atoi(tvalue)); + dlt_set_resend_timeout_atexit(atoi(tvalue)); if (gflag) { /* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */ diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c index 4174c89..9d0041d 100644 --- a/src/gateway/dlt_gateway.c +++ b/src/gateway/dlt_gateway.c @@ -313,7 +313,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnectio return DLT_RETURN_ERROR; } - con->p_control_msgs->id = (uint32_t) strtol(token, NULL, 16); + con->p_control_msgs->id = strtol(token, NULL, 16); con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT; con->p_control_msgs->type = CONTROL_MESSAGE_ON_STARTUP; con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED; @@ -384,7 +384,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages( p_token = strtok_r(token, ":", &p_rest); if ((p_token != NULL) && (strlen(p_token) != 0)) { - id = (uint32_t) strtol(p_token, NULL, 16); + id = strtol(p_token, NULL, 16); /* get back to head */ con->p_control_msgs = head; @@ -393,7 +393,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages( while (con->p_control_msgs != NULL) { if (con->p_control_msgs->id == id) { con->p_control_msgs->type = CONTROL_MESSAGE_BOTH; - con->p_control_msgs->interval = (int) strtol(p_rest, NULL, 10); + con->p_control_msgs->interval = strtol(p_rest, NULL, 10); if (con->p_control_msgs->interval <= 0) dlt_vlog(LOG_WARNING, @@ -430,7 +430,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages( con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT; con->p_control_msgs->type = CONTROL_MESSAGE_PERIODIC; con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED; - con->p_control_msgs->interval = (int) strtol(p_rest, NULL, 10); + con->p_control_msgs->interval = strtol(p_rest, NULL, 10); if (con->p_control_msgs->interval <= 0) dlt_vlog(LOG_WARNING, @@ -697,7 +697,7 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose) gateway->num_connections = num_sections - 1; } - gateway->connections = calloc((size_t) gateway->num_connections, + gateway->connections = calloc(gateway->num_connections, sizeof(DltGatewayConnection)); if (gateway->connections == NULL) { @@ -1167,8 +1167,8 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon, if (dlt_daemon_context_add(daemon, app.app_id, con.context_id, - (int8_t) con.log_level, - (int8_t) con.trace_status, + con.log_level, + con.trace_status, 0, -1, con.context_description, @@ -1254,7 +1254,7 @@ DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon, int verbose) { unsigned int connection_type = 0; - uint32_t i = 0; + int i = 0; if (daemon_local->flags.offlineLogstorageMaxDevices <= 0) { dlt_log(LOG_INFO, @@ -1269,7 +1269,7 @@ DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon, /* Check if log level of running application needs an update */ dlt_daemon_logstorage_update_application_loglevel(daemon, daemon_local, - (int) i, + i, verbose); } @@ -1349,7 +1349,7 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon, while (dlt_message_read(&msg, (unsigned char *)receiver->buf, - (unsigned int) receiver->bytesRcvd, + receiver->bytesRcvd, 0, verbose) == DLT_MESSAGE_ERROR_OK) { DltStandardHeaderExtra *header = (DltStandardHeaderExtra *) @@ -1422,9 +1422,9 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon, msg.headerbuffer, sizeof(DltStorageHeader), msg.headerbuffer + sizeof(DltStorageHeader), - (int) (msg.headersize - sizeof(DltStorageHeader)), + msg.headersize - sizeof(DltStorageHeader), msg.databuffer, - (int) msg.datasize, + msg.datasize, verbose); } else { /* otherwise remove this connection and do not connect again */ dlt_vlog(LOG_WARNING, @@ -1449,19 +1449,19 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon, if (msg.found_serialheader) { if (dlt_receiver_remove(receiver, - (int) (msg.headersize + + msg.headersize + msg.datasize - sizeof(DltStorageHeader) + - sizeof(dltSerialHeader))) == -1) { + sizeof(dltSerialHeader)) == -1) { /* Return value ignored */ dlt_message_free(&msg, verbose); return DLT_RETURN_ERROR; } } else if (dlt_receiver_remove(receiver, - (int) (msg.headersize + + msg.headersize + msg.datasize - - sizeof(DltStorageHeader))) == -1) { + sizeof(DltStorageHeader)) == -1) { /* Return value ignored */ dlt_message_free(&msg, verbose); return DLT_RETURN_ERROR; @@ -1557,7 +1557,7 @@ int dlt_gateway_forward_control_message(DltGateway *gateway, } if (con->send_serial) { /* send serial header */ - ret = (int) send(con->client.sock, + ret = send(con->client.sock, (void *)dltSerialHeader, sizeof(dltSerialHeader), 0); @@ -1568,7 +1568,7 @@ int dlt_gateway_forward_control_message(DltGateway *gateway, } } - ret = (int) send(con->client.sock, + ret = send(con->client.sock, msg->headerbuffer + sizeof(DltStorageHeader), msg->headersize - sizeof(DltStorageHeader), 0); @@ -1578,7 +1578,7 @@ int dlt_gateway_forward_control_message(DltGateway *gateway, return DLT_RETURN_ERROR; } else { - ret = (int) send(con->client.sock, msg->databuffer, msg->datasize, 0); + ret = send(con->client.sock, msg->databuffer, msg->datasize, 0); if (ret == -1) { dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n"); @@ -1697,7 +1697,7 @@ int dlt_gateway_send_control_message(DltGatewayConnection *con, } if (con->send_serial) { /* send serial header */ - ret = (int) send(con->client.sock, + ret = send(con->client.sock, (void *)dltSerialHeader, sizeof(dltSerialHeader), 0); diff --git a/src/lib/dlt_env_ll.c b/src/lib/dlt_env_ll.c index f58afce..8770a02 100644 --- a/src/lib/dlt_env_ll.c +++ b/src/lib/dlt_env_ll.c @@ -98,7 +98,7 @@ int dlt_env_helper_to_lower(char **const env, char *result, int const res_len) while (ch && (count < res_len - 1) && (ch != ';')) { if ((ch >= 'A') && (ch <= 'Z')) - result[count] = (char) (ch + 'a' - 'A'); + result[count] = ch + 'a' - 'A'; else result[count] = ch; @@ -125,7 +125,7 @@ int dlt_env_extract_symbolic_ll(char **const env, int8_t *ll) if (!(*env)) return -1; - if (dlt_env_helper_to_lower(env, &result[0], (int) sizeof(result)) == 0) { + if (dlt_env_helper_to_lower(env, &result[0], sizeof(result)) == 0) { if (strncmp("default", result, sizeof(result)) == 0) *ll = -1; else if (strncmp("off", result, sizeof(result)) == 0) @@ -203,7 +203,7 @@ int dlt_env_extract_ll(char **const env, int8_t *ll) } else { if ((**env >= '0') && (**env < '7')) { - *ll = (int8_t) (**env - '0'); + *ll = **env - '0'; (*env)++; } else if (dlt_env_extract_symbolic_ll(env, ll) != 0) diff --git a/src/lib/dlt_filetransfer.c b/src/lib/dlt_filetransfer.c index e9fbf3e..bd196ea 100644 --- a/src/lib/dlt_filetransfer.c +++ b/src/lib/dlt_filetransfer.c @@ -91,7 +91,7 @@ uint32_t getFilesize(const char *file, int *ok) } *ok = 1; - return (uint32_t) st.st_size; + return (uint32_t)st.st_size; } /** A simple Hash function for C-strings @@ -104,7 +104,7 @@ void stringHash(const char *str, uint32_t *hash) if (!str || !hash) return; - unsigned int len = (unsigned int) strlen(str); + unsigned int len = strlen(str); unsigned int i = 0; @@ -112,7 +112,7 @@ void stringHash(const char *str, uint32_t *hash) return; for (i = 0; i < len; i++) - *hash = (uint32_t) ((*hash) * 53) + (uint32_t) str[i]; + *hash = 53 * *hash + str[i]; } @@ -133,10 +133,10 @@ uint32_t getFileSerialNumber(const char *file, int *ok) } else { *ok = 1; - ret = (uint32_t) st.st_ino; + ret = st.st_ino; ret = ret << (sizeof(ret) * 8) / 2; - ret |= (uint32_t) st.st_size; - ret ^= (uint32_t) st.st_ctime; + ret |= st.st_size; + ret ^= st.st_ctime; stringHash(file, &ret); } @@ -333,7 +333,7 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename) DLT_STRING("filename"), DLT_STRING(filename), DLT_STRING("file size in bytes"), DLT_UINT(fsize), DLT_STRING("file creation date"), DLT_STRING(creationdate), - DLT_STRING("number of packages"), DLT_INT(dlt_user_log_file_packagesCount(fileContext, filename)), + DLT_STRING("number of packages"), DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)), DLT_STRING("FLIF") ); return 0; @@ -407,7 +407,7 @@ int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filenam return packages; } else { - packages = (int) (filesize / BUFFER_SIZE); + packages = filesize / BUFFER_SIZE; if (filesize % BUFFER_SIZE == 0) return packages; @@ -468,7 +468,7 @@ int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename DLT_STRING(alias), DLT_UINT(fsize), DLT_STRING(fcreationdate); - DLT_INT(dlt_user_log_file_packagesCount(fileContext, filename)), + DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)), DLT_UINT(BUFFER_SIZE), DLT_STRING("FLST") ); @@ -523,7 +523,7 @@ int dlt_user_log_file_header(DltContext *fileContext, const char *filename) DLT_STRING(filename), DLT_UINT(fsize), DLT_STRING(fcreationdate); - DLT_INT(dlt_user_log_file_packagesCount(fileContext, filename)), + DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)), DLT_UINT(BUFFER_SIZE), DLT_STRING("FLST") ); @@ -548,7 +548,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa { FILE *file; int pkgNumber; - uint16_t readBytes; + uint32_t readBytes; if (isFile(filename)) { @@ -565,9 +565,9 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa DLT_LOG(*fileContext, DLT_LOG_ERROR, DLT_STRING("Error at dlt_user_log_file_data: packageToTransfer out of scope"), DLT_STRING("packageToTransfer:"), - DLT_INT(packageToTransfer), + DLT_UINT(packageToTransfer), DLT_STRING("numberOfMaximalPackages:"), - DLT_INT(dlt_user_log_file_packagesCount(fileContext, filename)), + DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)), DLT_STRING("for File:"), DLT_STRING(filename) ); @@ -595,7 +595,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa } - readBytes = (uint16_t) fread(buffer, sizeof(char), BUFFER_SIZE, file); + readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file); int ok; uint32_t fserial = getFileSerialNumber(filename, &ok); @@ -608,7 +608,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa DLT_LOG(*fileContext, DLT_LOG_INFO, DLT_STRING("FLDA"), DLT_UINT(fserial), - DLT_INT(packageToTransfer), + DLT_UINT(packageToTransfer), DLT_RAW(buffer, readBytes), DLT_STRING("FLDA") ); @@ -624,7 +624,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa /* If free space < 50% the package won't be transferred. */ if (checkUserBufferForFreeSpace() > 0) { pkgNumber++; - readBytes = (uint16_t) fread(buffer, sizeof(char), BUFFER_SIZE, file); + readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file); int ok; uint32_t fserial = getFileSerialNumber(filename, &ok); @@ -637,7 +637,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa DLT_LOG(*fileContext, DLT_LOG_INFO, DLT_STRING("FLDA"), DLT_UINT(fserial), - DLT_INT(pkgNumber), + DLT_UINT(pkgNumber), DLT_RAW(buffer, readBytes), DLT_STRING("FLDA") ); diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c index f102029..07d09a5 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.c +++ b/src/offlinelogstorage/dlt_offline_logstorage.c @@ -193,7 +193,7 @@ DLT_STATIC int dlt_logstorage_list_add(char *keys, return -1; tmp->key_list = (char *)calloc( - (size_t) (num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), sizeof(char)); + (num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), sizeof(char)); if (tmp->key_list == NULL) { free(tmp); @@ -201,7 +201,7 @@ DLT_STATIC int dlt_logstorage_list_add(char *keys, return -1; } - memcpy(tmp->key_list, keys, (size_t) (num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)); + memcpy(tmp->key_list, keys, num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN); tmp->num_keys = num_keys; tmp->next = NULL; tmp->data = calloc(1, sizeof(DltLogStorageFilterConfig)); @@ -326,8 +326,8 @@ void dlt_logstorage_free(DltLogStorage *handle, int reason) DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, char *value) { int i = 0; - size_t y = 0; - size_t len = 0; + int y = 0; + int len = 0; char *tok; int num = 1; @@ -349,7 +349,7 @@ DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, char *value) num = dlt_logstorage_count_ids(value); /* need to alloc space for 5 chars, 4 for the name and "," and "\0" */ - *names = (char *)calloc((size_t) (num * 5), sizeof(char)); + *names = (char *)calloc(num * 5, sizeof(char)); if (*names == NULL) return -1; @@ -399,7 +399,7 @@ DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value) return -1; *number = 0; - len = (int) strlen(value); + len = strlen(value); /* check if string consists of digits only */ for (i = 0; i < len; i++) @@ -495,7 +495,7 @@ DLT_STATIC void dlt_logstorage_create_keys_only_ctid(char *ecuid, char *ctid, char *key) { char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 }; - size_t curr_len = 0; + int curr_len = 0; if (ecuid != NULL) { strncpy(curr_str, ecuid, strlen(ecuid)); @@ -527,7 +527,7 @@ DLT_STATIC void dlt_logstorage_create_keys_only_apid(char *ecuid, char *apid, char *key) { char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 }; - size_t curr_len = 0; + int curr_len = 0; if (ecuid != NULL) { strncpy(curr_str, ecuid, strlen(ecuid)); @@ -561,7 +561,7 @@ DLT_STATIC void dlt_logstorage_create_keys_multi(char *ecuid, char *apid, char *ctid, char *key) { char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 }; - size_t curr_len = 0; + int curr_len = 0; if (ecuid != NULL) { strncpy(curr_str, ecuid, strlen(ecuid)); @@ -651,7 +651,7 @@ DLT_STATIC int dlt_logstorage_create_keys(char *apids, (ctids != NULL) && (strncmp(ctids, ".*", 2) == 0) && (ecuid != NULL)) ) { dlt_logstorage_create_keys_only_ecu(ecuid, curr_key); *(num_keys) = 1; - *(keys) = (char *)calloc((size_t) (*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), + *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, sizeof(char)); if (*(keys) == NULL) @@ -682,7 +682,7 @@ DLT_STATIC int dlt_logstorage_create_keys(char *apids, *(num_keys) = num_apids * num_ctids; /* allocate memory for needed number of keys */ - *(keys) = (char *)calloc((size_t) (*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), + *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, sizeof(char)); if (*(keys) == NULL) { @@ -822,20 +822,20 @@ DLT_STATIC int dlt_logstorage_validate_filter_name(char *name) { int len = 0; int idx = 0; - size_t config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION); - size_t storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION); - size_t control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION); + int config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION); + int storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION); + int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION); if (name == NULL) return -1; - len = (int) strlen(name); + len = strlen(name); /* Check if section header is of format "FILTER" followed by a number */ if (strncmp(name, DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION, config_sec_len) == 0) { - for (idx = (int) config_sec_len; idx < len - 1; idx++) + for (idx = config_sec_len; idx < len - 1; idx++) if (!isdigit(name[idx])) return -1; @@ -846,7 +846,7 @@ DLT_STATIC int dlt_logstorage_validate_filter_name(char *name) DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION, storage_sec_len) == 0) { - for (idx = (int) storage_sec_len; idx < len - 1; idx++) + for (idx = storage_sec_len; idx < len - 1; idx++) if (!isdigit(name[idx])) return -1; @@ -857,7 +857,7 @@ DLT_STATIC int dlt_logstorage_validate_filter_name(char *name) DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION, control_sec_len) == 0) { - for (idx = (int) control_sec_len; idx < len - 1; idx++) + for (idx = control_sec_len; idx < len - 1; idx++) if (!isdigit(name[idx])) return -1; @@ -1001,7 +1001,7 @@ DLT_STATIC int dlt_logstorage_check_reset_loglevel(DltLogStorageFilterConfig *co DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config, char *value) { - size_t len; + int len; if ((value == NULL) || (strcmp(value, "") == 0)) return -1; @@ -1015,7 +1015,7 @@ DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config, /* do not allow the user to change directory by adding a relative path */ if (strstr(value, "..") == NULL) { - config->file_name = calloc(len + 1, sizeof(char)); + config->file_name = calloc((len + 1), sizeof(char)); if (config->file_name == NULL) { dlt_log(LOG_ERR, @@ -1123,7 +1123,7 @@ DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *con DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config, char *value) { - size_t len; + int len; if ((config == NULL) || (value == NULL) || (value[0] == '\0')) return -1; @@ -1134,7 +1134,7 @@ DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config, } len = strlen(value); - config->ecuid = calloc(len + 1, sizeof(char)); + config->ecuid = calloc((len + 1), sizeof(char)); if (config->ecuid == NULL) return -1; @@ -1368,9 +1368,9 @@ DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file, char *value) { int ret = 0; - size_t config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION); - size_t storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION); - size_t control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION); + int config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION); + int storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION); + int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION); if ((config_file == NULL) || (sec_name == NULL)) return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR; @@ -1931,9 +1931,9 @@ int dlt_logstorage_get_config(DltLogStorage *handle, char key[DLT_CONFIG_FILE_SECTIONS_MAX][DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN] = { { '\0' }, { '\0' }, { '\0' } }; int i = 0; - size_t apid_len = 0; - size_t ctid_len = 0; - size_t ecuid_len = 0; + int apid_len = 0; + int ctid_len = 0; + int ecuid_len = 0; int num_configs = 0; int num = 0; @@ -2161,10 +2161,10 @@ int dlt_logstorage_write(DltLogStorage *handle, + sizeof(DltStandardHeader)); if (DLT_IS_HTYP_UEH(standardHeader->htyp)) { - header_len = (unsigned int) (sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + standardHeaderExtraLen); + header_len = sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + standardHeaderExtraLen; /* check if size2 is big enough to contain expected DLT message header */ - if ((unsigned int) size2 < header_len) { + if ((unsigned int)size2 < header_len) { dlt_log(LOG_ERR, "DLT message header is too small\n"); return 0; } @@ -2185,10 +2185,10 @@ int dlt_logstorage_write(DltLogStorage *handle, } } else { - header_len = (unsigned int) (sizeof(DltStandardHeader) + standardHeaderExtraLen); + header_len = sizeof(DltStandardHeader) + standardHeaderExtraLen; /* check if size2 is big enough to contain expected DLT message header */ - if ((unsigned int) size2 < header_len) { + if ((unsigned int)size2 < header_len) { dlt_log(LOG_ERR, "DLT message header is too small (without extended header)\n"); return 0; } diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index b7b7955..9c121e0 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -73,7 +73,7 @@ void dlt_logstorage_log_file_name(char *log_file_name, unsigned int digit_idx = 0; unsigned int i = 0; snprintf(file_index, 10, "%d", idx); - digit_idx = (unsigned int) strlen(file_index); + digit_idx = strlen(file_index); if (file_config->logfile_counteridxlen > digit_idx) { @@ -233,16 +233,16 @@ unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_co return -1; } - filename_len = (unsigned int) (strlen(file) - strlen(filename)); + filename_len = strlen(file) - strlen(filename); /* index is retrived from file name */ if (file_config->logfile_timestamp) { - fileindex_len = (unsigned int) strlen(file) - + fileindex_len = strlen(file) - (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + filename_len + 1); - idx = (unsigned int) strtol(&file[strlen(file) - + idx = (int)strtol(&file[strlen(file) - (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + fileindex_len + DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN)], @@ -250,11 +250,11 @@ unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_co 10); } else { - fileindex_len = (unsigned int) strlen(file) - + fileindex_len = strlen(file) - (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + filename_len + 1); - idx = (unsigned int) strtol(&file[strlen(file) - + idx = (int)strtol(&file[strlen(file) - (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + fileindex_len)], &endptr, 10); } @@ -323,7 +323,7 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, } for (i = 0; i < cnt; i++) { - size_t len = 0; + int len = 0; len = strlen(config->file_name); if ((strncmp(files[i]->d_name, config->file_name, len) == 0) && @@ -500,7 +500,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, /* if size is enough, open it */ if ((ret == 0) && (s.st_size + msg_size <= (int) config->file_size)) { config->log = fopen(absolute_file_path, "a+"); - config->current_write_file_offset = (unsigned int) s.st_size; + config->current_write_file_offset = s.st_size; } else { /* no space in file or file stats cannot be read */ @@ -521,7 +521,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, dlt_logstorage_log_file_name(file_name, file_config, config->file_name, - (int) idx); + idx); /* concatenate path and file and open absolute path */ memset(absolute_file_path, @@ -719,8 +719,8 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config, int ret = 0; int start_index = 0; int end_index = 0; - unsigned int count = 0; - unsigned int remain_file_size = 0; + int count = 0; + int remain_file_size = 0; if ((config == NULL) || (file_config == NULL) || (dev_path == NULL) || (footer == NULL)) @@ -741,7 +741,7 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config, } if (dlt_logstorage_open_log_file(config, file_config, - dev_path, (int) count, true) != 0) { + dev_path, count, true) != 0) { dlt_vlog(LOG_ERR, "%s: failed to open log file\n", __func__); return -1; } @@ -754,14 +754,14 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config, start_index = dlt_logstorage_find_dlt_header(config->cache, start_offset, remain_file_size); end_index = dlt_logstorage_find_last_dlt_header(config->cache, - start_offset + (unsigned int) start_index, - remain_file_size - (unsigned int) start_index); - count = (unsigned int) (end_index - start_index); + start_offset + start_index, + remain_file_size - start_index); + count = end_index - start_index; if ((start_index >= 0) && (end_index > start_index) && (count > 0) && (count <= remain_file_size)) { - ret = (int) fwrite((uint8_t*)config->cache + start_offset + start_index, + ret = fwrite((uint8_t*)config->cache + start_offset + start_index, count, 1, config->log); dlt_logstorage_check_write_ret(config, ret); @@ -783,7 +783,7 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config, } start_index = dlt_logstorage_find_dlt_header(config->cache, start_offset, count); - count = end_offset - start_offset - (unsigned int) start_index; + count = end_offset - start_offset - start_index; if ((start_index >= 0) && (count > 0)) { @@ -791,14 +791,14 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config, if (config->log == NULL) { if (dlt_logstorage_prepare_on_msg(config, file_config, dev_path, - (int) count, NULL) != 0) + count, NULL) != 0) { dlt_vlog(LOG_ERR, "%s: failed to prepare log file\n", __func__); return -1; } } - ret = (int) fwrite((uint8_t*)config->cache + start_offset + start_index, count, 1, + ret = fwrite((uint8_t*)config->cache + start_offset + start_index, count, 1, config->log); dlt_logstorage_check_write_ret(config, ret); @@ -935,17 +935,17 @@ int dlt_logstorage_write_on_msg(DltLogStorageFilterConfig *config, return -1; } - ret = (int) fwrite(data1, 1, (size_t) size1, config->log); + ret = fwrite(data1, 1, size1, config->log); if (ret != size1) dlt_log(LOG_WARNING, "Wrote less data than specified\n"); - ret = (int) fwrite(data2, 1, (size_t) size2, config->log); + ret = fwrite(data2, 1, size2, config->log); if (ret != size2) dlt_log(LOG_WARNING, "Wrote less data than specified\n"); - ret = (int) fwrite(data3, 1, (size_t) size3, config->log); + ret = fwrite(data3, 1, size3, config->log); if (ret != size3) dlt_log(LOG_WARNING, "Wrote less data than specified\n"); @@ -1089,7 +1089,7 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config, else { /* update current used cache size */ - g_logstorage_cache_size = (unsigned int) (cache_size + sizeof(DltLogStorageCacheFooter)); + g_logstorage_cache_size = cache_size + sizeof(DltLogStorageCacheFooter); } } @@ -1123,8 +1123,8 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, int size3) { DltLogStorageCacheFooter *footer = NULL; - unsigned int msg_size; - unsigned int remain_cache_size; + int msg_size; + int remain_cache_size; uint8_t *curr_write_addr = NULL; int ret = 0; unsigned int cache_size; @@ -1152,23 +1152,23 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, dlt_log(LOG_ERR, "Cannot retrieve cache footer. Address is NULL\n"); return -1; } - msg_size = (unsigned int) (size1 + size2 + size3); + msg_size = size1 + size2 + size3; remain_cache_size = cache_size - footer->offset; if (msg_size <= remain_cache_size) /* add at current position */ { curr_write_addr = (uint8_t*)config->cache + footer->offset; - footer->offset += (unsigned int) msg_size; + footer->offset += msg_size; if (footer->wrap_around_cnt < 1) { footer->end_sync_offset = footer->offset; } /* write data to cache */ - memcpy(curr_write_addr, data1, (size_t) size1); + memcpy(curr_write_addr, data1, size1); curr_write_addr += size1; - memcpy(curr_write_addr, data2, (size_t) size2); + memcpy(curr_write_addr, data2, size2); curr_write_addr += size2; - memcpy(curr_write_addr, data3, (size_t) size3); + memcpy(curr_write_addr, data3, size3); } /* @@ -1226,14 +1226,14 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, /* start writing from beginning */ footer->end_sync_offset = footer->offset; curr_write_addr = config->cache; - footer->offset = (unsigned int) msg_size; + footer->offset = msg_size; /* write data to cache */ - memcpy(curr_write_addr, data1, (size_t) size1); + memcpy(curr_write_addr, data1, size1); curr_write_addr += size1; - memcpy(curr_write_addr, data2, (size_t) size2); + memcpy(curr_write_addr, data2, size2); curr_write_addr += size2; - memcpy(curr_write_addr, data3, (size_t) size3); + memcpy(curr_write_addr, data3, size3); } } diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 507c8ad..c8fdfc3 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2224,7 +2224,7 @@ DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char return DLT_RETURN_OK; } -DltReturnValue dlt_check_rcv_data_size(uint32_t received, uint32_t required) +DltReturnValue dlt_check_rcv_data_size(int received, int required) { int _ret = DLT_RETURN_OK; if (received < required) { diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c index 909252b..2d70a77 100644 --- a/src/shared/dlt_offline_trace.c +++ b/src/shared/dlt_offline_trace.c @@ -85,7 +85,7 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha return 0; for (i = 0; i < cnt; i++) { - size_t len = 0; + int len = 0; len = strlen(file_name); if ((strncmp(files[i]->d_name, file_name, len) == 0) && @@ -166,7 +166,7 @@ unsigned int dlt_offline_trace_get_idx_of_log_file(char *file) token = strtok(NULL, d); if (token != NULL) - idx = (unsigned int) strtol(token, NULL, 10); + idx = strtol(token, NULL, 10); else idx = 0; @@ -307,7 +307,7 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) if (0 == stat(filename, &status)) { if ((time_oldest == 0) || (status.st_mtime < time_oldest)) { time_oldest = status.st_mtime; - size_oldest = (unsigned long) status.st_size; + size_oldest = status.st_size; strncpy(filename_oldest, filename, PATH_MAX); filename_oldest[PATH_MAX] = 0; } @@ -414,21 +414,21 @@ DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace, /* write data into log file */ if (data1 && (trace->ohandle >= 0)) { - if (write(trace->ohandle, data1, (size_t) size1) != size1) { + if (write(trace->ohandle, data1, size1) != size1) { printf("Offline trace write failed!\n"); return DLT_RETURN_ERROR; } } if (data2 && (trace->ohandle >= 0)) { - if (write(trace->ohandle, data2, (size_t) size2) != size2) { + if (write(trace->ohandle, data2, size2) != size2) { printf("Offline trace write failed!\n"); return DLT_RETURN_ERROR; } } if (data3 && (trace->ohandle >= 0)) { - if (write(trace->ohandle, data3, (size_t) size3) != size3) { + if (write(trace->ohandle, data3, size3) != size3) { printf("Offline trace write failed!\n"); return DLT_RETURN_ERROR; } diff --git a/src/tests/dlt-test-stress-client.c b/src/tests/dlt-test-stress-client.c index e435a00..1210386 100644 --- a/src/tests/dlt-test-stress-client.c +++ b/src/tests/dlt-test-stress-client.c @@ -447,7 +447,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) length_tmp = 0; /* the macro can set this variable to -1 */ ptr = message->databuffer; - datalength = (int32_t) message->datasize; + datalength = message->datasize; /* first read the type info of the first argument: must be string */ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t); |