On Wed, Aug 19, 2015 at 6:57 PM, Branko Čibej <[email protected]> wrote:
> On 19.08.2015 18:26, [email protected] 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.

