All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Julien Grall <julien.grall@arm.com>,
	Paul Durrant <paul.durrant@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v5 for-4.9 2/4] hvm/dmop: Implement copy_{to, from}_guest_buf() in terms of raw accessors
Date: Mon, 10 Apr 2017 03:48:00 -0600	[thread overview]
Message-ID: <58EB70F0020000780014F400@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1491593753-1181-2-git-send-email-andrew.cooper3@citrix.com>

>>> On 07.04.17 at 21:35, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -37,36 +37,48 @@ struct dmop_bufs {
>  #undef MAX_NR_BUFS
>  };
>  
> -static bool copy_buf_from_guest(const xen_dm_op_buf_t bufs[],
> -                                unsigned int nr_bufs, void *dst,
> -                                unsigned int idx, size_t dst_size)
> +static bool _raw_copy_from_guest_buf(
> +    const struct dmop_bufs *bufs, unsigned int idx,
> +    void *dst, size_t dst_bytes)

If the parameters all get re-arranged anyway, could I talk you into
ordering them in the more memcpy()-like destination, source, size
sequence?

Also, while certainly a matter of taste, I liked the previous way of
indenting better.

>  {
> -    size_t size;
> +    size_t buf_bytes;
>  
> -    if ( idx >= nr_bufs )
> +    if ( idx >= bufs->nr )
>          return false;
>  
> -    memset(dst, 0, dst_size);
> +    buf_bytes = bufs->buf[idx].size;
>  
> -    size = min_t(size_t, dst_size, bufs[idx].size);
> +    if ( dst_bytes > buf_bytes )
> +        return false;
> +
> +    memset(dst, 0, dst_bytes);
>  
> -    return !copy_from_guest(dst, bufs[idx].h, size);
> +    return !copy_from_guest(dst, bufs->buf[idx].h, dst_bytes);
>  }

The change away from using min() is a behavioral change which you
give no reason for, and which I don't see belonging here (if it is
wanted at all). And if that's what we want, then the memset() is
now pointless.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-04-10  9:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 19:35 [PATCH v5 for-4.9 1/4] hvm/dmop: Box dmop_bufs rather than passing two parameters around Andrew Cooper
2017-04-07 19:35 ` [PATCH v5 for-4.9 2/4] hvm/dmop: Implement copy_{to, from}_guest_buf() in terms of raw accessors Andrew Cooper
2017-04-10  9:48   ` Jan Beulich [this message]
2017-04-07 19:35 ` [PATCH v5 for-4.9 3/4] hvm/dmop: Implement copy_{to, from}_guest_buf_offset() helpers Andrew Cooper
2017-04-10  9:11   ` Paul Durrant
2017-04-10  9:35     ` Andrew Cooper
2017-04-10  9:52       ` Paul Durrant
2017-04-10  9:57         ` Andrew Cooper
2017-04-10 10:04           ` Paul Durrant
2017-04-07 19:35 ` [PATCH v5 for-4.9 4/4] dmop: Add xendevicemodel_modified_memory_bulk() Andrew Cooper
2017-04-10  9:04 ` [PATCH v5 for-4.9 1/4] hvm/dmop: Box dmop_bufs rather than passing two parameters around Paul Durrant
2017-04-10  9:29   ` Andrew Cooper
2017-04-10  9:40     ` Paul Durrant
2017-04-10 10:04       ` Andrew Cooper
2017-04-10 10:12         ` Paul Durrant
2017-04-10 10:06       ` Jennifer Herbert
2017-04-10 10:18         ` Paul Durrant
2017-04-10  9:39 ` Jan Beulich

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=58EB70F0020000780014F400@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xen.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.