All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Subject: [PATCH] nfsdcltrack: don't assume time_t is long int
Date: Mon, 22 Feb 2021 08:11:28 +0700	[thread overview]
Message-ID: <20210222011128.30378-1-congdanhqx@gmail.com> (raw)

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(-)

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


                 reply	other threads:[~2021-02-22  1:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222011128.30378-1-congdanhqx@gmail.com \
    --to=congdanhqx@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.