All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH] migration: fix warning for source_return_path_thread
Date: Wed, 9 Mar 2016 10:30:20 +0100	[thread overview]
Message-ID: <56DFED2C.2080507@redhat.com> (raw)
In-Reply-To: <20160309082606.GS2377@pxdev.xzpeter.org>



On 09/03/2016 09:26, Peter Xu wrote:
>>> > >          if ((rp_cmd_args[header_type].len != -1 &&
>>> > >              header_len != rp_cmd_args[header_type].len) ||
>>> > > -            header_len > max_len) {
>>> > > +            header_len > sizeof(buf)) {
>> > 
>> > sizeof works fine because buf is an array of bytes, but ARRAY_SIZE is
>> > better because it works for any type of buffer.
> I carefully chose "sizeof" out of "ARRAY_SIZE" as commented by Eric
> that, we'd better use sizeof() for char typed buffers.
> 
> Will this be related to how header_len is defined? That's something
> I do not know... :( E.g., if it's defined as "length in bytes", then
> shall we better use sizeof() in all cases?

Oops, I was wrong. It's related to how header_len is used.  header_len
here is clearly a size in bytes (it's passed to qemu_get_buffer), so the
patch is okay.

Paolo

> Anyway, I take my above question as trivial since current buffer is
> char typed.

      reply	other threads:[~2016-03-09  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09  6:12 [Qemu-devel] [PATCH] migration: fix warning for source_return_path_thread Peter Xu
2016-03-09  7:54 ` Paolo Bonzini
2016-03-09  8:26   ` Peter Xu
2016-03-09  9:30     ` Paolo Bonzini [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=56DFED2C.2080507@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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.