Patchwork [V3] parsers.c: avoid implicit conversion loses integer precision warnings

login
register
mail settings
Submitter André Sintzoff
Date Aug. 18, 2015, 6:52 p.m.
Message ID <ae1dbf8a309b47660abb.1439923958@zibeline.local>
Download mbox | patch
Permalink /patch/10231/
State Changes Requested
Headers show

Comments

André Sintzoff - Aug. 18, 2015, 6:52 p.m.
# HG changeset patch
# User André Sintzoff <andre.sintzoff@gmail.com>
# Date 1439902654 -7200
#      Tue Aug 18 14:57:34 2015 +0200
# Node ID ae1dbf8a309b47660abbce73b4a7351518ffe433
# Parent  9e7d805925c87cfa0ca30819e8273ac37fd77a62
parsers.c: avoid implicit conversion loses integer precision warnings

These warnings are raised by Apple LLVM version 6.1.0 (clang-602.0.53)
(based on LLVM 3.6.0svn) and were introduced in ff89383a97db
Jordi Gutiérrez Hermoso - Aug. 18, 2015, 7:05 p.m.
On Tue, 2015-08-18 at 20:52 +0200, André Sintzoff wrote:
> # HG changeset patch
> # User André Sintzoff <andre.sintzoff@gmail.com>
> # Date 1439902654 -7200
> #      Tue Aug 18 14:57:34 2015 +0200
> # Node ID ae1dbf8a309b47660abbce73b4a7351518ffe433
> # Parent  9e7d805925c87cfa0ca30819e8273ac37fd77a62
> parsers.c: avoid implicit conversion loses integer precision warnings
> 
> These warnings are raised by Apple LLVM version 6.1.0 (clang-602.0.53)
> (based on LLVM 3.6.0svn) and were introduced in ff89383a97db

I would still like to see the LLVM diagnostics. Can you please put
them in the commit message? It would help to understand what you're
trying to fix.

Yes, please make your commit message very verbose. There is no limit
on commit message length.
Yuya Nishihara - Aug. 19, 2015, 12:45 p.m.
On Tue, 18 Aug 2015 20:52:38 +0200, André Sintzoff wrote:
> # HG changeset patch
> # User André Sintzoff <andre.sintzoff@gmail.com>
> # Date 1439902654 -7200
> #      Tue Aug 18 14:57:34 2015 +0200
> # Node ID ae1dbf8a309b47660abbce73b4a7351518ffe433
> # Parent  9e7d805925c87cfa0ca30819e8273ac37fd77a62
> parsers.c: avoid implicit conversion loses integer precision warnings
> 
> These warnings are raised by Apple LLVM version 6.1.0 (clang-602.0.53)
> (based on LLVM 3.6.0svn) and were introduced in ff89383a97db
> 
> diff -r 9e7d805925c8 -r ae1dbf8a309b mercurial/parsers.c
> --- a/mercurial/parsers.c	Fri Aug 14 12:36:41 2015 +0900
> +++ b/mercurial/parsers.c	Tue Aug 18 14:57:34 2015 +0200
> @@ -1125,13 +1125,13 @@
>  	Py_ssize_t k;
>  	Py_ssize_t i;
>  	int r;
> -	int minidx;
> +	long minidx;
>  	int parents[2];
>  
>  	/* Internal data structure:
>  	 * tovisit: array of length len+1 (all revs + nullrev), filled upto lentovisit
>  	 * seen: array of length len+1 (all revs + nullrev) 0: not seen, 1 seen*/
> -	int *tovisit = NULL;
> +	long *tovisit = NULL;
>  	long lentovisit = 0;
>  	char *seen = NULL;
>  
> @@ -1151,7 +1151,7 @@
>  	}
>  
>  	/* Initialize internal datastructures */
> -	tovisit = (int *)malloc((len + 1) * sizeof(int));
> +	tovisit = (long *)malloc((len + 1) * sizeof(long));

This doubles the size of big tovisit array. tovisit can be an array of int
because it only keeps valid revisions.
Yuya Nishihara - Aug. 19, 2015, 12:48 p.m.
On Tue, 18 Aug 2015 15:05:23 -0400, Jordi Gutiérrez Hermoso wrote:
> On Tue, 2015-08-18 at 20:52 +0200, André Sintzoff wrote:
> > # HG changeset patch
> > # User André Sintzoff <andre.sintzoff@gmail.com>
> > # Date 1439902654 -7200
> > #      Tue Aug 18 14:57:34 2015 +0200
> > # Node ID ae1dbf8a309b47660abbce73b4a7351518ffe433
> > # Parent  9e7d805925c87cfa0ca30819e8273ac37fd77a62
> > parsers.c: avoid implicit conversion loses integer precision warnings
> > 
> > These warnings are raised by Apple LLVM version 6.1.0 (clang-602.0.53)
> > (based on LLVM 3.6.0svn) and were introduced in ff89383a97db
> 
> I would still like to see the LLVM diagnostics. Can you please put
> them in the commit message? It would help to understand what you're
> trying to fix.

  % make local CFLAGS='-Wshorten-64-to-32' CC=clang
  ...
  mercurial/parsers.c:1178:28: warning: implicit conversion loses integer
  precision: 'long' to 'int' [-Wshorten-64-to-32]
                          tovisit[lentovisit++] = revnum;
                                                ~ ^~~~~~
  mercurial/parsers.c:1218:12: warning: implicit conversion loses integer
  precision: 'long' to 'int' [-Wshorten-64-to-32]
                  minidx = minroot;
                         ~ ^~~~~~~
Augie Fackler - Aug. 21, 2015, 8:08 p.m.
On Tue, Aug 18, 2015 at 03:05:23PM -0400, Jordi Gutiérrez Hermoso wrote:
> On Tue, 2015-08-18 at 20:52 +0200, André Sintzoff wrote:
> > # HG changeset patch
> > # User André Sintzoff <andre.sintzoff@gmail.com>
> > # Date 1439902654 -7200
> > #      Tue Aug 18 14:57:34 2015 +0200
> > # Node ID ae1dbf8a309b47660abbce73b4a7351518ffe433
> > # Parent  9e7d805925c87cfa0ca30819e8273ac37fd77a62
> > parsers.c: avoid implicit conversion loses integer precision warnings
> >
> > These warnings are raised by Apple LLVM version 6.1.0 (clang-602.0.53)
> > (based on LLVM 3.6.0svn) and were introduced in ff89383a97db
>
> I would still like to see the LLVM diagnostics. Can you please put
> them in the commit message? It would help to understand what you're
> trying to fix.
>
> Yes, please make your commit message very verbose. There is no limit
> on commit message length.

I've mailed a similar patch that actually resolved all warnings for me
on OS X - could you both please take a look?

http://patchwork.serpentine.com/patch/10245/

>
>
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 9e7d805925c8 -r ae1dbf8a309b mercurial/parsers.c
--- a/mercurial/parsers.c	Fri Aug 14 12:36:41 2015 +0900
+++ b/mercurial/parsers.c	Tue Aug 18 14:57:34 2015 +0200
@@ -1125,13 +1125,13 @@ 
 	Py_ssize_t k;
 	Py_ssize_t i;
 	int r;
-	int minidx;
+	long minidx;
 	int parents[2];
 
 	/* Internal data structure:
 	 * tovisit: array of length len+1 (all revs + nullrev), filled upto lentovisit
 	 * seen: array of length len+1 (all revs + nullrev) 0: not seen, 1 seen*/
-	int *tovisit = NULL;
+	long *tovisit = NULL;
 	long lentovisit = 0;
 	char *seen = NULL;
 
@@ -1151,7 +1151,7 @@ 
 	}
 
 	/* Initialize internal datastructures */
-	tovisit = (int *)malloc((len + 1) * sizeof(int));
+	tovisit = (long *)malloc((len + 1) * sizeof(long));
 	if (tovisit == NULL) {
 		PyErr_NoMemory();
 		goto bail;