Thread (5 messages) flat view 5 messages, 3 authors, 2018-08-10

RE: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.

From: David Laight <hidden>
Date: 2018-08-03 11:10:36
Also in: linux-api, lkml

From: Maninder Singh
Sent: 03 August 2018 04:32
quoted
On 08/02/2018 03:31 AM, Maninder Singh wrote:
quoted
FILE_SZ is defined as (1UL << 35), it will overflow
for 32 bit system and logic will break.

Signed-off-by: Maninder Singh <redacted>
Signed-off-by: Vaneet Narang <redacted>
---
 tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index e8c5dff..1d6ca12 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -85,7 +85,7 @@
 #define MSG_ZEROCOPY    0x4000000
 #endif

-#define FILE_SZ (1UL << 35)
+#define FILE_SZ (1ULL << 35)
...
...
quoted
quoted
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
                 zflg = 0;
         }
         while (total < FILE_SZ) {
-                long wr = FILE_SZ - total;
+                unsigned long long wr = FILE_SZ - total;

                 if (wr > chunk_size)
                         wr = chunk_size;
What about using more conventional size_t instead of "unsigned long long" ?
size_t is also equivalent to unsigned long and it will not hold value of (1 << 35) for 32 bit system.
So we can do two things.
Wouldn't the 'correct' type be off_t ?
In any case, IIRC, you have to do really horrid things in Linux to
access files larger than 2G on 32bit systems.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help