parsers.c: remove warning: 'size' may be used uninitialized in this function
authorMads Kiilerich <mads@kiilerich.com>
Fri, 06 Jul 2012 00:48:45 +0200
changeset 17165 249cc4ec4327
parent 17164 8299a9ad48dd
child 17166 c1a3b151782a
parsers.c: remove warning: 'size' may be used uninitialized in this function Some compilers / compiler options (such as gcc 4.7) would emit warnings: mercurial/parsers.c: In function 'pack_dirstate': mercurial/parsers.c:306:18: warning: 'size' may be used uninitialized in this function [-Wmaybe-uninitialized] mercurial/parsers.c:306:12: warning: 'mode' may be used uninitialized in this function [-Wmaybe-uninitialized] It is apparently not smart enough to figure out how the 'err' arithmetics makes sure that it can't happen. 'err' is now replaced with simple checks and goto. That might also help the optimizer when it is inlining getintat().
mercurial/parsers.c
--- a/mercurial/parsers.c	Wed Jul 11 16:47:33 2012 +0200
+++ b/mercurial/parsers.c	Fri Jul 06 00:48:45 2012 +0200
@@ -307,7 +307,6 @@
 		Py_ssize_t len, l;
 		PyObject *o;
 		char *s, *t;
-		int err;
 
 		if (!PyTuple_Check(v) || PyTuple_GET_SIZE(v) != 4) {
 			PyErr_SetString(PyExc_TypeError, "expected a 4-tuple");
@@ -319,10 +318,11 @@
 			goto bail;
 		}
 		*p++ = *s;
-		err = getintat(v, 1, &mode);
-		err |= getintat(v, 2, &size);
-		err |= getintat(v, 3, &mtime);
-		if (err)
+		if (getintat(v, 1, &mode) == -1)
+			goto bail;
+		if (getintat(v, 2, &size) == -1)
+			goto bail;
+		if (getintat(v, 3, &mtime) == -1)
 			goto bail;
 		if (*s == 'n' && mtime == (uint32_t)now) {
 			/* See dirstate.py:write for why we do this. */