Re: [patch 1/2 -mm] flex_array: introduce DEFINE_FLEX_ARRAY

From: Dave Hansen
Date: Wed Sep 02 2009 - 13:27:09 EST


On Tue, 2009-09-01 at 20:14 -0700, David Rientjes wrote:
> @@ -152,7 +136,8 @@ static unsigned int index_inside_part(struct
> flex_array *fa,
> {
> unsigned int part_offset;
>
> - part_offset = element_nr % __elements_per_part(fa->element_size);
> + part_offset = element_nr %
> + FLEX_ARRAY_ELEMENTS_PER_PART(fa->element_size);
> return part_offset * fa->element_size;
> }

This all looks pretty good. The only issue is that the macro name
lengths have gotten a bit out of hand.

For instance. This:

#define FLEX_ARRAY_ELEMENTS_PER_PART(size) \
(FLEX_ARRAY_PART_SIZE / size)

ends up being longer in practice than just open-coding the operation:

FLEX_ARRAY_ELEMENTS_PER_PART(fa->element_size)

vs.

(FLEX_ARRAY_PART_SIZE / fa->element_size)

and the length also ends up making for a couple of pretty ugly line
wraps.

Otherwise, this is fine with me.

Acked-by: Dave Hansen <dave@xxxxxxxxxxxxxxxxxx>

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/