Skip to content

Commit e698a23

Browse files
mhiramatshuahkh
authored andcommitted
selftests: net: Use size_t and ssize_t for counting file size
Use size_t and ssize_t correctly for counting send file size instead of unsigned long and long, because long is 32bit on 32bit arch, which is not enough for counting long file size (>4GB). Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: David S. Miller <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 7549b33 commit e698a23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/testing/selftests/net/tcp_mmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
#define MSG_ZEROCOPY 0x4000000
7272
#endif
7373

74-
#define FILE_SZ (1UL << 35)
74+
#define FILE_SZ (1ULL << 35)
7575
static int cfg_family = AF_INET6;
7676
static socklen_t cfg_alen = sizeof(struct sockaddr_in6);
7777
static int cfg_port = 8787;
@@ -155,7 +155,7 @@ void *child_thread(void *arg)
155155
socklen_t zc_len = sizeof(zc);
156156
int res;
157157

158-
zc.address = (__u64)addr;
158+
zc.address = (__u64)((unsigned long)addr);
159159
zc.length = chunk_size;
160160
zc.recv_skip_hint = 0;
161161
res = getsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE,
@@ -302,7 +302,7 @@ int main(int argc, char *argv[])
302302
{
303303
struct sockaddr_storage listenaddr, addr;
304304
unsigned int max_pacing_rate = 0;
305-
unsigned long total = 0;
305+
size_t total = 0;
306306
char *host = NULL;
307307
int fd, c, on = 1;
308308
char *buffer;
@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
417417
zflg = 0;
418418
}
419419
while (total < FILE_SZ) {
420-
long wr = FILE_SZ - total;
420+
ssize_t wr = FILE_SZ - total;
421421

422422
if (wr > chunk_size)
423423
wr = chunk_size;

0 commit comments

Comments
 (0)