[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1696626 - /subversion/trunk/subversion/libsvn_ra_serf/util.c

From: Stefan Fuhrmann <stefan.fuhrmann_at_wandisco.com>
Date: Fri, 21 Aug 2015 19:45:04 +0100

On Wed, Aug 19, 2015 at 6:57 PM, Branko Čibej <brane_at_wandisco.com> wrote:

> On 19.08.2015 18:26, stefan2_at_apache.org wrote:
> > Author: stefan2
> > Date: Wed Aug 19 16:26:05 2015
> > New Revision: 1696626
> >
> > URL: http://svn.apache.org/r1696626
> > Log:
> > * subversion/libsvn_ra_serf/util.c
> > (ssl_convert_serf_failures): When doing array size calculations, refer
> to
> > the array object only.
> >
> > Modified:
> > subversion/trunk/subversion/libsvn_ra_serf/util.c
> >
> > Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
> > URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1696626&r1=1696625&r2=1696626&view=diff
> >
> ==============================================================================
> > --- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
> > +++ subversion/trunk/subversion/libsvn_ra_serf/util.c Wed Aug 19
> 16:26:05 2015
> > @@ -65,7 +65,9 @@ ssl_convert_serf_failures(int failures)
> > apr_uint32_t svn_failures = 0;
> > apr_size_t i;
> >
> > - for (i = 0; i < sizeof(serf_failure_map) / (2 *
> sizeof(apr_uint32_t)); ++i)
> > + for (i = 0;
> > + i < sizeof(serf_failure_map) / (sizeof(serf_failure_map[0]));
> > + ++i)
> > {
> > if (failures & serf_failure_map[i][0])
> > {
>
> This one would've been better served by introducing a constant for the
> array size ...
>

I agree and was about to commit the patch. Then I greped
the code and found that we use this pattern quite frequently
(10s of places). There are also 6 local definitions for an
ARRAYLEN or ARRAY_LEN macro that nicely encapsulate
the sizeof() magic.

Given that people seem to like open arrays (spares the
invention of yet another constant), I suggest we introduce
SVN_ARRAY_LEN (or SVN__ARRAY_LEN) and use that
consistently.

-- Stefan^2.
Received on 2015-08-21 20:45:22 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.