From: David Laight <David.Laight@ACULAB.COM>
To: "'maninder1.s@samsung.com'" <maninder1.s@samsung.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"shuahkh@osg.samsung.com" <shuahkh@osg.samsung.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
PANKAJ MISHRA <pankaj.m@samsung.com>,
AMIT SAHRAWAT <a.sahrawat@samsung.com>,
Vaneet Narang <v.narang@samsung.com>
Subject: RE: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
Date: Fri, 3 Aug 2018 11:12:06 +0000 [thread overview]
Message-ID: <4f2c8d694dce4125a609e8d5383ebe36@AcuMS.aculab.com> (raw)
In-Reply-To: <20180803033159epcms5p1dd2f5a6834268e9a22efa15421795fa0@epcms5p1>
From: Maninder Singh
> Sent: 03 August 2018 04:32
> >On 08/02/2018 03:31 AM, Maninder Singh wrote:
> >> FILE_SZ is defined as (1UL << 35), it will overflow
> >> for 32 bit system and logic will break.
> >>
> >> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> >> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
> >> ---
> >> 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)
>
> ...
> ...
> >> @@ -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)
next prev parent reply other threads:[~2018-08-03 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcas5p4.samsung.com>
2018-08-02 10:31 ` [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture Maninder Singh
2018-08-02 13:08 ` Eric Dumazet
2018-08-03 3:31 ` Maninder Singh
2018-08-03 11:12 ` David Laight [this message]
2018-08-10 6:03 ` Maninder Singh
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=4f2c8d694dce4125a609e8d5383ebe36@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=a.sahrawat@samsung.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maninder1.s@samsung.com \
--cc=netdev@vger.kernel.org \
--cc=pankaj.m@samsung.com \
--cc=shuahkh@osg.samsung.com \
--cc=v.narang@samsung.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox