[PATCH] nfsdcltrack: don't assume time_t is long int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In musl 1.2.x, time_t is defined to 64 bit integer unconditionally.
Let's not assume time_t is long int, but always cast to int64_t for
printf(3).

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx>
---
 inttypes.h and PRId64 is being used by utils/idmapd, so I think we won't have
 more incompatibility problem with this change.
 utils/nfsdcltrack/nfsdcltrack.c | 3 ++-
 utils/nfsdcltrack/sqlite.c      | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
index e926f1c0..5edf0ca4 100644
--- a/utils/nfsdcltrack/nfsdcltrack.c
+++ b/utils/nfsdcltrack/nfsdcltrack.c
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <getopt.h>
 #include <string.h>
@@ -525,7 +526,7 @@ cltrack_gracedone(const char *timestr)
 	if (*tail)
 		return -EINVAL;
 
-	xlog(D_GENERAL, "%s: grace done. gracetime=%ld", __func__, gracetime);
+	xlog(D_GENERAL, "%s: grace done. gracetime=%" PRId64, __func__, (int64_t)gracetime);
 
 	ret = sqlite_remove_unreclaimed(gracetime);
 
diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
index f79aebb3..4ac805b3 100644
--- a/utils/nfsdcltrack/sqlite.c
+++ b/utils/nfsdcltrack/sqlite.c
@@ -40,6 +40,7 @@
 
 #include <dirent.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <string.h>
@@ -544,8 +545,8 @@ sqlite_remove_unreclaimed(time_t grace_start)
 	int ret;
 	char *err = NULL;
 
-	ret = snprintf(buf, sizeof(buf), "DELETE FROM clients WHERE time < %ld",
-			grace_start);
+	ret = snprintf(buf, sizeof(buf), "DELETE FROM clients WHERE time < %" PRId64,
+			(int64_t)grace_start);
 	if (ret < 0) {
 		return ret;
 	} else if ((size_t)ret >= sizeof(buf)) {
-- 
2.30.1.629.g12f37433bd




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux