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

Re: svn commit: r1872108 - /subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c

From: Julian Foad <julianfoad_at_apache.org>
Date: Mon, 30 Dec 2019 14:41:50 +0000

Branko Čibej wrote:
>> - for (r = range->start + 1; r <= range->end; r++)
>> + for (r = (int)range->start + 1; r <= (int)range->end; r++)
>
> I really don't like this kind if papering over warnings with typecasts.
> Instead, change the type of 'r' to match the types of 'range->start' and
> 'range->end'.

Can do. In fact that was the first thing I did. I do agree in general
casts are the worst way. Then having changed the loop variable type
here, I looked at the other instances nearby where I use a revision
number to subscript this array:

rangelist_array_union(rl_array_t *ma, ...)
{
   int r;

   for (r = 0; r <= RANGELIST_TESTS_MAX_REV; r++) {
     ma->root[r] = ...
}

rangelist_array_equal(const rl_array_t *ba, ...)
{
   int r;

   for (r = 0; r <= RANGELIST_TESTS_MAX_REV; r++) {
     if (ba->root[r] ...
}

and thought then it looked marginally better to keep using 'int' in
those places (because they're low level operations on the array and
don't care whether the index represents a revision number), and better
to keep consistent than to just change the loop variable in one of the
three functions. But it makes at least as much sense to me the way you
suggest, so I'm happy to change it.

http://svn.apache.org/r1872115 .

- Julian
Received on 2019-12-30 15:41:52 CET

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.