diff options
author | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2019-06-12 16:18:02 +0900 |
---|---|---|
committer | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2019-06-19 11:00:37 +0900 |
commit | 6088448cdfe3cd152c53136544acc4ee7a508a84 (patch) | |
tree | 3b8ed06c2502c8d2daae736b6af2e1d9701f50b4 /src/lib | |
parent | 3e73652e5dce1e841d959f521727a0952c2d1c92 (diff) | |
download | DLT-daemon-6088448cdfe3cd152c53136544acc4ee7a508a84.tar.gz |
Fix alerts from lgtm
Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dlt_client.c | 2 | ||||
-rw-r--r-- | src/lib/dlt_filetransfer.c | 21 | ||||
-rw-r--r-- | src/lib/dlt_user.c | 4 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c index dacff27..af7e118 100644 --- a/src/lib/dlt_client.c +++ b/src/lib/dlt_client.c @@ -801,7 +801,7 @@ DltReturnValue dlt_client_send_all_trace_status(DltClient *client, uint8_t trace payload = (uint8_t *)malloc(sizeof(DltServiceSetDefaultLogLevel)); if (payload == 0) { - dlt_vlog(LOG_ERR, "%s: Could not allocate memory %d\n", __func__, sizeof(DltServiceSetDefaultLogLevel)); + dlt_vlog(LOG_ERR, "%s: Could not allocate memory %zu\n", __func__, sizeof(DltServiceSetDefaultLogLevel)); return DLT_RETURN_ERROR; } diff --git a/src/lib/dlt_filetransfer.c b/src/lib/dlt_filetransfer.c index 736a7d6..3304ff6 100644 --- a/src/lib/dlt_filetransfer.c +++ b/src/lib/dlt_filetransfer.c @@ -167,18 +167,19 @@ time_t getFileCreationDate(const char *file, int *ok) * @param file Absolute file path * @return Returns the creation date of a file */ -char *getFileCreationDate2(const char *file, int *ok) +void getFileCreationDate2(const char *file, int *ok, char *date) { struct stat st; + struct tm ts; if (-1 == stat(file, &st)) { *ok = 0; - return 0; + date = 0; } *ok = 1; - struct tm *ts = localtime(&st.st_ctime); - return asctime(ts); + localtime_r(&st.st_ctime, &ts); + asctime_r(&ts, date); } /*!Checks if the file exists */ @@ -249,7 +250,8 @@ void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filenam DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "), DLT_STRING(filename)); - char *fcreationdate = getFileCreationDate2(filename, &ok); + char fcreationdate[50]; + getFileCreationDate2(filename, &ok, fcreationdate); if (!ok) DLT_LOG(*fileContext, @@ -313,7 +315,8 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename) DLT_STRING("dlt_user_log_file_infoAbout, Error getting serial number of file:"), DLT_STRING(filename)); - char *creationdate = getFileCreationDate2(filename, &ok); + char creationdate[50]; + getFileCreationDate2(filename, &ok, creationdate); if (!ok) DLT_LOG(*fileContext, @@ -448,7 +451,8 @@ int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename DLT_LOG(*fileContext, DLT_LOG_ERROR, DLT_STRING("dlt_user_log_file_header_alias, Error getting size of file:"), DLT_STRING(filename)); - char *fcreationdate = getFileCreationDate2(filename, &ok); + char fcreationdate[50]; + getFileCreationDate2(filename, &ok, fcreationdate); if (!ok) DLT_LOG(*fileContext, DLT_LOG_ERROR, @@ -503,7 +507,8 @@ int dlt_user_log_file_header(DltContext *fileContext, const char *filename) DLT_STRING("dlt_user_log_file_header, Error getting size of file:"), DLT_STRING(filename)); - char *fcreationdate = getFileCreationDate2(filename, &ok); + char fcreationdate[50]; + getFileCreationDate2(filename, &ok, fcreationdate); if (!ok) DLT_LOG(*fileContext, DLT_LOG_ERROR, diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 7c8ca90..dbaf7f1 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -2065,7 +2065,7 @@ DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data) return DLT_RETURN_WRONG_PARAMETER; if (!dlt_user_initialised) { - dlt_vlog(LOG_WARNING, "%user_initialised false\n", __FUNCTION__); + dlt_vlog(LOG_WARNING, "%s user_initialised false\n", __FUNCTION__); return DLT_RETURN_ERROR; } @@ -2815,7 +2815,7 @@ void dlt_user_trace_network_segmented_thread(void *unused) /* This case will not happen. */ /* When this thread is interrupted by signal, mq_receive() will not return */ /* partial read length and will return -1. And also no data is removed from mq. */ - dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %d\n", read); + dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %zd\n", read); continue; } |