Patchwork [2,of,2] parsers: use appropriate format to avoid unnecessary cast operations

login
register
mail settings
Submitter André Sintzoff
Date April 18, 2013, 6:33 p.m.
Message ID <66bd60964fc93c39177c.1366309996@amical.local>
Download mbox | patch
Permalink /patch/1431/
State Rejected, archived
Headers show

Comments

André Sintzoff - April 18, 2013, 6:33 p.m.
# HG changeset patch
# User André Sintzoff <andre.sintzoff@gmail.com>
# Date 1366309741 -7200
#      Jeu avr 18 20:29:01 2013 +0200
# Node ID 66bd60964fc93c39177cfbaa7ecc3222249c7527
# Parent  3a57c20af0527025bf5ffefd6f5dbd6e0b4fcd94
parsers: use appropriate format to avoid unnecessary cast operations
Matt Mackall - April 18, 2013, 6:58 p.m.
On Thu, 2013-04-18 at 20:33 +0200, André Sintzoff wrote:
> # HG changeset patch
> # User André Sintzoff <andre.sintzoff@gmail.com>
> # Date 1366309741 -7200
> #      Jeu avr 18 20:29:01 2013 +0200
> # Node ID 66bd60964fc93c39177cfbaa7ecc3222249c7527
> # Parent  3a57c20af0527025bf5ffefd6f5dbd6e0b4fcd94
> parsers: use appropriate format to avoid unnecessary cast operations

Any idea how compilers other than GCC will feel about this? We don't
have any "%z"s yet and we have users on machines from Windows to VMS.
André Sintzoff - April 18, 2013, 7:15 p.m.
2013/4/18 Matt Mackall <mpm@selenic.com>:
> On Thu, 2013-04-18 at 20:33 +0200, André Sintzoff wrote:
>> # HG changeset patch
>> # User André Sintzoff <andre.sintzoff@gmail.com>
>> # Date 1366309741 -7200
>> #      Jeu avr 18 20:29:01 2013 +0200
>> # Node ID 66bd60964fc93c39177cfbaa7ecc3222249c7527
>> # Parent  3a57c20af0527025bf5ffefd6f5dbd6e0b4fcd94
>> parsers: use appropriate format to avoid unnecessary cast operations
>
> Any idea how compilers other than GCC will feel about this? We don't
> have any "%z"s yet and we have users on machines from Windows to VMS.

It seems that even version 2012 of M$ Visual Studio does not support "%z".
http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx

So let's drop these patches.

Which version(s) of C do we need to support? Only C89?

André
Matt Mackall - April 18, 2013, 8:34 p.m.
On Thu, 2013-04-18 at 21:15 +0200, André Sintzoff wrote:
> 2013/4/18 Matt Mackall <mpm@selenic.com>:
> > On Thu, 2013-04-18 at 20:33 +0200, André Sintzoff wrote:
> >> # HG changeset patch
> >> # User André Sintzoff <andre.sintzoff@gmail.com>
> >> # Date 1366309741 -7200
> >> #      Jeu avr 18 20:29:01 2013 +0200
> >> # Node ID 66bd60964fc93c39177cfbaa7ecc3222249c7527
> >> # Parent  3a57c20af0527025bf5ffefd6f5dbd6e0b4fcd94
> >> parsers: use appropriate format to avoid unnecessary cast operations
> >
> > Any idea how compilers other than GCC will feel about this? We don't
> > have any "%z"s yet and we have users on machines from Windows to VMS.
> 
> It seems that even version 2012 of M$ Visual Studio does not support "%z".
> http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
> 
> So let's drop these patches.
> 
> Which version(s) of C do we need to support? Only C89?

Using post-C89 features is asking for trouble. Though we probably can't
avoid using a 'long long' of some sort.

Python has some header file support for masking some of these issues, I
think.
Matt Mackall - April 18, 2013, 8:46 p.m.
On Thu, 2013-04-18 at 15:36 -0500, Kevin Bullock wrote:
> On 18 Apr 2013, at 3:34 PM, Matt Mackall wrote:
> 
> > Using post-C89 features is asking for trouble. Though we probably can't
> > avoid using a 'long long' of some sort.
> > 
> > Python has some header file support for masking some of these issues, I
> > think.
> 
> Most of the warnings we get with -Wall -pedantic -c89 are uses of 'long long' in <Python.h>.

Yeah, Python knows which compilers support long long and uses it where
it can.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -353,8 +353,8 @@ 
 
 	pos = p - PyString_AS_STRING(packobj);
 	if (pos != nbytes) {
-		PyErr_Format(PyExc_SystemError, "bad dirstate size: %ld != %ld",
-                             (long)pos, (long)nbytes);
+		PyErr_Format(PyExc_SystemError, "bad dirstate size: %zd != %zd",
+                             pos, nbytes);
 		goto bail;
 	}