Re: [Qemu-devel] [PATCH v2 4/4] ARRAY_SIZE: check that argument is an array

2017-01-19 Thread Eric Blake
On 01/18/2017 02:55 PM, Michael S. Tsirkin wrote: > It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring > changes the argument from an array to a pointer to a dynamically > allocated buffer. Code keeps compiling but any ARRAY_SIZE calls now > return the size of the pointer divided

Re: [Qemu-devel] [PATCH v2 4/4] ARRAY_SIZE: check that argument is an array

2017-01-19 Thread Michael S. Tsirkin
On Thu, Jan 19, 2017 at 08:53:34AM -0600, Eric Blake wrote: > On 01/18/2017 02:55 PM, Michael S. Tsirkin wrote: > > It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring > > changes the argument from an array to a pointer to a dynamically > > allocated buffer. Code keeps compiling b

Re: [Qemu-devel] [PATCH v2 4/4] ARRAY_SIZE: check that argument is an array

2017-01-19 Thread Peter Maydell
On 19 January 2017 at 08:20, Markus Armbruster wrote: > "Michael S. Tsirkin" writes: > >> It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring >> changes the argument from an array to a pointer to a dynamically >> allocated buffer. Code keeps compiling but any ARRAY_SIZE calls no

Re: [Qemu-devel] [PATCH v2 4/4] ARRAY_SIZE: check that argument is an array

2017-01-19 Thread Markus Armbruster
"Michael S. Tsirkin" writes: > It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring > changes the argument from an array to a pointer to a dynamically > allocated buffer. Code keeps compiling but any ARRAY_SIZE calls now > return the size of the pointer divided by element size. >

[Qemu-devel] [PATCH v2 4/4] ARRAY_SIZE: check that argument is an array

2017-01-18 Thread Michael S. Tsirkin
It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring changes the argument from an array to a pointer to a dynamically allocated buffer. Code keeps compiling but any ARRAY_SIZE calls now return the size of the pointer divided by element size. Let's add build time checks to ARRAY_SI