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/dlt_filetransfer.c | |
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/dlt_filetransfer.c')
-rw-r--r-- | src/lib/dlt_filetransfer.c | 21 |
1 files changed, 13 insertions, 8 deletions
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, |