[cairo] [PATCH] test and util: maintain consistency in the usage of ARRAY_LENGTH macro

RAVI NANJUNDAPPA nravi.n at samsung.com
Wed Apr 23 20:05:18 PDT 2014


Hello Bryce, 

Please see the comments inline below.

Thanks and Best Regards, 

N Ravi

> -----Original Message-----
> From: Bryce W. Harrington [mailto:b.harrington at samsung.com]
> Sent: Wednesday, April 23, 2014 11:42 PM
> To: Ravi Nanjundappa
> Cc: cairo at cairographics.org
> Subject: Re: [cairo] [PATCH] test and util: maintain consistency in the
usage
> of ARRAY_LENGTH macro
> 
> Looks good to me.

Thanks for the review.

> 
> Have you run 'make test' and 'make perf' with this patch compiled in?
> (For this patch, you don't need to let the tests run to completion; if
this is
> going to fail, it'll fail right away, so just run each for a few minutes
and verify
> results look okay.)

Yes. I've run the 'make test' and 'make perf' with this patch.
PFA the logs for the same. (as you had mentioned, I didn't run the
tests/perf for long time... The log files include output lines
until the executing the tests).
I hope this should be fine.


> 
> Reviewed-by: Bryce Harrington <b.harrington at samsung.com>
> 
> On Wed, Apr 23, 2014 at 08:32:19AM +0530, Ravi Nanjundappa wrote:
> > ARRAY_LENGTH macro is used in perf's cairo-perf.h, src's cairoint.h,
> > test's cairo-test.h and in some internal header files of util's
> > directory.So to maintain consistency ARRAY_SIZE is replaced with
> > ARRAY_LENGTH macro.
> >
> > Signed-off-by: Ravi Nanjundappa <nravi.n at samsung.com>
> > ---
> >  test/cairo-test.c        |   12 ++++++------
> >  util/cairo-trace/trace.c |    7 ++++---
> >  util/malloc-stats.c      |    9 +++++----
> >  3 files changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/test/cairo-test.c b/test/cairo-test.c index
> > 119506d..8dbf4c6 100644
> > --- a/test/cairo-test.c
> > +++ b/test/cairo-test.c
> > @@ -83,8 +83,8 @@
> >  #define TRUE !FALSE
> >  #endif
> >
> > -#ifndef ARRAY_SIZE
> > -#define ARRAY_SIZE(A) (sizeof(A) / sizeof (A[0]))
> > +#ifndef ARRAY_LENGTH
> > +#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof
> > +(__array[0])))
> >  #endif
> >
> >  #if ! HAVE_ALARM || ! defined(SIGALRM) @@ -1088,13 +1088,13 @@
> > REPEAT:
> >
> >  	    if (cairo_test_file_is_older (pass_filename,
> >  					  filenames,
> > -					  ARRAY_SIZE (filenames)))
> > +					  ARRAY_LENGTH (filenames)))
> >  	    {
> >  		_xunlink (ctx, pass_filename);
> >  	    }
> >  	    if (cairo_test_file_is_older (fail_filename,
> >  					  filenames,
> > -					  ARRAY_SIZE (filenames)))
> > +					  ARRAY_LENGTH (filenames)))
> >  	    {
> >  		_xunlink (ctx, fail_filename);
> >  	    }
> > @@ -1180,13 +1180,13 @@ REPEAT:
> >
> >  	    if (cairo_test_file_is_older (pass_filename,
> >  					  filenames,
> > -					  ARRAY_SIZE (filenames)))
> > +					  ARRAY_LENGTH (filenames)))
> >  	    {
> >  		_xunlink (ctx, pass_filename);
> >  	    }
> >  	    if (cairo_test_file_is_older (fail_filename,
> >  					  filenames,
> > -					  ARRAY_SIZE (filenames)))
> > +					  ARRAY_LENGTH (filenames)))
> >  	    {
> >  		_xunlink (ctx, fail_filename);
> >  	    }
> > diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index
> > ebfc81a..d5111d7 100644
> > --- a/util/cairo-trace/trace.c
> > +++ b/util/cairo-trace/trace.c
> > @@ -127,8 +127,9 @@ static void *_dlhandle = RTLD_NEXT;
> >      (*name##_real) (args);  \
> >  })
> >
> > -#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) -#define
> > ARRAY_LENGTH(a) ((int) ARRAY_SIZE(a))
> > +#ifndef ARRAY_LENGTH
> > +#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof
> > +(__array[0]))) #endif
> >
> >  #if SIZEOF_VOID_P == 4
> >  #define PTR_SHIFT 2
> > @@ -280,7 +281,7 @@ _type_next_token (Type *t)
> >
> >  	if (b->count < sizeof (b->map) * CHAR_BIT) {
> >  	    unsigned int n, m, bit;
> > -	    for (n = 0; n < ARRAY_SIZE (b->map); n++) {
> > +	    for (n = 0; n < ARRAY_LENGTH (b->map); n++) {
> >  		if (b->map[n] == (unsigned int) -1)
> >  		    continue;
> >
> > diff --git a/util/malloc-stats.c b/util/malloc-stats.c index
> > da91656..690efcf 100644
> > --- a/util/malloc-stats.c
> > +++ b/util/malloc-stats.c
> > @@ -60,8 +60,9 @@ static struct alloc_stats_t total_allocations;
> > static struct func_stat_t *func_stats[31627];  static int
> > func_stats_num;
> >
> > -#define ARRAY_SIZE(A) (sizeof (A)/sizeof (A[0]))
> > -
> > +#ifndef ARRAY_LENGTH
> > +#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof
> > +(__array[0]))) #endif
> >  static void
> >  alloc_stats_add (struct alloc_stats_t *stats, int is_realloc, size_t
> > size)  { @@ -147,7 +148,7 @@ func_stats_add (const void *caller, int
> > is_realloc, size_t size)
> >
> >  	alloc_stats_add (&total_allocations, is_realloc, size);
> >
> > -	i = ((uintptr_t) caller ^ 1215497) % ARRAY_SIZE (func_stats);
> > +	i = ((uintptr_t) caller ^ 1215497) % ARRAY_LENGTH (func_stats);
> >  	for (elt = func_stats[i]; elt != NULL; elt = elt->next) {
> >  		if (elt->addr == caller)
> >  			break;
> > @@ -328,7 +329,7 @@ malloc_stats (void)
> >  		return;
> >
> >  	j = 0;
> > -	for (i = 0; i < ARRAY_SIZE (func_stats); i++) {
> > +	for (i = 0; i < ARRAY_LENGTH (func_stats); i++) {
> >  		struct func_stat_t *elt;
> >  		for (elt = func_stats[i]; elt != NULL; elt = elt->next)
> >  			sorted_func_stats[j++] = *elt;
> > --
> > 1.7.9.5
> >
> > --
> > cairo mailing list
> > cairo at cairographics.org
> > http://lists.cairographics.org/mailman/listinfo/cairo=
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-test-and-perf-logs.zip
Type: application/octet-stream
Size: 9616 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140424/5b62d462/attachment.obj>


More information about the cairo mailing list