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