selftests/vm: Set mmap()'s fd as -1 for MAP_ANONYMOUS flag
authorSeongJae Park <sj38.park@gmail.com>
Wed, 15 Mar 2017 13:19:26 +0000 (22:19 +0900)
committerShuah Khan <shuahkh@osg.samsung.com>
Tue, 11 Apr 2017 15:41:38 +0000 (09:41 -0600)
commit70d1a4e66854ae8aa26d9474ae282b46d7087770
treec031e7f5c59344de3879a1590f367467db6c867c
parentbfedc31c4f2c1af3b509bbdc0aae051e8ad7d3ae
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>
tools/testing/selftests/vm/map_hugetlb.c
tools/testing/selftests/vm/mlock2-tests.c
tools/testing/selftests/vm/on-fault-limit.c
tools/testing/selftests/vm/thuge-gen.c