summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriod1hc <toan.dinhcong@vn.bosch.com>2020-11-05 19:29:45 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-01-06 09:27:28 +0900
commit699d52298bfde3ab5721a78264d5a4f4e2f326ef (patch)
treed1f59052c1f77e860971fec19032333907d58c22 /src
parent2e8dade01beef3d8b6e6b812690c1f64d3408ce2 (diff)
downloadDLT-daemon-699d52298bfde3ab5721a78264d5a4f4e2f326ef.tar.gz
daemon: fix conversion warnings
- Instead of casting frequently, change the data type of 'to_remove' to 'uint32_t' for the correct format, also adding temp variable to check return value. - Change data type of 2 variable 'offset' and 'sizecont' to 'size_t' (dlt_daemon_client.c), because these variable using many time with function 'sizeof', and they was used as local variable so it will not effect dlt library. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
Diffstat (limited to 'src')
-rw-r--r--src/daemon/dlt-daemon.c100
-rw-r--r--src/daemon/dlt-daemon.h2
-rw-r--r--src/daemon/dlt_daemon_client.c151
-rw-r--r--src/daemon/dlt_daemon_common.c42
-rw-r--r--src/daemon/dlt_daemon_connection.c6
-rw-r--r--src/daemon/dlt_daemon_event_handler.c6
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.c32
-rw-r--r--src/daemon/dlt_daemon_serial.c4
-rw-r--r--src/daemon/dlt_daemon_socket.c2
9 files changed, 179 insertions, 166 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index bfe11d0..22ac934 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -261,7 +261,7 @@ int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
#endif
case 'p':
{
- daemon_local->flags.port = atoi(optarg);
+ daemon_local->flags.port = (unsigned int) atoi(optarg);
if (daemon_local->flags.port == 0) {
fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
@@ -593,7 +593,7 @@ int option_file_parser(DltDaemonLocal *daemon_local)
}
else if (strcmp(token, "OfflineLogstorageMaxDevices") == 0)
{
- daemon_local->flags.offlineLogstorageMaxDevices = atoi(value);
+ daemon_local->flags.offlineLogstorageMaxDevices = (uint32_t) atoi(value);
}
else if (strcmp(token, "OfflineLogstorageDirPath") == 0)
{
@@ -615,8 +615,8 @@ int option_file_parser(DltDaemonLocal *daemon_local)
}
else if (strcmp(token, "OfflineLogstorageMaxCounter") == 0)
{
- daemon_local->flags.offlineLogstorageMaxCounter = atoi(value);
- daemon_local->flags.offlineLogstorageMaxCounterIdx = strlen(value);
+ daemon_local->flags.offlineLogstorageMaxCounter = (unsigned int) atoi(value);
+ daemon_local->flags.offlineLogstorageMaxCounterIdx = (unsigned int) strlen(value);
}
else if (strcmp(token, "OfflineLogstorageCacheSize") == 0)
{
@@ -1272,7 +1272,7 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
daemon_local->baudrate = dlt_convert_serial_speed(speed);
- if (dlt_setup_serial(fd, daemon_local->baudrate) < 0) {
+ if (dlt_setup_serial(fd, (speed_t) daemon_local->baudrate) < 0) {
close(fd);
daemon_local->flags.yvalue[0] = 0;
@@ -1601,7 +1601,7 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
}
/* Allocate permanent buffer for version info */
- version = malloc(size + 1);
+ version = malloc((size_t) (size + 1));
if (version == 0) {
dlt_log(LOG_WARNING, "Cannot allocate memory for ECU version.\n");
@@ -1612,7 +1612,7 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
off_t offset = 0;
while (!feof(f)) {
- offset += fread(version + offset, 1, size, f);
+ offset += fread(version + offset, 1, (size_t) size, f);
if (ferror(f)) {
dlt_log(LOG_WARNING, "Failed to read ECU Software version file.\n");
@@ -1876,10 +1876,10 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
/* Set payload data... */
uiType = DLT_TYPE_INFO_STRG;
- uiSize = strlen(str) + 1;
- msg.datasize = sizeof(uint32_t) + sizeof(uint16_t) + uiSize;
+ uiSize = (uint16_t) (strlen(str) + 1);
+ msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint16_t) + uiSize);
- msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffer = (uint8_t *)malloc((size_t) msg.datasize);
msg.databuffersize = msg.datasize;
if (msg.databuffer == 0) {
@@ -1889,9 +1889,9 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
msg.datasize = 0;
memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiType), sizeof(uint32_t));
- msg.datasize += sizeof(uint32_t);
+ msg.datasize += (uint32_t) sizeof(uint32_t);
memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiSize), sizeof(uint16_t));
- msg.datasize += sizeof(uint16_t);
+ msg.datasize += (uint32_t) sizeof(uint16_t);
memcpy((uint8_t *)(msg.databuffer + msg.datasize), str, uiSize);
msg.datasize += uiSize;
@@ -1901,8 +1901,8 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon,daemon_local,
msg.headerbuffer, sizeof(DltStorageHeader),
msg.headerbuffer + sizeof(DltStorageHeader),
- msg.headersize - sizeof(DltStorageHeader),
- msg.databuffer, msg.datasize, verbose);
+ (int) (msg.headersize - sizeof(DltStorageHeader)),
+ msg.databuffer, (int) msg.datasize, verbose);
free(msg.databuffer);
@@ -2045,7 +2045,7 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
(uint8_t *)receiver->buf,
- receiver->bytesRcvd,
+ (unsigned int) receiver->bytesRcvd,
daemon_local->flags.nflag,
daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
@@ -2057,12 +2057,12 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
&(daemon_local->msg),
daemon_local->flags.vflag);
- bytes_to_be_removed = daemon_local->msg.headersize +
+ bytes_to_be_removed = (int) (daemon_local->msg.headersize +
daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ sizeof(DltStorageHeader));
if (daemon_local->msg.found_serialheader)
- bytes_to_be_removed += sizeof(dltSerialHeader);
+ bytes_to_be_removed += (int) sizeof(dltSerialHeader);
if (daemon_local->msg.resync_offset)
bytes_to_be_removed += daemon_local->msg.resync_offset;
@@ -2118,7 +2118,7 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
(uint8_t *)receiver->buf,
- receiver->bytesRcvd,
+ (unsigned int) receiver->bytesRcvd,
daemon_local->flags.mflag,
daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
@@ -2134,12 +2134,12 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
}
}
- bytes_to_be_removed = daemon_local->msg.headersize +
+ bytes_to_be_removed = (int) (daemon_local->msg.headersize +
daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ sizeof(DltStorageHeader));
if (daemon_local->msg.found_serialheader)
- bytes_to_be_removed += sizeof(dltSerialHeader);
+ bytes_to_be_removed += (int) sizeof(dltSerialHeader);
if (daemon_local->msg.resync_offset)
bytes_to_be_removed += daemon_local->msg.resync_offset;
@@ -2289,7 +2289,7 @@ int dlt_daemon_process_control_messages(
while (dlt_message_read(
&(daemon_local->msg),
(uint8_t *)receiver->buf,
- receiver->bytesRcvd,
+ (unsigned int) receiver->bytesRcvd,
daemon_local->flags.nflag,
daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
@@ -2300,12 +2300,12 @@ int dlt_daemon_process_control_messages(
&(daemon_local->msg),
daemon_local->flags.vflag);
- bytes_to_be_removed = daemon_local->msg.headersize +
+ bytes_to_be_removed = (int) (daemon_local->msg.headersize +
daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ sizeof(DltStorageHeader));
if (daemon_local->msg.found_serialheader)
- bytes_to_be_removed += sizeof(dltSerialHeader);
+ bytes_to_be_removed += (int) sizeof(dltSerialHeader);
if (daemon_local->msg.resync_offset)
bytes_to_be_removed += daemon_local->msg.resync_offset;
@@ -2510,7 +2510,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
int verbose)
{
uint32_t len = sizeof(DltUserControlMsgRegisterApplication);
- int to_remove = 0;
+ uint32_t to_remove = 0;
DltDaemonApplication *application = NULL;
DltDaemonApplication *old_application = NULL;
pid_t old_pid = 0;
@@ -2530,15 +2530,21 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
memset(&userapp, 0, sizeof(DltUserControlMsgRegisterApplication));
origin = rec->buf;
+ /* Adding temp variable to check the return value */
+ int temp = 0;
+
/* We shall not remove data before checking that everything is there. */
- to_remove = dlt_receiver_check_and_get(rec,
+ temp = dlt_receiver_check_and_get(rec,
&userapp,
len,
DLT_RCV_SKIP_HEADER);
- if (to_remove < 0)
+ if (temp < 0)
/* Not enough bytes received */
return -1;
+ else {
+ to_remove = (uint32_t) temp;
+ }
len = userapp.description_length;
@@ -2562,12 +2568,12 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
}
/* adjust to_remove */
- to_remove += sizeof(DltUserHeader) + len;
+ to_remove += (uint32_t) sizeof(DltUserHeader) + len;
/* point to begin of message */
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ if (dlt_receiver_remove(rec, (int) to_remove) != DLT_RETURN_OK) {
dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
@@ -2621,7 +2627,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- int to_remove = 0;
+ uint32_t to_remove = 0;
uint32_t len = sizeof(DltUserControlMsgRegisterContext);
DltUserControlMsgRegisterContext userctxt;
char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
@@ -2643,14 +2649,20 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
memset(&userctxt, 0, sizeof(DltUserControlMsgRegisterContext));
origin = rec->buf;
- to_remove = dlt_receiver_check_and_get(rec,
+ /* Adding temp variable to check the return value */
+ int temp = 0;
+
+ temp = dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER);
- if (to_remove < 0)
+ if (temp < 0)
/* Not enough bytes received */
return -1;
+ else {
+ to_remove = (uint32_t) temp;
+ }
len = userctxt.description_length;
@@ -2674,12 +2686,12 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
}
/* adjust to_remove */
- to_remove += sizeof(DltUserHeader) + len;
+ to_remove += (uint32_t) sizeof(DltUserHeader) + len;
/* point to begin of message */
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ if (dlt_receiver_remove(rec, (int) to_remove) != DLT_RETURN_OK) {
dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
@@ -2753,8 +2765,8 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
if (daemon_local->flags.offlineLogstorageMaxDevices)
/* Store log level set for offline logstorage into context structure*/
context->storage_log_level =
- dlt_daemon_logstorage_get_loglevel(daemon,
- daemon_local->flags.offlineLogstorageMaxDevices,
+ (int8_t) dlt_daemon_logstorage_get_loglevel(daemon,
+ (int8_t) daemon_local->flags.offlineLogstorageMaxDevices,
userctxt.apid,
userctxt.ctid);
else
@@ -2788,7 +2800,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
req = (DltServiceGetLogInfoRequest *)msg.databuffer;
req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
- req->options = daemon_local->flags.autoResponseGetLogInfoOption;
+ req->options = (uint8_t) daemon_local->flags.autoResponseGetLogInfoOption;
dlt_set_id(req->apid, userctxt.apid);
dlt_set_id(req->ctid, userctxt.ctid);
dlt_set_id(req->com, "remo");
@@ -3063,12 +3075,12 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
/* keep not read data in buffer */
- size = daemon_local->msg.headersize +
+ size = (int) (daemon_local->msg.headersize +
daemon_local->msg.datasize - sizeof(DltStorageHeader) +
- sizeof(DltUserHeader);
+ sizeof(DltUserHeader));
if (daemon_local->msg.found_serialheader)
- size += sizeof(dltSerialHeader);
+ size += (int) sizeof(dltSerialHeader);
if (dlt_receiver_remove(rec, size) != DLT_RETURN_OK) {
dlt_log(LOG_WARNING, "failed to remove bytes from receiver.\n");
@@ -3135,10 +3147,10 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
if (context) {
old_log_level = context->log_level;
- context->log_level = userctxt.log_level; /* No endianess conversion necessary*/
+ context->log_level = (int8_t) userctxt.log_level; /* No endianess conversion necessary*/
old_trace_status = context->trace_status;
- context->trace_status = userctxt.trace_status; /* No endianess conversion necessary */
+ context->trace_status = (int8_t) userctxt.trace_status; /* No endianess conversion necessary */
/* The following function sends also the trace status */
if ((context->user_handle >= DLT_FD_MINIMUM) &&
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 7a4b29c..bbee5ea 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 */
- int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */
+ uint32_t 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_client.c b/src/daemon/dlt_daemon_client.c
index 871ae30..2b3b7a1 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -277,7 +277,7 @@ int dlt_daemon_client_send(int sock,
if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
DLT_DAEMON_SEM_LOCK();
/* Store message in history buffer */
- ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0);
+ ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, (unsigned int) size1, data2, (unsigned int) size2, 0, 0);
DLT_DAEMON_SEM_FREE();
if (ret < DLT_RETURN_OK) {
@@ -374,8 +374,8 @@ int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon,
return dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
daemon_local->msg.headerbuffer, sizeof(DltStorageHeader),
daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
- daemon_local->msg.headersize - sizeof(DltStorageHeader),
- daemon_local->msg.databuffer, daemon_local->msg.datasize, verbose);
+ (int) (daemon_local->msg.headersize - sizeof(DltStorageHeader)),
+ daemon_local->msg.databuffer, (int) daemon_local->msg.datasize, verbose);
}
@@ -439,10 +439,10 @@ int dlt_daemon_client_send_control_message(int sock,
dlt_set_id(msg->extendedheader->ctid, ctid);
/* prepare length information */
- msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp);
+ msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
- len = msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
+ len = (int32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
if (len > UINT16_MAX) {
dlt_log(LOG_WARNING, "Huge control message discarded!\n");
@@ -454,8 +454,8 @@ int dlt_daemon_client_send_control_message(int sock,
if ((ret =
dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
msg->headerbuffer + sizeof(DltStorageHeader),
- msg->headersize - sizeof(DltStorageHeader),
- msg->databuffer, msg->datasize, verbose))) {
+ (int) (msg->headersize - sizeof(DltStorageHeader)),
+ msg->databuffer, (int) msg->datasize, verbose))) {
dlt_log(LOG_DEBUG, "dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
return ret;
}
@@ -748,10 +748,10 @@ void dlt_daemon_control_get_software_version(int sock, DltDaemon *daemon, DltDae
}
/* prepare payload of data */
- len = strlen(daemon->ECUVersionString);
+ len = (uint32_t) strlen(daemon->ECUVersionString);
/* msg.datasize = sizeof(serviceID) + sizeof(status) + sizeof(length) + len */
- msg.datasize = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) + len;
+ msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) + len);
if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
@@ -832,7 +832,7 @@ void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDa
resp = (DltServiceGetDefaultLogLevelResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
resp->status = DLT_SERVICE_RESPONSE_OK;
- resp->log_level = daemon->default_log_level;
+ resp->log_level = (uint8_t) daemon->default_log_level;
/* send message */
dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
@@ -859,12 +859,13 @@ void dlt_daemon_control_get_log_info(int sock,
char buf[255];
#endif
- int32_t i, j, offset = 0;
+ int32_t i, j;
+ size_t offset = 0;
char *apid = 0;
int8_t ll, ts;
uint16_t len;
int8_t value;
- int32_t sizecont = 0;
+ size_t sizecont = 0;
int offset_base;
uint32_t sid;
@@ -957,10 +958,10 @@ void dlt_daemon_control_get_log_info(int sock,
if ((req->options == 5) || (req->options == 6) || (req->options == 7))
sizecont += sizeof(int8_t); /* trace status */
- resp.datasize += (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
+ resp.datasize += (uint32_t) (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
(num_contexts * sizecont);
- resp.datasize += sizeof(uint16_t) /* count_app_ids */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* count_app_ids */;
/* Add additional size for response of Mode 7 */
if (req->options == 7) {
@@ -969,10 +970,10 @@ void dlt_daemon_control_get_log_info(int sock,
/* One application, one context */
/* context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose); */
if (context) {
- resp.datasize += sizeof(uint16_t) /* len_context_description */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
if (context->context_description != 0)
- resp.datasize += strlen(context->context_description); /* context_description */
+ resp.datasize += (uint32_t) strlen(context->context_description); /* context_description */
}
}
else
@@ -990,37 +991,37 @@ void dlt_daemon_control_get_log_info(int sock,
context = &(user_list->contexts[offset_base + j]);
if (context) {
- resp.datasize += sizeof(uint16_t) /* len_context_description */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
if (context->context_description != 0)
- resp.datasize += strlen(context->context_description); /* context_description */
+ resp.datasize += (uint32_t) strlen(context->context_description); /* context_description */
}
}
}
/* Space for application description */
if (application) {
- resp.datasize += sizeof(uint16_t) /* len_app_description */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* len_app_description */;
if (application->application_description != 0)
- resp.datasize += strlen(application->application_description); /* app_description */
+ resp.datasize += (uint32_t) strlen(application->application_description); /* app_description */
}
}
else {
/* All applications, all contexts */
for (i = 0; i < user_list->num_contexts; i++) {
- resp.datasize += sizeof(uint16_t) /* len_context_description */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
if (user_list->contexts[i].context_description != 0)
resp.datasize +=
- strlen(user_list->contexts[i].context_description);
+ (uint32_t) strlen(user_list->contexts[i].context_description);
}
for (i = 0; i < user_list->num_applications; i++) {
- resp.datasize += sizeof(uint16_t) /* len_app_description */;
+ resp.datasize += (uint32_t) sizeof(uint16_t) /* len_app_description */;
if (user_list->applications[i].application_description != 0)
- resp.datasize += strlen(user_list->applications[i].application_description); /* app_description */
+ resp.datasize += (uint32_t) strlen(user_list->applications[i].application_description); /* app_description */
}
}
}
@@ -1052,12 +1053,12 @@ void dlt_daemon_control_get_log_info(int sock,
memcpy(resp.databuffer, &sid, sizeof(uint32_t));
offset += sizeof(uint32_t);
- value = (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
+ value = (int8_t) (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
memcpy(resp.databuffer + offset, &value, sizeof(int8_t));
offset += sizeof(int8_t);
- count_app_ids = num_applications;
+ count_app_ids = (uint16_t) num_applications;
if (count_app_ids != 0) {
memcpy(resp.databuffer + offset, &count_app_ids, sizeof(uint16_t));
@@ -1100,9 +1101,9 @@ void dlt_daemon_control_get_log_info(int sock,
#endif
if (req->apid[0] != '\0')
- count_con_ids = num_contexts;
+ count_con_ids = (uint16_t) num_contexts;
else
- count_con_ids = application->num_contexts;
+ count_con_ids = (uint16_t) application->num_contexts;
memcpy(resp.databuffer + offset, &count_con_ids, sizeof(uint16_t));
offset += sizeof(uint16_t);
@@ -1152,7 +1153,7 @@ void dlt_daemon_control_get_log_info(int sock,
/* Mode 7 */
if (req->options == 7) {
if (context->context_description) {
- len = strlen(context->context_description);
+ len = (uint16_t) strlen(context->context_description);
memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
offset += sizeof(uint16_t);
memcpy(resp.databuffer + offset, context->context_description,
@@ -1180,7 +1181,7 @@ void dlt_daemon_control_get_log_info(int sock,
/* Mode 7 */
if (req->options == 7) {
if (application->application_description) {
- len = strlen(application->application_description);
+ len = (uint16_t) strlen(application->application_description);
memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
offset += sizeof(uint16_t);
memcpy(resp.databuffer + offset, application->application_description,
@@ -1306,7 +1307,7 @@ void dlt_daemon_control_service_response(int sock,
resp = (DltServiceResponse *)msg.databuffer;
resp->service_id = service_id;
- resp->status = status;
+ resp->status = (uint8_t) status;
/* send message */
dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
@@ -1534,7 +1535,7 @@ void dlt_daemon_control_callsw_cinjection(int sock,
uint32_t id = 0, id_tmp = 0;
uint8_t *ptr;
DltDaemonContext *context;
- int32_t data_length_inject = 0;
+ uint32_t data_length_inject = 0;
uint32_t data_length_inject_tmp = 0;
int32_t datalength;
@@ -1548,7 +1549,7 @@ void dlt_daemon_control_callsw_cinjection(int sock,
if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) || (msg->databuffer == NULL))
return;
- datalength = msg->datasize;
+ datalength = (int32_t) msg->datasize;
ptr = msg->databuffer;
DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */
@@ -1614,16 +1615,16 @@ void dlt_daemon_control_callsw_cinjection(int sock,
return;
}
- usercontext.data_length_inject = data_length_inject;
+ usercontext.data_length_inject = (uint32_t) data_length_inject;
usercontext.service_id = id;
- memcpy(userbuffer, ptr, data_length_inject); /* Copy received injection to send buffer */
+ memcpy(userbuffer, ptr, (size_t) data_length_inject); /* Copy received injection to send buffer */
/* write to FIFO */
DltReturnValue ret =
dlt_user_log_out3(context->user_handle, &(userheader), sizeof(DltUserHeader),
&(usercontext), sizeof(DltUserControlMsgInjection),
- userbuffer, data_length_inject);
+ userbuffer, (size_t) data_length_inject);
if (ret < DLT_RETURN_OK) {
if (ret == DLT_RETURN_PIPE_ERROR) {
@@ -1666,12 +1667,12 @@ void dlt_daemon_send_log_level(int sock,
if ((context->user_handle >= DLT_FD_MINIMUM) &&
(dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_OK, verbose);
}
else {
dlt_log(LOG_ERR, "Log level could not be sent!\n");
context->log_level = old_log_level;
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
@@ -1711,7 +1712,7 @@ void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
else
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- ret = strncmp(src_str, str, len);
+ ret = (int8_t) strncmp(src_str, str, (size_t) len);
if (ret == 0)
dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose);
@@ -1747,12 +1748,12 @@ void dlt_daemon_control_set_log_level(int sock,
req = (DltServiceSetLogLevel *)(msg->databuffer);
if (daemon_local->flags.enforceContextLLAndTS)
- req->log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+ req->log_level = (uint8_t) getStatus(req->log_level, daemon_local->flags.contextLogLevel);
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
- apid_length = strlen(apid);
- ctid_length = strlen(ctid);
+ apid_length = (int8_t) strlen(apid);
+ ctid_length = (int8_t) strlen(ctid);
if ((apid_length != 0) && (apid[apid_length - 1] == '*') && (ctid[0] == 0)) { /*apid provided having '*' in it and ctid is null*/
dlt_daemon_find_multiple_context_and_send_log_level(sock,
@@ -1760,8 +1761,8 @@ void dlt_daemon_control_set_log_level(int sock,
daemon_local,
1,
apid,
- apid_length - 1,
- req->log_level,
+ (int8_t) (apid_length - 1),
+ (int8_t) req->log_level,
verbose);
}
else if ((ctid_length != 0) && (ctid[ctid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and apid is null*/
@@ -1771,8 +1772,8 @@ void dlt_daemon_control_set_log_level(int sock,
daemon_local,
0,
ctid,
- ctid_length - 1,
- req->log_level,
+ (int8_t) (ctid_length - 1),
+ (int8_t) req->log_level,
verbose);
}
else if ((apid_length != 0) && (apid[apid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
@@ -1783,7 +1784,7 @@ void dlt_daemon_control_set_log_level(int sock,
1,
apid,
DLT_ID_SIZE,
- req->log_level,
+ (int8_t) req->log_level,
verbose);
}
else if ((ctid_length != 0) && (ctid[ctid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
@@ -1794,7 +1795,7 @@ void dlt_daemon_control_set_log_level(int sock,
0,
ctid,
DLT_ID_SIZE,
- req->log_level,
+ (int8_t) req->log_level,
verbose);
}
else {
@@ -1806,7 +1807,7 @@ void dlt_daemon_control_set_log_level(int sock,
/* Set log level */
if (context != 0) {
- dlt_daemon_send_log_level(sock, daemon, daemon_local, context, req->log_level, verbose);
+ dlt_daemon_send_log_level(sock, daemon, daemon_local, context, (int8_t) req->log_level, verbose);
}
else {
dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid,
@@ -1839,12 +1840,12 @@ void dlt_daemon_send_trace_status(int sock,
if ((context->user_handle >= DLT_FD_MINIMUM) &&
(dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_OK, verbose);
}
else {
dlt_log(LOG_ERR, "Trace status could not be sent!\n");
context->trace_status = old_trace_status;
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
@@ -1884,7 +1885,7 @@ void dlt_daemon_find_multiple_context_and_send_trace_status(int sock,
else
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- ret = strncmp(src_str, str, len);
+ ret = (int8_t) strncmp(src_str, str, (size_t) len);
if (ret == 0)
dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, tracestatus, verbose);
@@ -1920,12 +1921,12 @@ void dlt_daemon_control_set_trace_status(int sock,
req = (DltServiceSetLogLevel *)(msg->databuffer);
if (daemon_local->flags.enforceContextLLAndTS)
- req->log_level = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+ req->log_level = (uint8_t) getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
- apid_length = strlen(apid);
- ctid_length = strlen(ctid);
+ apid_length = (int8_t) strlen(apid);
+ ctid_length = (int8_t) strlen(ctid);
if ((apid_length != 0) && (apid[apid_length - 1] == '*') && (ctid[0] == 0)) { /*apid provided having '*' in it and ctid is null*/
dlt_daemon_find_multiple_context_and_send_trace_status(sock,
@@ -1933,8 +1934,8 @@ void dlt_daemon_control_set_trace_status(int sock,
daemon_local,
1,
apid,
- apid_length - 1,
- req->log_level,
+ (int8_t) (apid_length - 1),
+ (int8_t) req->log_level,
verbose);
}
else if ((ctid_length != 0) && (ctid[ctid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and apid is null*/
@@ -1945,8 +1946,8 @@ void dlt_daemon_control_set_trace_status(int sock,
daemon_local,
0,
ctid,
- ctid_length - 1,
- req->log_level,
+ (int8_t) (ctid_length - 1),
+ (int8_t) req->log_level,
verbose);
}
else if ((apid_length != 0) && (apid[apid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
@@ -1957,7 +1958,7 @@ void dlt_daemon_control_set_trace_status(int sock,
1,
apid,
DLT_ID_SIZE,
- req->log_level,
+ (int8_t) req->log_level,
verbose);
}
else if ((ctid_length != 0) && (ctid[ctid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
@@ -1968,7 +1969,7 @@ void dlt_daemon_control_set_trace_status(int sock,
0,
ctid,
DLT_ID_SIZE,
- req->log_level,
+ (int8_t) req->log_level,
verbose);
}
else {
@@ -1976,7 +1977,7 @@ void dlt_daemon_control_set_trace_status(int sock,
/* Set trace status */
if (context != 0) {
- dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, req->log_level, verbose);
+ dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, (int8_t) req->log_level, verbose);
}
else {
dlt_vlog(LOG_ERR,
@@ -2003,7 +2004,7 @@ void dlt_daemon_control_set_default_log_level(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetDefaultLogLevel *req;
- int32_t id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
+ uint32_t id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
return;
@@ -2019,7 +2020,7 @@ void dlt_daemon_control_set_default_log_level(int sock,
if (daemon_local->flags.enforceContextLLAndTS)
daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
else
- daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
+ daemon->default_log_level = (int8_t) req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the default log level */
dlt_daemon_user_send_default_update(daemon, verbose);
@@ -2040,7 +2041,7 @@ void dlt_daemon_control_set_all_log_level(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetDefaultLogLevel *req = NULL;
- int32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
+ uint32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
int8_t loglevel = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
@@ -2058,7 +2059,7 @@ void dlt_daemon_control_set_all_log_level(int sock,
if (daemon_local->flags.enforceContextLLAndTS)
loglevel = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
else
- loglevel = req->log_level; /* No endianess conversion necessary */
+ loglevel = (int8_t) req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_log_level_update(daemon, loglevel, verbose);
@@ -2080,7 +2081,7 @@ void dlt_daemon_control_set_default_trace_status(int sock,
/* Payload of request message */
DltServiceSetDefaultLogLevel *req;
- int32_t id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
+ uint32_t id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
return;
@@ -2096,7 +2097,7 @@ void dlt_daemon_control_set_default_trace_status(int sock,
if (daemon_local->flags.enforceContextLLAndTS)
daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
else
- daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
+ daemon->default_trace_status = (int8_t) req->log_level; /* No endianess conversion necessary*/
/* Send Update to all contexts using the default trace status */
dlt_daemon_user_send_default_update(daemon, verbose);
@@ -2117,7 +2118,7 @@ void dlt_daemon_control_set_all_trace_status(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetDefaultLogLevel *req = NULL;
- int32_t id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
+ uint32_t id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
int8_t tracestatus = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
@@ -2136,7 +2137,7 @@ void dlt_daemon_control_set_all_trace_status(int sock,
if (daemon_local->flags.enforceContextLLAndTS)
tracestatus = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
else
- tracestatus = req->log_level; /* No endianess conversion necessary */
+ tracestatus = (int8_t) req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_trace_status_update(daemon, tracestatus, verbose);
@@ -2157,7 +2158,7 @@ void dlt_daemon_control_set_timing_packets(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetVerboseMode *req; /* request uses same struct as set verbose mode */
- int32_t id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
+ uint32_t id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
return;
@@ -2227,7 +2228,7 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
- len = msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
+ len = (int32_t) (msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
if (len > UINT16_MAX) {
dlt_log(LOG_WARNING, "Huge control message discarded!\n");
@@ -2672,7 +2673,7 @@ void dlt_daemon_control_passive_node_connect(int sock,
if (dlt_gateway_process_on_demand_request(&daemon_local->pGateway,
daemon_local,
req->node_id,
- req->connection_status,
+ (int) req->connection_status,
verbose) < 0)
dlt_daemon_control_service_response(sock,
daemon,
@@ -2745,7 +2746,7 @@ void dlt_daemon_control_passive_node_connect_status(int sock,
memset(resp, 0, msg.datasize);
resp->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
resp->status = DLT_SERVICE_RESPONSE_OK;
- resp->num_connections = daemon_local->pGateway.num_connections;
+ resp->num_connections = (uint32_t) daemon_local->pGateway.num_connections;
for (i = 0; i < resp->num_connections; i++) {
if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX) {
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index 35ad9d6..b57b33e 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -143,7 +143,7 @@ DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon,
int dlt_daemon_init_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- int append_length = 0;
+ size_t append_length = 0;
if (daemon == NULL)
return DLT_RETURN_ERROR;
@@ -215,9 +215,9 @@ int dlt_daemon_init(DltDaemon *daemon,
daemon->user_list = NULL;
daemon->num_user_lists = 0;
- daemon->default_log_level = InitialContextLogLevel;
- daemon->default_trace_status = InitialContextTraceStatus;
- daemon->force_ll_ts = ForceLLTS;
+ daemon->default_log_level = (int8_t) InitialContextLogLevel;
+ daemon->default_trace_status = (int8_t) InitialContextTraceStatus;
+ daemon->force_ll_ts = (int8_t) ForceLLTS;
daemon->overflow_counter = 0;
@@ -236,8 +236,8 @@ int dlt_daemon_init(DltDaemon *daemon,
dlt_vlog(LOG_INFO, "Ringbuffer configuration: %lu/%lu/%lu\n",
RingbufferMinSize, RingbufferMaxSize, RingbufferStepSize);
- if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize, RingbufferMaxSize,
- RingbufferStepSize) == DLT_RETURN_ERROR)
+ if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), (uint32_t) RingbufferMinSize, (uint32_t) RingbufferMaxSize,
+ (uint32_t) RingbufferStepSize) == DLT_RETURN_ERROR)
return -1;
daemon->storage_handle = NULL;
@@ -291,7 +291,7 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
if (gateway_mode == 0) {
/* initialize application list */
- daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
+ daemon->user_list = calloc((size_t) nodes, sizeof(DltDaemonRegisteredUsers));
if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
@@ -305,7 +305,7 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
nodes += gateway->num_connections;
/* initialize application list */
- daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
+ daemon->user_list = calloc((size_t) nodes, sizeof(DltDaemonRegisteredUsers));
if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
@@ -557,7 +557,7 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
/* Sort */
if (new_application) {
qsort(user_list->applications,
- user_list->num_applications,
+ (size_t) user_list->num_applications,
sizeof(DltDaemonApplication),
dlt_daemon_cmp_apid);
@@ -595,7 +595,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
application->application_description = NULL;
}
- pos = application - (user_list->applications);
+ pos = (int) (application - (user_list->applications));
/* move all applications above pos to pos */
memmove(&(user_list->applications[pos]),
@@ -642,7 +642,7 @@ DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
dlt_set_id(application.apid, apid);
return (DltDaemonApplication *)bsearch(&application,
user_list->applications,
- user_list->num_applications,
+ (size_t) user_list->num_applications,
sizeof(DltDaemonApplication),
dlt_daemon_cmp_apid);
}
@@ -925,7 +925,7 @@ DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
/* Sort */
if (new_context) {
qsort(user_list->contexts,
- user_list->num_contexts,
+ (size_t) user_list->num_contexts,
sizeof(DltDaemonContext),
dlt_daemon_cmp_apid_ctid);
@@ -964,7 +964,7 @@ int dlt_daemon_context_del(DltDaemon *daemon,
context->context_description = NULL;
}
- pos = context - (user_list->contexts);
+ pos = (int) (context - (user_list->contexts));
/* move all contexts above pos to pos */
memmove(&(user_list->contexts[pos]),
@@ -1018,7 +1018,7 @@ DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
return (DltDaemonContext *)bsearch(&context,
user_list->contexts,
- user_list->num_contexts,
+ (size_t) user_list->num_contexts,
sizeof(DltDaemonContext),
dlt_daemon_cmp_apid_ctid);
}
@@ -1356,14 +1356,14 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
if ((context->storage_log_level != DLT_LOG_DEFAULT) &&
(daemon->maintain_logstorage_loglevel != DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_OFF))
- usercontext.log_level = context->log_level >
- context->storage_log_level ? context->log_level : context->storage_log_level;
+ usercontext.log_level = (uint8_t) (context->log_level >
+ context->storage_log_level ? context->log_level : context->storage_log_level);
else /* Storage log level is not updated (is DEFAULT) then no device is yet connected so ignore */
usercontext.log_level =
- ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
+ (uint8_t) ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
usercontext.trace_status =
- ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
+ (uint8_t) ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
usercontext.log_level_pos = context->log_level_pos;
@@ -1464,9 +1464,9 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
unlink(filename1);
}
- daemon->default_log_level = InitialContextLogLevel;
- daemon->default_trace_status = InitialContextTraceStatus;
- daemon->force_ll_ts = InitialEnforceLlTsStatus;
+ daemon->default_log_level = (int8_t) InitialContextLogLevel;
+ daemon->default_trace_status = (int8_t) InitialContextTraceStatus;
+ daemon->force_ll_ts = (int8_t) InitialEnforceLlTsStatus;
/* Reset all other things (log level, trace status, etc.
* to default values */
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index a438c03..78346fd 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,
- msg_size);
+ (int) 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, size1);
+ ret = dlt_connection_send(con, data1, (size_t) size1);
if ((data2 != NULL) && (ret == DLT_RETURN_OK))
- ret = dlt_connection_send(con, data2, size2);
+ ret = dlt_connection_send(con, data2, (size_t) size2);
return ret;
}
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 0d463da..6c33d23 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -109,8 +109,8 @@ 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 = ev->nfds;
- int max = 2 * ev->max_nfds;
+ int i = (int) ev->nfds;
+ int max = (int) (2 * ev->max_nfds);
struct pollfd *tmp = realloc(ev->pfd, max * sizeof(*ev->pfd));
if (!tmp) {
@@ -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 = ev->nfds;
+ unsigned int nfds = (unsigned int) 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 5d21a76..8471dc2 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, (len - 2));
+ memcpy(ecuid, key, (size_t) (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), (len - 1));
+ strncpy(ctid, (key + 2), (size_t) (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, (len - 2));
+ strncpy(apid, key + 1, (size_t) (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 = strlen(tok);
+ len = (int) 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 = strlen(key);
+ len = (int) 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 = loglevel;
+ req.log_level = (uint8_t) loglevel;
if (dlt_gateway_send_control_message(con, &ctrl, (void *)&req, verbose) != 0) {
dlt_vlog(LOG_ERR,
@@ -487,7 +487,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
{
int ll = DLT_LOG_DEFAULT;
int num = 0;
- int i = 0;
+ uint32_t 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 = config[j]->log_level;
+ storage_loglevel = (int8_t) config[j]->log_level;
break;
}
- configured_loglevel = config[j]->log_level;
+ configured_loglevel = (int8_t) 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)
{
- int i = 0;
+ uint32_t 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)
{
- int i = 0;
+ uint32_t i = 0;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1152,7 +1152,7 @@ int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon,
char *mnt_point,
int verbose)
{
- int i = 0;
+ uint32_t 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)
{
- int i = 0;
+ uint32_t 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 = strlen(mnt_point);
+ len1 = (int) strlen(mnt_point);
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
- len2 = strlen(daemon->storage_handle[i].device_mount_point);
+ len2 = (int) 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, len) == 0)
+ if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, (size_t) len) == 0)
return &daemon->storage_handle[i];
}
diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c
index 36b7990..1b6507d 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, size1))
+ if (0 > write(sock, data1, (size_t) size1))
return DLT_DAEMON_ERROR_SEND_FAILED;
if (data2 && (size2 > 0))
- if (0 > write(sock, data2, size2))
+ if (0 > write(sock, data2, (size_t) 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 9db48b9..410c702 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,
- message_size - data_sent,
+ (size_t) (message_size - data_sent),
0);
if (ret < 0) {