From: Peter Xu <peterx@redhat.com>
To: Paolo Bonzini <pbonzini@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 16:26:06 +0800 [thread overview]
Message-ID: <20160309082606.GS2377@pxdev.xzpeter.org> (raw)
In-Reply-To: <56DFD6CB.90906@redhat.com>
On Wed, Mar 09, 2016 at 08:54:51AM +0100, Paolo Bonzini wrote:
> > @@ -1292,7 +1291,7 @@ static void *source_return_path_thread(void *opaque)
> >
> > 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?
Anyway, I take my above question as trivial since current buffer is
char typed.
Thanks!
Peter
next prev parent reply other threads:[~2016-03-09 8:26 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 [this message]
2016-03-09 9:30 ` Paolo Bonzini
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=20160309082606.GS2377@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=amit.shah@redhat.com \
--cc=pbonzini@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 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).