Patchwork [3,of,4,warning-cleanup] parsers: avoid int/unsigned conversions

login
register
mail settings
Submitter Augie Fackler
Date Aug. 21, 2015, 6:36 p.m.
Message ID <c94fce4d889c4f83b6d6.1440182171@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/10248/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 21, 2015, 6:36 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1440182031 14400
#      Fri Aug 21 14:33:51 2015 -0400
# Node ID c94fce4d889c4f83b6d62bd8a2d4550aa0fb91f0
# Parent  f9f6192f329048b537dc2dc2af18f98479fe4388
parsers: avoid int/unsigned conversions

Detected with
make local CFLAGS='-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter' CC=clang
Yuya Nishihara - Aug. 22, 2015, 11:32 a.m.
On Fri, 21 Aug 2015 14:36:11 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1440182031 14400
> #      Fri Aug 21 14:33:51 2015 -0400
> # Node ID c94fce4d889c4f83b6d62bd8a2d4550aa0fb91f0
> # Parent  f9f6192f329048b537dc2dc2af18f98479fe4388
> parsers: avoid int/unsigned conversions
> 
> Detected with
> make local CFLAGS='-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter' CC=clang
> 
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -705,8 +705,8 @@ typedef struct {
>  	PyObject *headrevs;    /* cache, invalidated on changes */
>  	PyObject *filteredrevs;/* filtered revs set */
>  	nodetree *nt;          /* base-16 trie */
> -	int ntlength;          /* # nodes in use */
> -	int ntcapacity;        /* # nodes allocated */
> +	unsigned ntlength;          /* # nodes in use */
> +	unsigned ntcapacity;        /* # nodes allocated */
>  	int ntdepth;           /* maximum depth of tree */
>  	int ntsplits;          /* # splits performed */
>  	int ntrev;             /* last rev scanned */

It seems odd to me because all other sizes in indexObject are signed.
But, it's just a matter of taste.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -705,8 +705,8 @@  typedef struct {
 	PyObject *headrevs;    /* cache, invalidated on changes */
 	PyObject *filteredrevs;/* filtered revs set */
 	nodetree *nt;          /* base-16 trie */
-	int ntlength;          /* # nodes in use */
-	int ntcapacity;        /* # nodes allocated */
+	unsigned ntlength;          /* # nodes in use */
+	unsigned ntcapacity;        /* # nodes allocated */
 	int ntdepth;           /* maximum depth of tree */
 	int ntsplits;          /* # splits performed */
 	int ntrev;             /* last rev scanned */