Patchwork parsers.c: avoid implicit conversion loses integer warnings

login
register
mail settings
Submitter André Sintzoff
Date March 29, 2015, 6:25 p.m.
Message ID <3c0b34de39029c48dd41.1427653531@zibeline.local>
Download mbox | patch
Permalink /patch/8353/
State Accepted
Headers show

Comments

André Sintzoff - March 29, 2015, 6:25 p.m.
# HG changeset patch
# User André Sintzoff <andre.sintzoff@gmail.com>
# Date 1427648783 -7200
#      Sun Mar 29 19:06:23 2015 +0200
# Node ID 3c0b34de39029c48dd41f31fc111baf91fb8b935
# Parent  efa094701a05d58d505c3b0c3b3c73dba4e51e97
parsers.c: avoid implicit conversion loses integer warnings

These warnings are raised by Apple LLVM version 6.0 (clang-600.0.57)
(based on LLVM 3.5svn) and were introduced in 539b3c7eea44
Augie Fackler - March 30, 2015, 2:34 p.m.
On Sun, Mar 29, 2015 at 08:25:31PM +0200, André Sintzoff wrote:
> # HG changeset patch
> # User André Sintzoff <andre.sintzoff@gmail.com>
> # Date 1427648783 -7200
> #      Sun Mar 29 19:06:23 2015 +0200
> # Node ID 3c0b34de39029c48dd41f31fc111baf91fb8b935
> # Parent  efa094701a05d58d505c3b0c3b3c73dba4e51e97
> parsers.c: avoid implicit conversion loses integer warnings

Queued this, thanks.

(I'll make sure to double-check that the build still works on 2.4, sigh.)

>
> These warnings are raised by Apple LLVM version 6.0 (clang-600.0.57)
> (based on LLVM 3.5svn) and were introduced in 539b3c7eea44
>
> diff -r efa094701a05 -r 3c0b34de3902 mercurial/parsers.c
> --- a/mercurial/parsers.c	Fri Mar 27 14:11:13 2015 -0700
> +++ b/mercurial/parsers.c	Sun Mar 29 19:06:23 2015 +0200
> @@ -912,7 +912,7 @@
>  }
>
>  static Py_ssize_t add_roots_get_min(indexObject *self, PyObject *list,
> -                                    int marker, char *phases)
> +                                    Py_ssize_t marker, char *phases)
>  {
>       PyObject *iter = NULL;
>       PyObject *iter_item = NULL;
> @@ -938,7 +938,7 @@
>  }
>
>  static inline void set_phase_from_parents(char *phases, int parent_1,
> -                                          int parent_2, int i)
> +                                          int parent_2, Py_ssize_t i)
>  {
>       if (parent_1 >= 0 && phases[parent_1] > phases[i])
>               phases[i] = phases[parent_1];
> @@ -960,7 +960,7 @@
>       Py_ssize_t minrevallphases = 0;
>       Py_ssize_t minrevphase = 0;
>       Py_ssize_t i = 0;
> -	long parent_1, parent_2;
> +	int parent_1, parent_2;
>       char *phases = NULL;
>       const char *data;
>
> @@ -998,8 +998,8 @@
>                               PyErr_SetString(PyExc_TypeError, "revlog parents are invalid");
>                               goto release_phases;
>                       }
> -			parent_1 = PyInt_AS_LONG(p1);
> -			parent_2 = PyInt_AS_LONG(p2);
> +			parent_1 = (int)PyInt_AS_LONG(p1);
> +			parent_2 = (int)PyInt_AS_LONG(p2);
>                       set_phase_from_parents(phases, parent_1, parent_2, i+self->raw_length);
>               }
>       }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r efa094701a05 -r 3c0b34de3902 mercurial/parsers.c
--- a/mercurial/parsers.c	Fri Mar 27 14:11:13 2015 -0700
+++ b/mercurial/parsers.c	Sun Mar 29 19:06:23 2015 +0200
@@ -912,7 +912,7 @@ 
 }
 
 static Py_ssize_t add_roots_get_min(indexObject *self, PyObject *list,
-                                    int marker, char *phases)
+                                    Py_ssize_t marker, char *phases)
 {
 	PyObject *iter = NULL;
 	PyObject *iter_item = NULL;
@@ -938,7 +938,7 @@ 
 }
 
 static inline void set_phase_from_parents(char *phases, int parent_1,
-                                          int parent_2, int i)
+                                          int parent_2, Py_ssize_t i)
 {
 	if (parent_1 >= 0 && phases[parent_1] > phases[i])
 		phases[i] = phases[parent_1];
@@ -960,7 +960,7 @@ 
 	Py_ssize_t minrevallphases = 0;
 	Py_ssize_t minrevphase = 0;
 	Py_ssize_t i = 0;
-	long parent_1, parent_2;
+	int parent_1, parent_2;
 	char *phases = NULL;
 	const char *data;
 
@@ -998,8 +998,8 @@ 
 				PyErr_SetString(PyExc_TypeError, "revlog parents are invalid");
 				goto release_phases;
 			}
-			parent_1 = PyInt_AS_LONG(p1);
-			parent_2 = PyInt_AS_LONG(p2);
+			parent_1 = (int)PyInt_AS_LONG(p1);
+			parent_2 = (int)PyInt_AS_LONG(p2);
 			set_phase_from_parents(phases, parent_1, parent_2, i+self->raw_length);
 		}
 	}