summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Herrmann <fherrmann@de.adit-jv.com>2020-01-10 16:10:33 +0100
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-07-06 10:04:07 +0900
commitec391decd94ac9f6c6133c24a41c8afb2c01623f (patch)
tree7ac109da07b3cbeb25bede7ed55436c32332f09d
parentc79ac621dbb7e774c90079ee1682857b4b0a2cfa (diff)
downloadDLT-daemon-ec391decd94ac9f6c6133c24a41c8afb2c01623f.tar.gz
fix clang warnings about GNU stuff
Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
-rw-r--r--include/dlt/dlt_user_macros.h16
-rw-r--r--src/daemon/dlt_daemon_socket.c11
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage_behavior.c47
-rw-r--r--src/shared/dlt_offline_trace.c4
4 files changed, 36 insertions, 42 deletions
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index f1a531b..f313270 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -202,9 +202,9 @@
* Send log message with variable list of messages (intended for verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
- * @param ARGS variable list of arguments
+ * @param ... variable list of arguments
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
- * use a semicolon instead of a comma to separate the ARGS.
+ * use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG(hContext, DLT_LOG_INFO, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
@@ -229,9 +229,9 @@
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TS timestamp to be used for log message
- * @param ARGS variable list of arguments
+ * @param ... variable list of arguments
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
- * use a semicolon instead of a comma to separate the ARGS.
+ * use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_TS(hContext, DLT_LOG_INFO, timestamp, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
@@ -258,11 +258,11 @@
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
- * @param ARGS variable list of arguments:
+ * @param ... variable list of arguments
* calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
* DLT_INT(), DLT_UINT(), DLT_RAW()
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
- * use a semicolon instead of a comma to separate the ARGS.
+ * use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_ID(hContext, DLT_LOG_INFO, 0x1234, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
@@ -288,11 +288,11 @@
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
* @param TS timestamp to be used for log message
- * @param ARGS variable list of arguments:
+ * @param ... variable list of arguments
* calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
* DLT_INT(), DLT_UINT(), DLT_RAW()
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
- * use a semicolon instead of a comma to separate the ARGS.
+ * use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_ID_TS(hContext, DLT_LOG_INFO, 0x1234, timestamp, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index 65d9a5c..a2cf08a 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -193,15 +193,16 @@ int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size
int data_sent = 0;
while (data_sent < message_size) {
- ssize_t ret = send(sock, (char *)data_buffer + data_sent, message_size - data_sent, 0);
+ ssize_t ret = send(sock,
+ (uint8_t*)data_buffer + data_sent,
+ message_size - data_sent,
+ 0);
if (ret < 0) {
dlt_vlog(LOG_WARNING,
- "dlt_daemon_socket_sendreliable: socket send failed [errno: %d]!\n",
- errno);
+ "%s: socket send failed [errno: %d]!\n", __func__, errno);
return DLT_DAEMON_ERROR_SEND_FAILED;
- }
- else {
+ } else {
data_sent += ret;
}
}
diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
index 3f7555e..d0ea325 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
@@ -515,17 +515,13 @@ DLT_STATIC int dlt_logstorage_find_dlt_header(void *ptr,
unsigned int offset,
unsigned int cnt)
{
- int index = 0;
- char substring[] = { 'D', 'L', 'T', 0x01 };
+ const char magic[] = { 'D', 'L', 'T', 0x01 };
+ const char *cache = (char*)ptr + offset;
- while (cnt > 0) {
- if (*((char *)ptr + offset + index) == 'D') {
- if (strncmp((char *)ptr + offset + index, substring, 4) == 0)
- return index;
- }
-
- cnt--;
- index++;
+ unsigned int i;
+ for (i = 0; i < cnt; i++) {
+ if ((cache[i] == 'D') && (strncmp(&cache[i], magic, 4) == 0))
+ return i;
}
return -1;
@@ -545,18 +541,15 @@ DLT_STATIC int dlt_logstorage_find_last_dlt_header(void *ptr,
unsigned int offset,
unsigned int cnt)
{
- char substring[] = {'D', 'L', 'T', 0x01};
- while(cnt > 0)
- {
- if (*((char *)ptr + offset + cnt) == 'D')
- {
- if (strncmp((char *)ptr + offset + cnt, substring, 4) == 0)
- {
- return cnt;
- }
- }
- cnt--;
+ const char magic[] = {'D', 'L', 'T', 0x01};
+ const char *cache = (char*)ptr + offset;
+
+ unsigned int i;
+ for (i = cnt; i > 0; i--) {
+ if ((cache[i] == 'D') && (strncmp(&cache[i], magic, 4) == 0))
+ return i;
}
+
return -1;
}
@@ -653,7 +646,7 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config,
}
}
- ret = fwrite((char *)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);
@@ -691,7 +684,7 @@ DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config,
}
}
- ret = fwrite((char *)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);
@@ -962,7 +955,7 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config,
DltLogStorageCacheFooter *footer = NULL;
int msg_size;
int remain_cache_size;
- char *curr_write_addr = NULL;
+ uint8_t *curr_write_addr = NULL;
int ret = 0;
unsigned int cache_size;
@@ -983,7 +976,7 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config,
cache_size = config->file_size;
}
- footer = (DltLogStorageCacheFooter *)((char *)config->cache + cache_size);
+ footer = (DltLogStorageCacheFooter *)((uint8_t*)config->cache + cache_size);
if (footer == NULL)
{
dlt_log(LOG_ERR, "Cannot retrieve cache footer. Address is NULL\n");
@@ -994,7 +987,7 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config,
if (msg_size <= remain_cache_size) /* add at current position */
{
- curr_write_addr = (char *)config->cache + footer->offset;
+ curr_write_addr = (uint8_t*)config->cache + footer->offset;
footer->offset += msg_size;
if (footer->wrap_around_cnt < 1) {
footer->end_sync_offset = footer->offset;
@@ -1123,7 +1116,7 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
cache_size = config->file_size;
}
- footer = (DltLogStorageCacheFooter *)((char *)config->cache + cache_size);
+ footer = (DltLogStorageCacheFooter *)((uint8_t*)config->cache + cache_size);
if (footer == NULL)
{
dlt_log(LOG_ERR, "Cannot retrieve cache information\n");
diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c
index 303d6b3..060b97f 100644
--- a/src/shared/dlt_offline_trace.c
+++ b/src/shared/dlt_offline_trace.c
@@ -195,7 +195,7 @@ DltReturnValue dlt_offline_trace_create_new_file(DltOfflineTrace *trace)
DLT_OFFLINETRACE_FILENAME_TIMESTAMP_DELI, timestamp,
DLT_OFFLINETRACE_FILENAME_EXT);
- if ((ret < 0) || (ret >= (int)sizeof(trace->filename))) {
+ if ((ret < 0) || ((size_t)ret >= (int)sizeof(trace->filename))) {
printf("dlt_offlinetrace filename cannot be concatenated\n");
return DLT_RETURN_ERROR;
}
@@ -203,7 +203,7 @@ DltReturnValue dlt_offline_trace_create_new_file(DltOfflineTrace *trace)
ret = snprintf(file_path, sizeof(file_path), "%s/%s",
trace->directory, trace->filename);
- if ((ret < 0) || (ret >= (int)sizeof(file_path))) {
+ if ((ret < 0) || ((size_t)ret >= (int)sizeof(file_path))) {
printf("dlt_offlinetrace file path cannot be concatenated\n");
return DLT_RETURN_ERROR;
}