summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
diff options
context:
space:
mode:
authorsebastienr <sebastien.raillet@marelli.com>2021-11-09 09:53:48 +0100
committerGitHub <noreply@github.com>2021-11-09 17:53:48 +0900
commitac5b12440da75a36fa7d98a32545acf1e696004f (patch)
treec53947134ab4d83182ad5431449e5989cfc3f766 /src/lib/dlt_user.c
parent05dec28345ebed16a4a39fea85848c0b8b907c05 (diff)
downloadDLT-daemon-ac5b12440da75a36fa7d98a32545acf1e696004f.tar.gz
fix -Wformat issues reported by clang (#349)
* some previous dlt_vlog was using %lu specifier to display an uint64_t variable. However, this isn't portable as depending on the system you're targeting (32bits, 64bits, Linux, android, etc.), the uint64_t can be an unsigned long long. This prevents compilation on system where -Werror and -Wformat is activated coupled with a less tolerant compiler (e.g clang). Instead, PRIxN macros (e.g PRIu64 for uint64_t) are now used as specifier to ensure compatibility for each platforms * for bytes_read which is of type ssize_t, zd specifier is used as indicated in C99 standard * for st_size (from struct stat) which is of type off_t, POSIX says that it should be a signed integer. To be safe, we now use %jd specifier to ensure that it will fit correctly
Diffstat (limited to 'src/lib/dlt_user.c')
-rw-r--r--src/lib/dlt_user.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index fff621e..5a880dc 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -1071,7 +1071,7 @@ DltReturnValue dlt_free(void)
if (bytes_read >= 0) {
if (!bytes_read)
break;
- dlt_vlog(LOG_NOTICE, "[%s] data is still readable... [%ld] bytes read\n",
+ dlt_vlog(LOG_NOTICE, "[%s] data is still readable... [%zd] bytes read\n",
__func__, bytes_read);
}
}
@@ -3878,7 +3878,7 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
/* Get file size */
struct stat st;
fstat(dlt_user.dlt_log_handle, &st);
- dlt_vlog(LOG_DEBUG, "%s: Current file size=[%ld]\n", __func__,
+ dlt_vlog(LOG_DEBUG, "%s: Current file size=[%jd]\n", __func__,
st.st_size);
/* Check filesize */
@@ -3888,7 +3888,7 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
if (msg_size > dlt_user.filesize_max) {
dlt_user_file_reach_max = true;
dlt_vlog(LOG_ERR,
- "%s: File size (%ld bytes) reached to defined maximum size (%d bytes)\n",
+ "%s: File size (%jd bytes) reached to defined maximum size (%d bytes)\n",
__func__, st.st_size, dlt_user.filesize_max);
return DLT_RETURN_FILESZERR;
}