summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorFelix Herrmann <fherrmann@de.adit-jv.com>2020-01-13 10:40:25 +0100
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-07-06 10:04:07 +0900
commit676e8fc1ba927dc84df82b508d796e31d9fd120c (patch)
tree141271d339f1ba68d0b29fd124e8eaa5d3d99fd4 /src/shared
parentec391decd94ac9f6c6133c24a41c8afb2c01623f (diff)
downloadDLT-daemon-676e8fc1ba927dc84df82b508d796e31d9fd120c.tar.gz
fix some gcc9 compiler warnings
Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/dlt_common.c7
-rw-r--r--src/shared/dlt_config_file_parser.c16
-rw-r--r--src/shared/dlt_offline_trace.c14
3 files changed, 22 insertions, 15 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 642d43d..670b01b 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -3042,21 +3042,22 @@ void dlt_get_version(char *buf, size_t size)
return;
}
+/* Clang does not like these macros, because they are not reproducable */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdate-time"
snprintf(buf,
size,
"DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n%s %s %s %s\n",
_DLT_PACKAGE_VERSION,
_DLT_PACKAGE_VERSION_STATE,
_DLT_PACKAGE_REVISION,
-/* Clang does not like these macros, because they are not reproducable */
-#pragma clang diagnostic ignored "-Wdate-time"
__DATE__,
__TIME__,
-#pragma clang diagnostic error "-Wdate-time"
_DLT_SYSTEMD_ENABLE,
_DLT_SYSTEMD_WATCHDOG_ENABLE,
_DLT_TEST_ENABLE,
_DLT_SHM_ENABLE);
+#pragma GCC diagnostic pop
}
void dlt_get_major_version(char *buf, size_t size)
diff --git a/src/shared/dlt_config_file_parser.c b/src/shared/dlt_config_file_parser.c
index e701341..7392836 100644
--- a/src/shared/dlt_config_file_parser.c
+++ b/src/shared/dlt_config_file_parser.c
@@ -288,17 +288,21 @@ static int dlt_config_file_get_key_value(char *line, char *str1, char *str2)
ptr = strtok_r(line, delimiter, &save_ptr);
- if (ptr != NULL) /* get key */
- strncpy(str1, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
- else
+ if (ptr != NULL) { /* get key */
+ strncpy(str1, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+ str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+ } else {
return -1;
+ }
ptr = strtok_r(NULL, delimiter, &save_ptr);
- if (ptr != NULL)
- strncpy(str2, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
- else
+ if (ptr != NULL) {
+ strncpy(str2, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+ str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+ } else {
return -1;
+ }
return 0;
}
diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c
index 060b97f..1f6a5d5 100644
--- a/src/shared/dlt_offline_trace.c
+++ b/src/shared/dlt_offline_trace.c
@@ -116,13 +116,15 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha
}
if (num > 0) {
- if (tmp_old != NULL)
- if (strlen(tmp_old) < NAME_MAX)
- strncpy(oldest, tmp_old, NAME_MAX);
+ if ((tmp_old != NULL) && (strlen(tmp_old) < NAME_MAX)) {
+ strncpy(oldest, tmp_old, NAME_MAX);
+ oldest[NAME_MAX] = '\0';
+ }
- if (tmp_new != NULL)
- if (strlen(tmp_old) < NAME_MAX)
- strncpy(newest, tmp_new, NAME_MAX);
+ if ((tmp_new != NULL) && (strlen(tmp_old) < NAME_MAX)) {
+ strncpy(newest, tmp_new, NAME_MAX);
+ oldest[NAME_MAX] = '\0';
+ }
}
/* free scandir result */