linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* tools/locktest/testlk.c:84: argument 4 has type ‘__off64_t {aka long long int}’
@ 2018-06-03 16:30 Philipp Psurek
  2018-06-03 16:34 ` Philipp Psurek
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Psurek @ 2018-06-03 16:30 UTC (permalink / raw)
  To: linux-nfs

Hi,

I got this error on 32 bit ARM:

make[2]: Entering directory
'/home/portage/portage/net-fs/nfs-utils-2.3.2/work/nfs-utils-
2.3.2/tools/locktest'
armv7a-hardfloat-linux-gnueabi-gcc -DHAVE_CONFIG_H -I.
-I../../support/include 
-I/usr/include/tirpc -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 -O3 -pipe -fomit-frame-pointer
-mcpu=cortex-a7
-mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -ffast-math -c -o
testlk.o
testlk.c
testlk.c: In function ‘main’:
testlk.c:84:45: error: format ‘%ld’ expects argument of type ‘long
int’, but
argument 4 has type ‘__off64_t {aka long long int}’ [-Werror=format=]
    printf("%s: conflicting lock by %d on (%ld;%ld)\n",
                                           ~~^
                                           %lld
     fname, fl.l_pid, fl.l_start, fl.l_len);
                      ~~~~~~~~~~              
testlk.c:84:49: error: format ‘%ld’ expects argument of type ‘long
int’, but
argument 5 has type ‘__off64_t {aka long long int}’ [-Werror=format=]
    printf("%s: conflicting lock by %d on (%ld;%ld)\n",
                                               ~~^
                                               %lld
     fname, fl.l_pid, fl.l_start, fl.l_len);

You can not assume long is 64 bit wide on 32 bit architectures. You
have to use
long long. Please apply the patch below

* 2nd change removes whitespace
* 3rd change is this bug
* 1st change suppress this warning from gcc-7 and higher:

testlk.c: In function 'main':
testlk.c:30:4: warning: this statement may fall through
[-Wimplicit-fallthrough=]
    usage(0);
    ^~~~~~~~
testlk.c:31:3: note: here
   case 'r':
   ^~~~

see
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Warning-Options.html#index
-Wimplicit-fallthrough_003d

I provide you this bug via email, because I can not upload files into
Bugzilla
https://bugzilla.linux-nfs.org/show_bug.cgi?id=325

Your Bugzilla has also an invalid security certificate
https://bugzilla.linux-nfs.org/show_bug.cgi?id=323

The Bug described in this email is
https://bugzilla.linux-nfs.org/show_bug.cgi?id=324

------------------------------------------------------
fl.l_start and fl.l_len are 64 bit wide. It has been assumed that long
is 64 bit in a printf(), which is incorrect on a 32 bit archtecture

* 1st change suppress fall through warning from gcc-7 and higher
* 2nd change removes whitespace
* 3rd change is this bug and changes this into a long long

Signed-off-by: Philipp Psurek <philipp.psurek@gmail.com>
---

--- a/tools/locktest/testlk.c    2018-05-22 20:33:01.000000000 +0200
+++ b/tools/locktest/testlk.c    2018-06-03 17:26:36.800202901 +0200
@@ -28,6 +28,7 @@
 		switch (c) {
 		case 'h':
 			usage(0);
+			/* fall through */
 		case 'r':
 			cmd = F_SETLK;
 			typ = F_RDLCK;
@@ -75,13 +76,13 @@
 	if (fcntl(fd, cmd, &fl) < 0)
 		fatal("fcntl");
 	printf("fcntl: ok\n");
-	
+
 	/* printf("TP2\n"); */
 	if (cmd == F_GETLK) {
 		if (fl.l_type == F_UNLCK) {
 			printf("%s: no conflicting lock\n", fname);
 		} else {
-			printf("%s: conflicting lock by %d on
(%ld;%ld)\n",
+			printf("%s: conflicting lock by %d on
(%lld;%lld)\n",
 				fname, fl.l_pid, fl.l_start,
fl.l_len);
 		}
 		return 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tools/locktest/testlk.c:84: argument 4 has type ‘__off64_t {aka long long int}’
  2018-06-03 16:30 tools/locktest/testlk.c:84: argument 4 has type ‘__off64_t {aka long long int}’ Philipp Psurek
@ 2018-06-03 16:34 ` Philipp Psurek
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Psurek @ 2018-06-03 16:34 UTC (permalink / raw)
  To: linux-nfs

[-- Attachment #1: Type: text/plain, Size: 88 bytes --]

Hi again,

i see, email likes also no tabs. Patch as attachment.

best regards
  Philipp

[-- Attachment #2: testlk.c.patch --]
[-- Type: text/x-patch, Size: 1050 bytes --]

fl.l_start and fl.l_len are 64 bit wide. It has been assumed that long
is 64 bit in a printf(), which is incorrect on a 32 bit archtecture

* 1st change suppress fall through warning from gcc-7 and higher
* 2nd change removes whitespace
* 3rd change is this bug and changes this into a long long

Signed-off-by: Philipp Psurek <philipp.psurek@gmail.com>
---

--- a/tools/locktest/testlk.c    2018-05-22 20:33:01.000000000 +0200
+++ b/tools/locktest/testlk.c    2018-06-03 17:26:36.800202901 +0200
@@ -28,6 +28,7 @@
 		switch (c) {
 		case 'h':
 			usage(0);
+			/* fall through */
 		case 'r':
 			cmd = F_SETLK;
 			typ = F_RDLCK;
@@ -75,13 +76,13 @@
 	if (fcntl(fd, cmd, &fl) < 0)
 		fatal("fcntl");
 	printf("fcntl: ok\n");
-	
+
 	/* printf("TP2\n"); */
 	if (cmd == F_GETLK) {
 		if (fl.l_type == F_UNLCK) {
 			printf("%s: no conflicting lock\n", fname);
 		} else {
-			printf("%s: conflicting lock by %d on (%ld;%ld)\n",
+			printf("%s: conflicting lock by %d on (%lld;%lld)\n",
 				fname, fl.l_pid, fl.l_start, fl.l_len);
 		}
 		return 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-03 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03 16:30 tools/locktest/testlk.c:84: argument 4 has type ‘__off64_t {aka long long int}’ Philipp Psurek
2018-06-03 16:34 ` Philipp Psurek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).