summaryrefslogtreecommitdiff
path: root/src/shared/dlt_common.c
diff options
context:
space:
mode:
authorDinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>2020-10-27 15:35:51 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-01-06 09:27:28 +0900
commit906578850094f8f5e9ce488c71ad831b2f35330c (patch)
tree90403e585db0470fe67ac9d2c677f772d3c12468 /src/shared/dlt_common.c
parent7e7ae6dbb5579c2e163d87ff7bcc774de459b96b (diff)
downloadDLT-daemon-906578850094f8f5e9ce488c71ad831b2f35330c.tar.gz
library: fix conversion warnings
- Change the data type of variable 'size' in DltContextData struct (dlt_user.h.in). Variable 'size' was used repeated with function 'sizeof()' many time, so change type to 'size_t' can avoid a lot of warnings. - Adding temporary variable to calculate the datasize header (define in dlt_common.h) in 'dlt_common.c' file. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
Diffstat (limited to 'src/shared/dlt_common.c')
-rw-r--r--src/shared/dlt_common.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 9cd88f9..3aae317 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -996,18 +996,26 @@ int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int
msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + extra_size);
msg->datasize = DLT_BETOH_16(msg->standardheader->len) - (msg->headersize - sizeof(DltStorageHeader));
- if (verbose) {
- dlt_vlog(LOG_DEBUG, "BufferLength=%d, HeaderSize=%d, DataSize=%d\n",
- length, msg->headersize, msg->datasize);
- }
+ /* calculate complete size of payload */
+ int32_t temp_datasize;
+ temp_datasize = DLT_BETOH_16(msg->standardheader->len) - (msg->headersize - sizeof(DltStorageHeader));
/* check data size */
- if (msg->datasize < 0) {
+ if (temp_datasize < 0) {
dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short (%d)!\n",
- msg->datasize);
+ temp_datasize);
return DLT_MESSAGE_ERROR_CONTENT;
}
+ else {
+ msg->datasize = (uint32_t) temp_datasize;
+ }
+
+ /* check if verbose mode is on*/
+ if (verbose) {
+ dlt_vlog(LOG_DEBUG, "BufferLength=%d, HeaderSize=%d, DataSize=%d\n",
+ length, msg->headersize, msg->datasize);
+ }
/* load standard header extra parameters and Extended header if used */
if (extra_size > 0) {
@@ -1204,19 +1212,25 @@ DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
file->msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
(DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
- file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
- if (verbose) {
- dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
- file->msg.headersize, file->msg.datasize);
- }
+ /* calculate complete size of payload */
+ int32_t temp_datasize;
+ temp_datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
/* check data size */
- if (file->msg.datasize < 0) {
+ if (temp_datasize < 0) {
dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short! (%d)\n",
- file->msg.datasize);
+ temp_datasize);
return DLT_RETURN_ERROR;
+ } else {
+ file->msg.datasize = (uint32_t) temp_datasize;
+ }
+
+ /* check if verbose mode is on */
+ if (verbose) {
+ dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
+ file->msg.headersize, file->msg.datasize);
}
return DLT_RETURN_OK;
@@ -1294,20 +1308,27 @@ DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
file->msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
(DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
- file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
- if (verbose) {
- dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
- file->msg.headersize, file->msg.datasize);
- }
+ /* calculate complete size of payload */
+ int32_t temp_datasize;
+ temp_datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
/* check data size */
- if (file->msg.datasize < 0) {
+ if (temp_datasize < 0) {
dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short! (%d)\n",
- file->msg.datasize);
+ temp_datasize);
return DLT_RETURN_ERROR;
}
+ else {
+ file->msg.datasize = (uint32_t) temp_datasize;
+ }
+
+ /* check if verbose mode is on */
+ if (verbose) {
+ dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
+ file->msg.headersize, file->msg.datasize);
+ }
return DLT_RETURN_OK;
}
@@ -1934,7 +1955,7 @@ DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, DltReceiverType
/** Reuse the receiver buffer if it exists and the buffer size
* is not changed. If not, free the old one and allocate a new buffer.
*/
- if ((NULL != receiver->buffer) && (buffersize != receiver->buffersize)) {
+ if ((NULL != receiver->buffer) && ((uint32_t) buffersize != receiver->buffersize)) {
free(receiver->buffer);
receiver->buffer = NULL;
}