[PATCH 2 of 2] reachableroots: silence warning of implicit integer narrowing issued by clang

Augie Fackler raf at durin42.com
Thu Aug 27 10:21:06 CDT 2015


On Thu, Aug 27, 2015 at 11:32:02PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1439522714 -32400
> #      Fri Aug 14 12:25:14 2015 +0900
> # Node ID d344ac47b3332921c24d0518ca3accb21adb3990
> # Parent  941c785d0bcc1891d4df6ecc991d851d146131dd
> reachableroots: silence warning of implicit integer narrowing issued by clang

Queued these, thanks.

>
> Tested with CFLAGS=-Wshorten-64-to-32 CC=clang which is the default of
> Mac OS X.
>
> Because a valid revnum shouldn't exceed INT_MAX, we don't need long width for
> large tovisit array.

mpm, please double-check this logic - I'm pretty sure this is all correct.

>
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -1187,7 +1187,7 @@ static PyObject *reachableroots2(indexOb
>                       goto bail;
>               }
>               if (!(revstates[revnum + 1] & RS_SEEN)) {
> -			tovisit[lentovisit++] = revnum;
> +			tovisit[lentovisit++] = (int)revnum;
>                       revstates[revnum + 1] |= RS_SEEN;
>               }
>       }
> @@ -1228,7 +1228,7 @@ static PyObject *reachableroots2(indexOb
>       /* Find all the nodes in between the roots we found and the heads
>        * and add them to the reachable set */
>       if (includepath == 1) {
> -		int minidx = minroot;
> +		long minidx = minroot;
>               if (minidx < 0)
>                       minidx = 0;
>               for (i = minidx; i < len; i++) {
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list