Patchwork [2,of,2] parsers: suppress warning of signed and unsigned comparison at nt_init

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 18, 2015, 7:39 a.m.
Message ID <23dfdae0b60241f45302.1445153952@mimosa>
Download mbox | patch
Permalink /patch/11173/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 18, 2015, 7:39 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1445126704 -32400
#      Sun Oct 18 09:05:04 2015 +0900
# Node ID 23dfdae0b60241f453027c6a404e510433567858
# Parent  4f0d9c665de23497bc54055d6cdeae914ac2b351
parsers: suppress warning of signed and unsigned comparison at nt_init

Spotted by CC=clang CFLAGS='-Wall -Wextra -Wno-missing-field-initializers
-Wno-unused-parameter -Wshorten-64-to-32':

  mercurial/parsers.c:1580:24: warning: comparison of integers of different
  signs: 'Py_ssize_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
                  if (self->raw_length > INT_MAX / sizeof(nodetree)) {
Matt Mackall - Oct. 18, 2015, 11:13 p.m.
On Sun, 2015-10-18 at 16:39 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1445126704 -32400
> #      Sun Oct 18 09:05:04 2015 +0900
> # Node ID 23dfdae0b60241f453027c6a404e510433567858
> # Parent  4f0d9c665de23497bc54055d6cdeae914ac2b351
> parsers: suppress warning of signed and unsigned comparison at
> nt_init

These are queued for default, thanks. I think this one in particular
could be tidied up to use more sensible types in its internal non-
Python-facing structures.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1577,7 +1577,7 @@  static int nt_insert(indexObject *self, 
 static int nt_init(indexObject *self)
 {
 	if (self->nt == NULL) {
-		if (self->raw_length > INT_MAX / sizeof(nodetree)) {
+		if ((size_t)self->raw_length > INT_MAX / sizeof(nodetree)) {
 			PyErr_SetString(PyExc_ValueError, "overflow in nt_init");
 			return -1;
 		}