qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] migration: fix warning for source_return_path_t


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] migration: fix warning for source_return_path_thread
Date: Wed, 9 Mar 2016 10:30:20 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0


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 via email to

[Prev in Thread] Current Thread [Next in Thread]