Skip to contentSkip to conversation

package/nfs-utils: fix time_t on 64-bits platforms build

PATCH In review Giulio Benetti 2 participants 6 messages Jul 22, 2021 – Jul 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/nfs-utils: fix time_t on 64-bits platforms build

Add patch to fix time_t build failure on 64-bits platforms.

Fixes:
http://autobuild.buildroot.net/results/9bc1d43a588338b7395af7bc97535ee16a6ea2d9/

---
 ...me_t-build-error-on-64-bits-platform.patch | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch
package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch new file +52 -0
new file mode 100644
index 0000000000..1dec494f26
@@ -0,0 +1,52 @@
+From 9d25faae1216258b617dd2db134bc1d9fa0fd73d Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 22 Jul 2021 16:13:14 +0200
+Subject: [PATCH] nfs-utils: fix time_t build error on 64-bits platforms
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When passing time_t type to "%ld" on 64-bits platforms where time_t is a
+'long long' we encouter this build failure:
+error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
+
+So let's change "%ld" markers to "%lld" assuming it to be a 64-bits and
+cast variables to '(long long)' if the type is a time_t.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ utils/nfsdcltrack/nfsdcltrack.c | 2 +-
+ utils/nfsdcltrack/sqlite.c      | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
+index e926f1c0..437477bb 100644
+--- a/utils/nfsdcltrack/nfsdcltrack.c
++++ b/utils/nfsdcltrack/nfsdcltrack.c
+@@ -525,7 +525,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=%lld", __func__, (long long)gracetime);
+ 
+ 	ret = sqlite_remove_unreclaimed(gracetime);
+ 
+diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
+index f79aebb3..6e603087 100644
+--- a/utils/nfsdcltrack/sqlite.c
++++ b/utils/nfsdcltrack/sqlite.c
+@@ -544,8 +544,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 < %lld",
++			(long long)grace_start);
+ 	if (ret < 0) {
+ 		return ret;
+ 	} else if ((size_t)ret >= sizeof(buf)) {
+-- 
+2.25.1
+
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw
Quoted 1 line · Giulio Benetti

Add patch to fix time_t build failure on 64-bits platforms.

Forgot to add:

```
Patch is pending upstream:
https://patchwork.kernel.org/project/linux-nfs/patch/[email protected]/
```
Quoted 68 lines

Fixes:
http://autobuild.buildroot.net/results/9bc1d43a588338b7395af7bc97535ee16a6ea2d9/

---
  ...me_t-build-error-on-64-bits-platform.patch | 52 +++++++++++++++++++
  1 file changed, 52 insertions(+)

create mode 100644 package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch

package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch new file +52 -0
new file mode 100644
index 0000000000..1dec494f26
@@ -0,0 +1,52 @@
+From 9d25faae1216258b617dd2db134bc1d9fa0fd73d Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 22 Jul 2021 16:13:14 +0200
+Subject: [PATCH] nfs-utils: fix time_t build error on 64-bits platforms
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When passing time_t type to "%ld" on 64-bits platforms where time_t is a
+'long long' we encouter this build failure:
+error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
+
+So let's change "%ld" markers to "%lld" assuming it to be a 64-bits and
+cast variables to '(long long)' if the type is a time_t.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ utils/nfsdcltrack/nfsdcltrack.c | 2 +-
+ utils/nfsdcltrack/sqlite.c      | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
+index e926f1c0..437477bb 100644
+--- a/utils/nfsdcltrack/nfsdcltrack.c
++++ b/utils/nfsdcltrack/nfsdcltrack.c
+@@ -525,7 +525,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=%lld", __func__, (long long)gracetime);
+
+ 	ret = sqlite_remove_unreclaimed(gracetime);
+
+diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
+index f79aebb3..6e603087 100644
+--- a/utils/nfsdcltrack/sqlite.c
++++ b/utils/nfsdcltrack/sqlite.c
+@@ -544,8 +544,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 < %lld",
++			(long long)grace_start);
+ 	if (ret < 0) {
+ 		return ret;
+ 	} else if ((size_t)ret >= sizeof(buf)) {
+--
+2.25.1
+
Signature · 6 lines
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw

Please drop this patch since I’m going another upstream patch.

Thank you
Giulio Benetti

Quoted 67 lines

Il giorno 22 lug 2021, alle ore 17:41, Giulio Benetti <[email protected]> ha scritto:

Quoted 1 line · Giulio Benetti

Add patch to fix time_t build failure on 64-bits platforms.

Forgot to add:

```
Patch is pending upstream:
https://patchwork.kernel.org/project/linux-nfs/patch/[email protected]/
```
Quoted 57 lines

Fixes:
http://autobuild.buildroot.net/results/9bc1d43a588338b7395af7bc97535ee16a6ea2d9/

---
 ...me_t-build-error-on-64-bits-platform.patch | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch
package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch new file +44 -0
new file mode 100644
index 0000000000..1dec494f26
@@ -0,0 +1,52 @@
+From 9d25faae1216258b617dd2db134bc1d9fa0fd73d Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Thu, 22 Jul 2021 16:13:14 +0200
+Subject: [PATCH] nfs-utils: fix time_t build error on 64-bits platforms
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When passing time_t type to "%ld" on 64-bits platforms where time_t is a
+'long long' we encouter this build failure:
+error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
+
+So let's change "%ld" markers to "%lld" assuming it to be a 64-bits and
+cast variables to '(long long)' if the type is a time_t.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+---
+ utils/nfsdcltrack/nfsdcltrack.c | 2 +-
+ utils/nfsdcltrack/sqlite.c      | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
+index e926f1c0..437477bb 100644
+--- a/utils/nfsdcltrack/nfsdcltrack.c
++++ b/utils/nfsdcltrack/nfsdcltrack.c
+@@ -525,7 +525,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=%lld", __func__, (long long)gracetime);
+
+    ret = sqlite_remove_unreclaimed(gracetime);
+
+diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
+index f79aebb3..6e603087 100644
+--- a/utils/nfsdcltrack/sqlite.c
++++ b/utils/nfsdcltrack/sqlite.c
+@@ -544,8 +544,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);
Quoted 12 lines
Quoted 8 lines
package/nfs-utils/0001-nfs-utils-fix-time_t-build-error-on-64-bits-platform.patch new file +8 -0
++    ret = snprintf(buf, sizeof(buf), "DELETE FROM clients WHERE time < %lld",
++            (long long)grace_start);
+    if (ret < 0) {
+        return ret;
+    } else if ((size_t)ret >= sizeof(buf)) {
+--
+2.25.1
+
Signature · 2 lines
Giulio Benetti
Benetti Engineering sas

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#3 lore raw

Hi Giulio,

Quoted 1 line

Please drop this patch since I’m going another upstream patch.

Yep, I first sent my patches upstream. I should have Cc you, I'll try to remember for next time.

Also feel free to backport them to Buildroot and please Cc me (so we don't sent the same patch both).

Kind regards,
Petr
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

Hi Petr,

Quoted 7 lines

Il giorno 25 lug 2021, alle ore 21:38, Petr Vorel <[email protected]> ha scritto:

Hi Giulio,

Quoted 1 line

Please drop this patch since I’m going another upstream patch.

Yep, I first sent my patches upstream. I should have Cc you, I'll try to remember for next time.

Ah they’re yours, I didn’t have to time to check.

Quoted 3 lines

Also feel free to backport them to Buildroot and please Cc me (so we don't sent the same patch both).

Sure, good idea, thank you.

I’m going to backport them to buildroot then.

Best regards
Giulio Benetti

Quoted 7 lines

Kind regards,
Petr
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#5 lore raw

Hi Giulio,

Quoted 13 lines

Hi Petr,

Quoted 7 lines

Il giorno 25 lug 2021, alle ore 21:38, Petr Vorel <[email protected]> ha scritto:

Hi Giulio,

Quoted 1 line

Please drop this patch since I’m going another upstream patch.

Yep, I first sent my patches upstream. I should have Cc you, I'll try to remember for next time.

Ah they’re yours, I didn’t have to time to check.

Quoted 6 lines
Quoted 2 lines

Also feel free to backport them to Buildroot and please Cc me (so we don't sent the same patch both).

Sure, good idea, thank you.

I’m going to backport them to buildroot then.

+1. Thanks!

Kind regards,
Petr

Quoted 10 lines

Best regards
Giulio Benetti

Quoted 6 lines

Kind regards,
Petr
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot