Skip to content
Snippets Groups Projects
Commit 249cc4ec authored by kiilerix's avatar kiilerix
Browse files

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().
parent 8299a9ad
No related branches found
No related tags found
No related merge requests found
......@@ -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. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment