On 20/01/2017 08:34, Markus Armbruster wrote:
> Eric Blake writes:
>
>> On 01/19/2017 04:11 PM, Michael S. Tsirkin wrote:
>>
> +#define QEMU_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), \
> +typeof(&(x)[0])))
> #ifnde
Eric Blake writes:
> On 01/19/2017 04:11 PM, Michael S. Tsirkin wrote:
>
+#define QEMU_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), \
+typeof(&(x)[0])))
#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / siz
On 01/19/2017 04:11 PM, Michael S. Tsirkin wrote:
>>> +#define QEMU_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), \
>>> +typeof(&(x)[0])))
>>> #ifndef ARRAY_SIZE
>>> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
>>> +#define AR
On Thu, Jan 19, 2017 at 03:59:33PM -0600, Eric Blake wrote:
> On 01/19/2017 03:07 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
On 01/19/2017 03:07 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
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