lkml.org 
[lkml]   [2009]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch 1/2 -mm] flex_array: introduce DEFINE_FLEX_ARRAY
From
Date
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@linux.vnet.ibm.com>

-- Dave



\
 
 \ /
  Last update: 2009-09-02 19:29    [W:0.367 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site