All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yang <richardw.yang@linux.intel.com>
To: kwolf@redhat.com, mreitz@redhat.com, jasowang@redhat.com,
	alex.bennee@linaro.org, dgilbert@redhat.com,
	richard.henderson@linaro.org
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Wei Yang <richardw.yang@linux.intel.com>
Subject: [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c
Date: Tue, 15 Oct 2019 11:13:49 +0800	[thread overview]
Message-ID: <20191015031350.4345-2-richardw.yang@linux.intel.com> (raw)
In-Reply-To: <20191015031350.4345-1-richardw.yang@linux.intel.com>

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);
+    } 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;
 }
-- 
2.17.1



  reply	other threads:[~2019-10-15  3:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  3:13 [PATCH 0/2] replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size Wei Yang
2019-10-15  3:13 ` Wei Yang [this message]
2019-11-11  9:57   ` [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c Stefano Garzarella
2019-11-11 10:25   ` Alex Bennée
2019-11-11 15:47     ` Wei Yang
2019-11-11 16:00       ` Alex Bennée
2019-10-15  3:13 ` [PATCH 2/2] core: replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size Wei Yang
2019-11-11 10:06   ` Stefano Garzarella
2019-11-11 15:46     ` Wei Yang
2019-11-09  1:25 ` [PATCH 0/2] " Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015031350.4345-2-richardw.yang@linux.intel.com \
    --to=richardw.yang@linux.intel.com \
    --cc=alex.bennee@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.