Patchwork [1,of,2] parsers: correct type of temporary variables for dirstate tuple fields

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

Comments

Yuya Nishihara - Oct. 18, 2015, 7:39 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1445091253 -32400
#      Sat Oct 17 23:14:13 2015 +0900
# Node ID 4f0d9c665de23497bc54055d6cdeae914ac2b351
# Parent  50fc80e46786301bcf775649ef8f6d121f62fa5c
parsers: correct type of temporary variables for dirstate tuple fields

These fields are defined as int. This eliminates the following warning
spotted by CC=clang CFLAGS='-Wall -Wextra -Wno-missing-field-initializers
-Wno-unused-parameter -Wshorten-64-to-32':

  mercurial/parsers.c:625:29: warning: comparison of integers of different
  signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Wsign-compare]
                  if (state == 'n' && mtime == now) {

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -606,7 +606,7 @@  static PyObject *pack_dirstate(PyObject 
 	for (pos = 0; PyDict_Next(map, &pos, &k, &v); ) {
 		dirstateTupleObject *tuple;
 		char state;
-		uint32_t mode, size, mtime;
+		int mode, size, mtime;
 		Py_ssize_t len, l;
 		PyObject *o;
 		char *t;
@@ -636,9 +636,9 @@  static PyObject *pack_dirstate(PyObject 
 			mtime_unset = NULL;
 		}
 		*p++ = state;
-		putbe32(mode, p);
-		putbe32(size, p + 4);
-		putbe32(mtime, p + 8);
+		putbe32((uint32_t)mode, p);
+		putbe32((uint32_t)size, p + 4);
+		putbe32((uint32_t)mtime, p + 8);
 		t = p + 12;
 		p += 16;
 		len = PyString_GET_SIZE(k);