qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: peter.maydell@linaro.org, gkurz@linux.vnet.ibm.com,
	armbru@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH] util/mmap-alloc: check parameter before using
Date: Wed, 26 Oct 2016 08:33:37 -0500	[thread overview]
Message-ID: <d95a35fa-df3c-0b0e-52bf-d4cc002bde8f@redhat.com> (raw)
In-Reply-To: <1477466334-4078-1-git-send-email-caoj.fnst@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On 10/26/2016 02:18 AM, Cao jin wrote:
> Also refactor some code hunk for readability
> 
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  util/mmap-alloc.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
> index 5a85aa3..92c123a 100644
> --- a/util/mmap-alloc.c
> +++ b/util/mmap-alloc.c
> @@ -41,6 +41,11 @@ size_t qemu_fd_getpagesize(int fd)
>  
>  void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
>  {
> +    /* Make sure align is a power of 2 */
> +    assert(!(align & (align - 1)));

Better to spell this:

assert(is_power_of_2(align));

at which point the comment is redundant and can be omitted.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      parent reply	other threads:[~2016-10-26 13:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26  7:18 [Qemu-devel] [PATCH] util/mmap-alloc: check parameter before using Cao jin
2016-10-26  8:10 ` Thomas Huth
2016-10-26 10:14   ` Cao jin
2016-10-26 13:33 ` Eric Blake [this message]

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=d95a35fa-df3c-0b0e-52bf-d4cc002bde8f@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).