aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/vm/thuge-gen.c
diff options
context:
space:
mode:
authorSeongJae Park <sj38.park@gmail.com>2017-03-15 22:19:26 +0900
committerShuah Khan <shuahkh@osg.samsung.com>2017-04-11 09:41:38 -0600
commit70d1a4e66854ae8aa26d9474ae282b46d7087770 (patch)
treec031e7f5c59344de3879a1590f367467db6c867c /tools/testing/selftests/vm/thuge-gen.c
parentselftests/futex: Fix build error with OUTPUT variable (diff)
downloadwireguard-linux-70d1a4e66854ae8aa26d9474ae282b46d7087770.tar.xz
wireguard-linux-70d1a4e66854ae8aa26d9474ae282b46d7087770.zip
selftests/vm: Set mmap()'s fd as -1 for MAP_ANONYMOUS flag
Man page of mmap() says that portable applications should ensure fd argument to be -1 if MAP_ANONYMOUS flag is set as below: ``` The mapping is not backed by any file; its contents are initialized to zero. The fd and offset arguments are ignored; however, some implementations require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable applications should ensure this. ``` However, few mmap() calls under selftests/vm/ uses 0 as fd though they use MAP_ANONYMOUS flag. This commit changes the argument to be -1 as recommended. Signed-off-by: SeongJae Park <sj38.park@gmail.com> Acked-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--tools/testing/selftests/vm/thuge-gen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/vm/thuge-gen.c b/tools/testing/selftests/vm/thuge-gen.c
index 0bc737a75150..88a2ab535e01 100644
--- a/tools/testing/selftests/vm/thuge-gen.c
+++ b/tools/testing/selftests/vm/thuge-gen.c
@@ -146,7 +146,7 @@ void test_mmap(unsigned long size, unsigned flags)
before = read_free(size);
map = mmap(NULL, size*NUM_PAGES, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB|flags, 0, 0);
+ MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB|flags, -1, 0);
if (map == (char *)-1) err("mmap");
memset(map, 0xff, size*NUM_PAGES);