diff mbox series

[1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c

Message ID 20191015031350.4345-2-richardw.yang@linux.intel.com
State New
Headers show
Series replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size | expand

Commit Message

Wei Yang Oct. 15, 2019, 3:13 a.m. UTC
This file uses quite a different code style and changing just one line
would leads to some awkward appearance.

This is a preparation for the following replacement of
sysconf(_SC_PAGESIZE).

BTW, to depress ERROR message from checkpatch.pl, this patch replaces
strtoul with qemu_strtoul.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 31 deletions(-)

Comments

Stefano Garzarella Nov. 11, 2019, 9:57 a.m. UTC | #1
On Tue, Oct 15, 2019 at 11:13:49AM +0800, Wei Yang wrote:
> This file uses quite a different code style and changing just one line
> would leads to some awkward appearance.
> 
> This is a preparation for the following replacement of
> sysconf(_SC_PAGESIZE).
> 
> BTW, to depress ERROR message from checkpatch.pl, this patch replaces
> strtoul with qemu_strtoul.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++---------------
>  1 file changed, 36 insertions(+), 31 deletions(-)
> 
> diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
> index 11d0e777b1..9ea49e2307 100644
> --- a/tests/tcg/multiarch/test-mmap.c
> +++ b/tests/tcg/multiarch/test-mmap.c
> @@ -456,49 +456,54 @@ void check_invalid_mmaps(void)
>  
>  int main(int argc, char **argv)
>  {
> -	char tempname[] = "/tmp/.cmmapXXXXXX";
> -	unsigned int i;
> -
> -	/* Trust the first argument, otherwise probe the system for our
> -	   pagesize.  */
> -	if (argc > 1)
> -		pagesize = strtoul(argv[1], NULL, 0);
> -	else
> -		pagesize = sysconf(_SC_PAGESIZE);
> +    char tempname[] = "/tmp/.cmmapXXXXXX";
> +    unsigned int i;
> +
> +    /*
> +     * Trust the first argument, otherwise probe the system for our
> +     * pagesize.
> +     */
> +    if (argc > 1) {
> +        qemu_strtoul(argv[1], NULL, 0, &pagesize);

What do you think about doing this change in a separate patch?

> +    } else {
> +        pagesize = sysconf(_SC_PAGESIZE);
> +    }
>  
> -	/* Assume pagesize is a power of two.  */
> -	pagemask = pagesize - 1;
> -	dummybuf = malloc (pagesize);
> -	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
> +    /* Assume pagesize is a power of two.  */
> +    pagemask = pagesize - 1;
> +    dummybuf = malloc(pagesize);
> +    printf("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>  
> -	test_fd = mkstemp(tempname);
> -	unlink(tempname);
> +    test_fd = mkstemp(tempname);
> +    unlink(tempname);
>  
> -	/* Fill the file with int's counting from zero and up.  */
> +    /* Fill the file with int's counting from zero and up.  */
>      for (i = 0; i < (pagesize * 4) / sizeof i; i++) {
>          checked_write(test_fd, &i, sizeof i);
>      }
>  
> -	/* Append a few extra writes to make the file end at non 
> -	   page boundary.  */
> +    /*
> +     * Append a few extra writes to make the file end at non
> +     * page boundary.
> +     */
>      checked_write(test_fd, &i, sizeof i); i++;
>      checked_write(test_fd, &i, sizeof i); i++;
>      checked_write(test_fd, &i, sizeof i); i++;
>  
> -	test_fsize = lseek(test_fd, 0, SEEK_CUR);
> +    test_fsize = lseek(test_fd, 0, SEEK_CUR);
>  
> -	/* Run the tests.  */
> -	check_aligned_anonymous_unfixed_mmaps();
> -	check_aligned_anonymous_unfixed_colliding_mmaps();
> -	check_aligned_anonymous_fixed_mmaps();
> -	check_file_unfixed_mmaps();
> -	check_file_fixed_mmaps();
> -	check_file_fixed_eof_mmaps();
> -	check_file_unfixed_eof_mmaps();
> -	check_invalid_mmaps();
> +    /* Run the tests.  */
> +    check_aligned_anonymous_unfixed_mmaps();
> +    check_aligned_anonymous_unfixed_colliding_mmaps();
> +    check_aligned_anonymous_fixed_mmaps();
> +    check_file_unfixed_mmaps();
> +    check_file_fixed_mmaps();
> +    check_file_fixed_eof_mmaps();
> +    check_file_unfixed_eof_mmaps();
> +    check_invalid_mmaps();
>  
> -	/* Fails at the moment.  */
> -	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
> +    /* Fails at the moment.  */
> +    /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>  
> -	return EXIT_SUCCESS;
> +    return EXIT_SUCCESS;
>  }

The rest looks good to me.

Thanks,
Stefano
Alex Bennée Nov. 11, 2019, 10:25 a.m. UTC | #2
Wei Yang <richardw.yang@linux.intel.com> writes:

> This file uses quite a different code style and changing just one line
> would leads to some awkward appearance.
>
> This is a preparation for the following replacement of
> sysconf(_SC_PAGESIZE).
>
> BTW, to depress ERROR message from checkpatch.pl, this patch replaces
> strtoul with qemu_strtoul.


NACK I'm afraid.

The tests/tcg directory all build against glibc only to make them easier
to cross-compile for the various targets. If you run check-tcg and have
a non-native cross compiler setup you'll notice this fails to build:

    BUILD   aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ‘main’:
  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ‘qemu_strtoul’; did you mean ‘strtoul’? [-Wimplicit-function-declaration]
           qemu_strtoul(argv[1], NULL, 0, &pagesize);
           ^~~~~~~~~~~~
           strtoul
  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ‘qemu_real_host_page_size’ undeclared (first use in this function)
           pagesize = qemu_real_host_page_size;
                      ^~~~~~~~~~~~~~~~~~~~~~~~
  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in
  make[2]: *** [../Makefile.target:103: test-mmap] Error 1
  make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
  make: *** Waiting for unfinished jobs....

>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++---------------
>  1 file changed, 36 insertions(+), 31 deletions(-)
>
> diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
> index 11d0e777b1..9ea49e2307 100644
> --- a/tests/tcg/multiarch/test-mmap.c
> +++ b/tests/tcg/multiarch/test-mmap.c
> @@ -456,49 +456,54 @@ void check_invalid_mmaps(void)
>
>  int main(int argc, char **argv)
>  {
> -	char tempname[] = "/tmp/.cmmapXXXXXX";
> -	unsigned int i;
> -
> -	/* Trust the first argument, otherwise probe the system for our
> -	   pagesize.  */
> -	if (argc > 1)
> -		pagesize = strtoul(argv[1], NULL, 0);
> -	else
> -		pagesize = sysconf(_SC_PAGESIZE);
> +    char tempname[] = "/tmp/.cmmapXXXXXX";
> +    unsigned int i;
> +
> +    /*
> +     * Trust the first argument, otherwise probe the system for our
> +     * pagesize.
> +     */
> +    if (argc > 1) {
> +        qemu_strtoul(argv[1], NULL, 0, &pagesize);
> +    } else {
> +        pagesize = sysconf(_SC_PAGESIZE);
> +    }
>
> -	/* Assume pagesize is a power of two.  */
> -	pagemask = pagesize - 1;
> -	dummybuf = malloc (pagesize);
> -	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
> +    /* Assume pagesize is a power of two.  */
> +    pagemask = pagesize - 1;
> +    dummybuf = malloc(pagesize);
> +    printf("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>
> -	test_fd = mkstemp(tempname);
> -	unlink(tempname);
> +    test_fd = mkstemp(tempname);
> +    unlink(tempname);
>
> -	/* Fill the file with int's counting from zero and up.  */
> +    /* Fill the file with int's counting from zero and up.  */
>      for (i = 0; i < (pagesize * 4) / sizeof i; i++) {
>          checked_write(test_fd, &i, sizeof i);
>      }
>
> -	/* Append a few extra writes to make the file end at non
> -	   page boundary.  */
> +    /*
> +     * Append a few extra writes to make the file end at non
> +     * page boundary.
> +     */
>      checked_write(test_fd, &i, sizeof i); i++;
>      checked_write(test_fd, &i, sizeof i); i++;
>      checked_write(test_fd, &i, sizeof i); i++;
>
> -	test_fsize = lseek(test_fd, 0, SEEK_CUR);
> +    test_fsize = lseek(test_fd, 0, SEEK_CUR);
>
> -	/* Run the tests.  */
> -	check_aligned_anonymous_unfixed_mmaps();
> -	check_aligned_anonymous_unfixed_colliding_mmaps();
> -	check_aligned_anonymous_fixed_mmaps();
> -	check_file_unfixed_mmaps();
> -	check_file_fixed_mmaps();
> -	check_file_fixed_eof_mmaps();
> -	check_file_unfixed_eof_mmaps();
> -	check_invalid_mmaps();
> +    /* Run the tests.  */
> +    check_aligned_anonymous_unfixed_mmaps();
> +    check_aligned_anonymous_unfixed_colliding_mmaps();
> +    check_aligned_anonymous_fixed_mmaps();
> +    check_file_unfixed_mmaps();
> +    check_file_fixed_mmaps();
> +    check_file_fixed_eof_mmaps();
> +    check_file_unfixed_eof_mmaps();
> +    check_invalid_mmaps();
>
> -	/* Fails at the moment.  */
> -	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
> +    /* Fails at the moment.  */
> +    /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>
> -	return EXIT_SUCCESS;
> +    return EXIT_SUCCESS;
>  }


--
Alex Bennée
Wei Yang Nov. 11, 2019, 3:47 p.m. UTC | #3
On Mon, Nov 11, 2019 at 10:25:43AM +0000, Alex Benn??e wrote:
>
>Wei Yang <richardw.yang@linux.intel.com> writes:
>
>> This file uses quite a different code style and changing just one line
>> would leads to some awkward appearance.
>>
>> This is a preparation for the following replacement of
>> sysconf(_SC_PAGESIZE).
>>
>> BTW, to depress ERROR message from checkpatch.pl, this patch replaces
>> strtoul with qemu_strtoul.
>
>
>NACK I'm afraid.
>
>The tests/tcg directory all build against glibc only to make them easier
>to cross-compile for the various targets. If you run check-tcg and have
>a non-native cross compiler setup you'll notice this fails to build:
>
>    BUILD   aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ???main???:
>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ???qemu_strtoul???; did you mean ???strtoul???? [-Wimplicit-function-declaration]
>           qemu_strtoul(argv[1], NULL, 0, &pagesize);
>           ^~~~~~~~~~~~
>           strtoul
>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ???qemu_real_host_page_size??? undeclared (first use in this function)
>           pagesize = qemu_real_host_page_size;
>                      ^~~~~~~~~~~~~~~~~~~~~~~~
>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in
>  make[2]: *** [../Makefile.target:103: test-mmap] Error 1
>  make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
>  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
>  make: *** Waiting for unfinished jobs....
>

This output is from "make test" ?

>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++---------------
>>  1 file changed, 36 insertions(+), 31 deletions(-)
>>
>> diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
>> index 11d0e777b1..9ea49e2307 100644
>> --- a/tests/tcg/multiarch/test-mmap.c
>> +++ b/tests/tcg/multiarch/test-mmap.c
>> @@ -456,49 +456,54 @@ void check_invalid_mmaps(void)
>>
>>  int main(int argc, char **argv)
>>  {
>> -	char tempname[] = "/tmp/.cmmapXXXXXX";
>> -	unsigned int i;
>> -
>> -	/* Trust the first argument, otherwise probe the system for our
>> -	   pagesize.  */
>> -	if (argc > 1)
>> -		pagesize = strtoul(argv[1], NULL, 0);
>> -	else
>> -		pagesize = sysconf(_SC_PAGESIZE);
>> +    char tempname[] = "/tmp/.cmmapXXXXXX";
>> +    unsigned int i;
>> +
>> +    /*
>> +     * Trust the first argument, otherwise probe the system for our
>> +     * pagesize.
>> +     */
>> +    if (argc > 1) {
>> +        qemu_strtoul(argv[1], NULL, 0, &pagesize);
>> +    } else {
>> +        pagesize = sysconf(_SC_PAGESIZE);
>> +    }
>>
>> -	/* Assume pagesize is a power of two.  */
>> -	pagemask = pagesize - 1;
>> -	dummybuf = malloc (pagesize);
>> -	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>> +    /* Assume pagesize is a power of two.  */
>> +    pagemask = pagesize - 1;
>> +    dummybuf = malloc(pagesize);
>> +    printf("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>>
>> -	test_fd = mkstemp(tempname);
>> -	unlink(tempname);
>> +    test_fd = mkstemp(tempname);
>> +    unlink(tempname);
>>
>> -	/* Fill the file with int's counting from zero and up.  */
>> +    /* Fill the file with int's counting from zero and up.  */
>>      for (i = 0; i < (pagesize * 4) / sizeof i; i++) {
>>          checked_write(test_fd, &i, sizeof i);
>>      }
>>
>> -	/* Append a few extra writes to make the file end at non
>> -	   page boundary.  */
>> +    /*
>> +     * Append a few extra writes to make the file end at non
>> +     * page boundary.
>> +     */
>>      checked_write(test_fd, &i, sizeof i); i++;
>>      checked_write(test_fd, &i, sizeof i); i++;
>>      checked_write(test_fd, &i, sizeof i); i++;
>>
>> -	test_fsize = lseek(test_fd, 0, SEEK_CUR);
>> +    test_fsize = lseek(test_fd, 0, SEEK_CUR);
>>
>> -	/* Run the tests.  */
>> -	check_aligned_anonymous_unfixed_mmaps();
>> -	check_aligned_anonymous_unfixed_colliding_mmaps();
>> -	check_aligned_anonymous_fixed_mmaps();
>> -	check_file_unfixed_mmaps();
>> -	check_file_fixed_mmaps();
>> -	check_file_fixed_eof_mmaps();
>> -	check_file_unfixed_eof_mmaps();
>> -	check_invalid_mmaps();
>> +    /* Run the tests.  */
>> +    check_aligned_anonymous_unfixed_mmaps();
>> +    check_aligned_anonymous_unfixed_colliding_mmaps();
>> +    check_aligned_anonymous_fixed_mmaps();
>> +    check_file_unfixed_mmaps();
>> +    check_file_fixed_mmaps();
>> +    check_file_fixed_eof_mmaps();
>> +    check_file_unfixed_eof_mmaps();
>> +    check_invalid_mmaps();
>>
>> -	/* Fails at the moment.  */
>> -	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>> +    /* Fails at the moment.  */
>> +    /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>>
>> -	return EXIT_SUCCESS;
>> +    return EXIT_SUCCESS;
>>  }
>
>
>--
>Alex Benn??e
Alex Bennée Nov. 11, 2019, 4 p.m. UTC | #4
Wei Yang <richard.weiyang@gmail.com> writes:

> On Mon, Nov 11, 2019 at 10:25:43AM +0000, Alex Benn??e wrote:
>>
>>Wei Yang <richardw.yang@linux.intel.com> writes:
>>
>>> This file uses quite a different code style and changing just one line
>>> would leads to some awkward appearance.
>>>
>>> This is a preparation for the following replacement of
>>> sysconf(_SC_PAGESIZE).
>>>
>>> BTW, to depress ERROR message from checkpatch.pl, this patch replaces
>>> strtoul with qemu_strtoul.
>>
>>
>>NACK I'm afraid.
>>
>>The tests/tcg directory all build against glibc only to make them easier
>>to cross-compile for the various targets. If you run check-tcg and have
>>a non-native cross compiler setup you'll notice this fails to build:
>>
>>    BUILD   aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
>>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ???main???:
>>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ???qemu_strtoul???; did you mean ???strtoul???? [-Wimplicit-function-declaration]
>>           qemu_strtoul(argv[1], NULL, 0, &pagesize);
>>           ^~~~~~~~~~~~
>>           strtoul
>>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ???qemu_real_host_page_size??? undeclared (first use in this function)
>>           pagesize = qemu_real_host_page_size;
>>                      ^~~~~~~~~~~~~~~~~~~~~~~~
>>  /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in
>>  make[2]: *** [../Makefile.target:103: test-mmap] Error 1
>>  make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
>>  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
>>  make: *** Waiting for unfinished jobs....
>>
>
> This output is from "make test" ?

make check-tcg

>
>>>
>>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>>> ---
>>>  tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++---------------
>>>  1 file changed, 36 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
>>> index 11d0e777b1..9ea49e2307 100644
>>> --- a/tests/tcg/multiarch/test-mmap.c
>>> +++ b/tests/tcg/multiarch/test-mmap.c
>>> @@ -456,49 +456,54 @@ void check_invalid_mmaps(void)
>>>
>>>  int main(int argc, char **argv)
>>>  {
>>> -	char tempname[] = "/tmp/.cmmapXXXXXX";
>>> -	unsigned int i;
>>> -
>>> -	/* Trust the first argument, otherwise probe the system for our
>>> -	   pagesize.  */
>>> -	if (argc > 1)
>>> -		pagesize = strtoul(argv[1], NULL, 0);
>>> -	else
>>> -		pagesize = sysconf(_SC_PAGESIZE);
>>> +    char tempname[] = "/tmp/.cmmapXXXXXX";
>>> +    unsigned int i;
>>> +
>>> +    /*
>>> +     * Trust the first argument, otherwise probe the system for our
>>> +     * pagesize.
>>> +     */
>>> +    if (argc > 1) {
>>> +        qemu_strtoul(argv[1], NULL, 0, &pagesize);
>>> +    } else {
>>> +        pagesize = sysconf(_SC_PAGESIZE);
>>> +    }
>>>
>>> -	/* Assume pagesize is a power of two.  */
>>> -	pagemask = pagesize - 1;
>>> -	dummybuf = malloc (pagesize);
>>> -	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>>> +    /* Assume pagesize is a power of two.  */
>>> +    pagemask = pagesize - 1;
>>> +    dummybuf = malloc(pagesize);
>>> +    printf("pagesize=%u pagemask=%x\n", pagesize, pagemask);
>>>
>>> -	test_fd = mkstemp(tempname);
>>> -	unlink(tempname);
>>> +    test_fd = mkstemp(tempname);
>>> +    unlink(tempname);
>>>
>>> -	/* Fill the file with int's counting from zero and up.  */
>>> +    /* Fill the file with int's counting from zero and up.  */
>>>      for (i = 0; i < (pagesize * 4) / sizeof i; i++) {
>>>          checked_write(test_fd, &i, sizeof i);
>>>      }
>>>
>>> -	/* Append a few extra writes to make the file end at non
>>> -	   page boundary.  */
>>> +    /*
>>> +     * Append a few extra writes to make the file end at non
>>> +     * page boundary.
>>> +     */
>>>      checked_write(test_fd, &i, sizeof i); i++;
>>>      checked_write(test_fd, &i, sizeof i); i++;
>>>      checked_write(test_fd, &i, sizeof i); i++;
>>>
>>> -	test_fsize = lseek(test_fd, 0, SEEK_CUR);
>>> +    test_fsize = lseek(test_fd, 0, SEEK_CUR);
>>>
>>> -	/* Run the tests.  */
>>> -	check_aligned_anonymous_unfixed_mmaps();
>>> -	check_aligned_anonymous_unfixed_colliding_mmaps();
>>> -	check_aligned_anonymous_fixed_mmaps();
>>> -	check_file_unfixed_mmaps();
>>> -	check_file_fixed_mmaps();
>>> -	check_file_fixed_eof_mmaps();
>>> -	check_file_unfixed_eof_mmaps();
>>> -	check_invalid_mmaps();
>>> +    /* Run the tests.  */
>>> +    check_aligned_anonymous_unfixed_mmaps();
>>> +    check_aligned_anonymous_unfixed_colliding_mmaps();
>>> +    check_aligned_anonymous_fixed_mmaps();
>>> +    check_file_unfixed_mmaps();
>>> +    check_file_fixed_mmaps();
>>> +    check_file_fixed_eof_mmaps();
>>> +    check_file_unfixed_eof_mmaps();
>>> +    check_invalid_mmaps();
>>>
>>> -	/* Fails at the moment.  */
>>> -	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>>> +    /* Fails at the moment.  */
>>> +    /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
>>>
>>> -	return EXIT_SUCCESS;
>>> +    return EXIT_SUCCESS;
>>>  }
>>
>>
>>--
>>Alex Benn??e


--
Alex Bennée
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c
index 11d0e777b1..9ea49e2307 100644
--- a/tests/tcg/multiarch/test-mmap.c
+++ b/tests/tcg/multiarch/test-mmap.c
@@ -456,49 +456,54 @@  void check_invalid_mmaps(void)
 
 int main(int argc, char **argv)
 {
-	char tempname[] = "/tmp/.cmmapXXXXXX";
-	unsigned int i;
-
-	/* Trust the first argument, otherwise probe the system for our
-	   pagesize.  */
-	if (argc > 1)
-		pagesize = strtoul(argv[1], NULL, 0);
-	else
-		pagesize = sysconf(_SC_PAGESIZE);
+    char tempname[] = "/tmp/.cmmapXXXXXX";
+    unsigned int i;
+
+    /*
+     * Trust the first argument, otherwise probe the system for our
+     * pagesize.
+     */
+    if (argc > 1) {
+        qemu_strtoul(argv[1], NULL, 0, &pagesize);
+    } else {
+        pagesize = sysconf(_SC_PAGESIZE);
+    }
 
-	/* Assume pagesize is a power of two.  */
-	pagemask = pagesize - 1;
-	dummybuf = malloc (pagesize);
-	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
+    /* Assume pagesize is a power of two.  */
+    pagemask = pagesize - 1;
+    dummybuf = malloc(pagesize);
+    printf("pagesize=%u pagemask=%x\n", pagesize, pagemask);
 
-	test_fd = mkstemp(tempname);
-	unlink(tempname);
+    test_fd = mkstemp(tempname);
+    unlink(tempname);
 
-	/* Fill the file with int's counting from zero and up.  */
+    /* Fill the file with int's counting from zero and up.  */
     for (i = 0; i < (pagesize * 4) / sizeof i; i++) {
         checked_write(test_fd, &i, sizeof i);
     }
 
-	/* Append a few extra writes to make the file end at non 
-	   page boundary.  */
+    /*
+     * Append a few extra writes to make the file end at non
+     * page boundary.
+     */
     checked_write(test_fd, &i, sizeof i); i++;
     checked_write(test_fd, &i, sizeof i); i++;
     checked_write(test_fd, &i, sizeof i); i++;
 
-	test_fsize = lseek(test_fd, 0, SEEK_CUR);
+    test_fsize = lseek(test_fd, 0, SEEK_CUR);
 
-	/* Run the tests.  */
-	check_aligned_anonymous_unfixed_mmaps();
-	check_aligned_anonymous_unfixed_colliding_mmaps();
-	check_aligned_anonymous_fixed_mmaps();
-	check_file_unfixed_mmaps();
-	check_file_fixed_mmaps();
-	check_file_fixed_eof_mmaps();
-	check_file_unfixed_eof_mmaps();
-	check_invalid_mmaps();
+    /* Run the tests.  */
+    check_aligned_anonymous_unfixed_mmaps();
+    check_aligned_anonymous_unfixed_colliding_mmaps();
+    check_aligned_anonymous_fixed_mmaps();
+    check_file_unfixed_mmaps();
+    check_file_fixed_mmaps();
+    check_file_fixed_eof_mmaps();
+    check_file_unfixed_eof_mmaps();
+    check_invalid_mmaps();
 
-	/* Fails at the moment.  */
-	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
+    /* Fails at the moment.  */
+    /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
 
-	return EXIT_SUCCESS;
+    return EXIT_SUCCESS;
 }