# HG changeset patch # User Mads Kiilerich # Date 2012-07-05 22:48:45 # Node ID 249cc4ec4327829ac1b14d7a64c550a966eb3014 # Parent 8299a9ad48dd46ca7ce5a405f06fa2dd16f1b236 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(). diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -307,7 +307,6 @@ static PyObject *pack_dirstate(PyObject 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 @@ static PyObject *pack_dirstate(PyObject 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. */