@@ -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);
@@ -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)) {
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@gmail.com> --- 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(-)