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>
This commit is contained in:

committed by
Shuah Khan

parent
bfedc31c4f
commit
70d1a4e668
@@ -62,7 +62,7 @@ int main(void)
|
||||
void *addr;
|
||||
int ret;
|
||||
|
||||
addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0);
|
||||
addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, -1, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
exit(1);
|
||||
|
Reference in New Issue
Block a user