Skip to contentSkip to conversation

Fails to build on arm{el,hf} with 64bit time_t: export-cache.c:110:51: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]

PATCH Salvatore Bonaccorso 2 participants 5 messages Apr 6, 2024 – May 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Chuck, hi Steve,

In Debian, as you might have heard there is a 64bit time_t transition[1] ongoing affecting the armel and armhf architectures. While doing so, nfs-utils was found to fail to build for those architectures after the switch, reported in Debian as [2]. Vladimir Petko from Ubuntu has as well filled it in [3].

[1]: https://lists.debian.org/debian-devel-announce/2024/02/msg00005.html
[2]: https://bugs.debian.org/1067829
[3]: https://bugzilla.kernel.org/show_bug.cgi?id=218540

The report is full-quoted below.

Vladimir Petko has created a patch in the bugzilla which I'm attaching here as well. If this is not an acceptable format due to missing Signed-off's I'm attaching a variant with a Suggested-by for Vladimir to properly credit the patch origin.

Let me know if that works. I changed it slightly and only casting to long long, and made it almost checkpatch clean.

Regards,
Salvatore

----- Forwarded message from Sebastian Ramacher <[email protected]> -----

From: Sebastian Ramacher <[email protected]>
Resent-From: Sebastian Ramacher <[email protected]>
Reply-To: Sebastian Ramacher <[email protected]>, [email protected]
Date: Wed, 27 Mar 2024 11:02:25 +0100
To: Debian Bug Tracking System <[email protected]>
Subject: Bug#1067829: nfs-utils: FTBFS on arm{el,hf}: export-cache.c:110:51: error: format ‘%ld’ expects argument of
type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
Delivered-To: [email protected]
Message-ID: <[email protected]>

Source: nfs-utils
Version: 1:2.6.4-3
Severity: serious
Tags: ftbfs
Justification: fails to build from source (but built successfully in the past)
X-Debbugs-Cc: [email protected]

https://buildd.debian.org/status/fetch.php?pkg=nfs-utils&arch=armel&ver=1%3A2.6.4-3%2Bb2&stamp=1711452552&raw=0

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/usr/include/tirpc -I/usr/include/libxml2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -pipe -Wall -Wextra -Werror=strict-prototypes -Werror=missing-prototypes -Werror=missing-declarations -Werror=format=2 -Werror=undef -Werror=missing-include-dirs -Werror=strict-aliasing=2 -Werror=init-self -Werror=implicit-function-declaration -Werror=return-type -Werror=switch -Werror=overflow -Werror=parentheses -Werror=aggregate-return -Werror=unused-result -fno-strict-aliasing -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -c xml.c -fPIC -DPIC -o .libs/xml.o export-cache.c: In function ‘junction_flush_exports_cache’:
export-cache.c:110:51: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]

  110 |         snprintf(flushtime, sizeof(flushtime), "%ld\n", now);
      |                                                 ~~^     ~~~
      |                                                   |     |
      |                                                   |     time_t {aka long long int}
      |                                                   long int
      |                                                 %lld

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/usr/include/tirpc -I/usr/include/libxml2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -pipe -Wall -Wextra -Werror=strict-prototypes -Werror=missing-prototypes -Werror=missing-declarations -Werror=format=2 -Werror=undef -Werror=missing-include-dirs -Werror=strict-aliasing=2 -Werror=init-self -Werror=implicit-function-declaration -Werror=return-type -Werror=switch -Werror=overflow -Werror=parentheses -Werror=aggregate-return -Werror=unused-result -fno-strict-aliasing -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -c display.c -o display.o >/dev/null 2>&1
cc1: some warnings being treated as errors
make[3]: *** [Makefile:489: export-cache.lo] Error 1
make[3]: *** Waiting for unfinished jobs....

Cheers

Signature · 3 lines
Sebastian Ramacher

----- End forwarded message -----

Description: cast to a type with a known size to ensure sprintf works
Author: Vladimir Petko <[email protected]>

Bug-Ubuntu:  https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/2055349
Last-Update: 2024-02-29
support/junction/export-cache.c +1 -1
@@ -107,7 +107,7 @@
 		xlog(D_GENERAL, "%s: time(3) failed", __func__);
 		return FEDFS_ERR_SVRFAULT;
 	}
-	snprintf(flushtime, sizeof(flushtime), "%ld\n", now);
+	snprintf(flushtime, sizeof(flushtime), "%lld\n", (long long int)now);
 
 	for (i = 0; junction_proc_files[i] != NULL; i++) {
 		retval = junction_write_time(junction_proc_files[i], flushtime);

From 774394df352c249775d51d5d6e3effa775096b4f Mon Sep 17 00:00:00 2001
From: Salvatore Bonaccorso <[email protected]>
Date: Sat, 6 Apr 2024 20:48:43 +0200
Subject: [PATCH] junction: export-cache: cast to a type with a known size to
ensure sprintf works
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As reported in Debian, with the 64bit time_t transition for the armel and armhf architecture, it was found that nfs-utils fails to compile with:

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/usr/include/tirpc -I/usr/include/libxml2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -pipe -Wall -Wextra -Werror=strict-prototypes -Werror=missing-prototypes -Werror=missing-declarations -Werror=format=2 -Werror=undef -Werror=missing-include-dirs -Werror=strict-aliasing=2 -Werror=init-self -Werror=implicit-function-declaration -Werror=return-type -Werror=switch -Werror=overflow -Werror=parentheses -Werror=aggregate-return -Werror=unused-result -fno-strict-aliasing -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -c xml.c -fPIC -DPIC -o .libs/xml.o export-cache.c: In function ‘junction_flush_exports_cache’:
export-cache.c:110:51: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
110 | snprintf(flushtime, sizeof(flushtime), "%ld\n", now);
| ~~^ ~~~
| | |
| | time_t {aka long long int}
| long int
| %lld

time_t is not guaranteed to be 64-bit, so it must be coerced into the expected type for printf. Cast it to long long.

---
 support/junction/export-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
support/junction/export-cache.c +1 -1
index 4e578c9b37b1..00187c019d60 100644
@@ -107,7 +107,7 @@ junction_flush_exports_cache(void)
 		xlog(D_GENERAL, "%s: time(3) failed", __func__);
 		return FEDFS_ERR_SVRFAULT;
 	}
-	snprintf(flushtime, sizeof(flushtime), "%ld\n", now);
+	snprintf(flushtime, sizeof(flushtime), "%lld\n", (long long)now);
 
 	for (i = 0; junction_proc_files[i] != NULL; i++) {
 		retval = junction_write_time(junction_proc_files[i], flushtime);
Signature · 1 line
2.43.0
Reviewed-by Chuck Lever
#1 lore raw
Quoted 18 lines · Salvatore Bonaccorso

Hi Chuck, hi Steve,

In Debian, as you might have heard there is a 64bit time_t transition[1] ongoing affecting the armel and armhf architectures. While doing so, nfs-utils was found to fail to build for those architectures after the switch, reported in Debian as [2]. Vladimir Petko from Ubuntu has as well filled it in [3].

[1]: https://lists.debian.org/debian-devel-announce/2024/02/msg00005.html
[2]: https://bugs.debian.org/1067829
[3]: https://bugzilla.kernel.org/show_bug.cgi?id=218540

The report is full-quoted below.

Quoted 7 lines

Vladimir Petko has created a patch in the bugzilla which I'm attaching here as well. If this is not an acceptable format due to missing Signed-off's I'm attaching a variant with a Suggested-by for Vladimir to properly credit the patch origin.

Let me know if that works. I changed it slightly and only casting to long long, and made it almost checkpatch clean.

I suppose strftime(3) might be nicer, but this works.

Reviewed-by Chuck Lever <[email protected] <mailto:[email protected]>>
Quoted 33 lines

Regards,
Salvatore

----- Forwarded message from Sebastian Ramacher <[email protected]> -----

From: Sebastian Ramacher <[email protected]>
Resent-From: Sebastian Ramacher <[email protected]>
Reply-To: Sebastian Ramacher <[email protected]>, [email protected]
Date: Wed, 27 Mar 2024 11:02:25 +0100
To: Debian Bug Tracking System <[email protected]>
Subject: Bug#1067829: nfs-utils: FTBFS on arm{el,hf}: export-cache.c:110:51: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]
Delivered-To: [email protected]
Message-ID: <[email protected]>

Source: nfs-utils
Version: 1:2.6.4-3
Severity: serious
Tags: ftbfs
Justification: fails to build from source (but built successfully in the past)
X-Debbugs-Cc: [email protected]

https://buildd.debian.org/status/fetch.php?pkg=nfs-utils&arch=armel&ver=1%3A2.6.4-3%2Bb2&stamp=1711452552&raw=0

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/usr/include/tirpc -I/usr/include/libxml2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -pipe -Wall -Wextra -Werror=strict-prototypes -Werror=missing-prototypes -Werror=missing-declarations -Werror=format=2 -Werror=undef -Werror=missing-include-dirs -Werror=strict-aliasing=2 -Werror=init-self -Werror=implicit-function-declaration -Werror=return-type -Werror=switch -Werror=overflow -Werror=parentheses -Werror=aggregate-return -Werror=unused-result -fno-strict-aliasing -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -c xml.c -fPIC -DPIC -o .libs/xml.o export-cache.c: In function ‘junction_flush_exports_cache’:
export-cache.c:110:51: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘time_t’ {aka ‘long long int’} [-Werror=format=]

 110 |         snprintf(flushtime, sizeof(flushtime), "%ld\n", now);
     |                                                 ~~^     ~~~
     |                                                   |     |
     |                                                   |     time_t {aka long long int}
     |                                                   long int
     |                                                 %lld
Quoted 11 lines

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/usr/include/tirpc -I/usr/include/libxml2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -pipe -Wall -Wextra -Werror=strict-prototypes -Werror=missing-prototypes -Werror=missing-declarations -Werror=format=2 -Werror=undef -Werror=missing-include-dirs -Werror=strict-aliasing=2 -Werror=init-self -Werror=implicit-function-declaration -Werror=return-type -Werror=switch -Werror=overflow -Werror=parentheses -Werror=aggregate-return -Werror=unused-result -fno-strict-aliasing -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -c display.c -o display.o >/dev/null 2>&1
cc1: some warnings being treated as errors
make[3]: *** [Makefile:489: export-cache.lo] Error 1
make[3]: *** Waiting for unfinished jobs....

Cheers

Signature · 4 lines
Sebastian Ramacher

----- End forwarded message -----
<armhf-time-t-format-error.patch><0001-junction-export-cache-cast-to-a-type-with-a-known-si.patch>

--
Chuck Lever

#2 lore raw

Hi all,

Quoted 23 lines · Chuck Lever III
Quoted 23 lines · Salvatore Bonaccorso

Hi Chuck, hi Steve,

In Debian, as you might have heard there is a 64bit time_t transition[1] ongoing affecting the armel and armhf architectures. While doing so, nfs-utils was found to fail to build for those architectures after the switch, reported in Debian as [2]. Vladimir Petko from Ubuntu has as well filled it in [3].

[1]: https://lists.debian.org/debian-devel-announce/2024/02/msg00005.html
[2]: https://bugs.debian.org/1067829
[3]: https://bugzilla.kernel.org/show_bug.cgi?id=218540

The report is full-quoted below.

Vladimir Petko has created a patch in the bugzilla which I'm attaching here as well. If this is not an acceptable format due to missing Signed-off's I'm attaching a variant with a Suggested-by for Vladimir to properly credit the patch origin.

Quoted 6 lines
Quoted 2 lines

Let me know if that works. I changed it slightly and only casting to long long, and made it almost checkpatch clean.

I suppose strftime(3) might be nicer, but this works.

Reviewed-by Chuck Lever <[email protected] <mailto:[email protected]>>

I noticed this is not yet applied to the repository, do you need anything else from me or did it just felt trouch the cracks or actually queued?

Asking since if you want to have it done differently I will then follow suit downstream as well in Debian, where we have for now applied the submitted patch.

Regards,
Salvatore

#3 lore raw
Quoted 33 lines · Salvatore Bonaccorso

Hi all,

Quoted 23 lines · Chuck Lever III
Quoted 23 lines · Salvatore Bonaccorso

Hi Chuck, hi Steve,

In Debian, as you might have heard there is a 64bit time_t transition[1] ongoing affecting the armel and armhf architectures. While doing so, nfs-utils was found to fail to build for those architectures after the switch, reported in Debian as [2]. Vladimir Petko from Ubuntu has as well filled it in [3].

[1]: https://lists.debian.org/debian-devel-announce/2024/02/msg00005.html
[2]: https://bugs.debian.org/1067829
[3]: https://bugzilla.kernel.org/show_bug.cgi?id=218540

The report is full-quoted below.

Vladimir Petko has created a patch in the bugzilla which I'm attaching here as well. If this is not an acceptable format due to missing Signed-off's I'm attaching a variant with a Suggested-by for Vladimir to properly credit the patch origin.

Quoted 6 lines
Quoted 2 lines

Let me know if that works. I changed it slightly and only casting to long long, and made it almost checkpatch clean.

I suppose strftime(3) might be nicer, but this works.

Quoted 7 lines

I noticed this is not yet applied to the repository, do you need anything else from me or did it just felt trouch the cracks or actually queued?

Asking since if you want to have it done differently I will then follow suit downstream as well in Debian, where we have for now applied the submitted patch.

Salvatore, can you resend the patch inline (not as an attachment)
To: Steve, Cc: linux-nfs@ ?

Steve, see above for my Reviewed-by.

Signature · 1 line
Chuck Lever
#4 lore raw

Hi,

Quoted 38 lines · Chuck Lever
Quoted 37 lines · Salvatore Bonaccorso

Hi all,

Quoted 23 lines · Chuck Lever III
Quoted 23 lines · Salvatore Bonaccorso

Hi Chuck, hi Steve,

In Debian, as you might have heard there is a 64bit time_t transition[1] ongoing affecting the armel and armhf architectures. While doing so, nfs-utils was found to fail to build for those architectures after the switch, reported in Debian as [2]. Vladimir Petko from Ubuntu has as well filled it in [3].

[1]: https://lists.debian.org/debian-devel-announce/2024/02/msg00005.html
[2]: https://bugs.debian.org/1067829
[3]: https://bugzilla.kernel.org/show_bug.cgi?id=218540

The report is full-quoted below.

Vladimir Petko has created a patch in the bugzilla which I'm attaching here as well. If this is not an acceptable format due to missing Signed-off's I'm attaching a variant with a Suggested-by for Vladimir to properly credit the patch origin.

Quoted 6 lines
Quoted 2 lines

Let me know if that works. I changed it slightly and only casting to long long, and made it almost checkpatch clean.

I suppose strftime(3) might be nicer, but this works.

I noticed this is not yet applied to the repository, do you need anything else from me or did it just felt trouch the cracks or actually queued?

Quoted 6 lines
Quoted 3 lines

Asking since if you want to have it done differently I will then follow suit downstream as well in Debian, where we have for now applied the submitted patch.

Salvatore, can you resend the patch inline (not as an attachment)
To: Steve, Cc: linux-nfs@ ?

Yes sure, sorry about it. Here it is submitted:

https://lore.kernel.org/linux-nfs/[email protected]/T/#u

Regards,
Salvatore