[PATCH 3 of 4] mpatch: silence warning about maybe-uninitialized variable

Yuya Nishihara yuya at tcha.org
Sun Aug 7 08:09:57 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1470530827 -32400
#      Sun Aug 07 09:47:07 2016 +0900
# Node ID 888e432366ac66145869421a67732e33b70a80c9
# Parent  ab6faafa65302e34a080f41838012f241fd3c6e8
mpatch: silence warning about maybe-uninitialized variable

It's false positive, but it wouldn't be possible for gcc to know
PyBytes_FromStringAndSize() sets PyErr_Occurred().

  mercurial/mpatch_module.c:105:47: warning: 'r' may be used uninitialized
  in this function [-Wmaybe-uninitialized]
     PyErr_SetString(mpatch_Error, mpatch_errors[-r]);

diff --git a/mercurial/mpatch_module.c b/mercurial/mpatch_module.c
--- a/mercurial/mpatch_module.c
+++ b/mercurial/mpatch_module.c
@@ -59,7 +59,7 @@ patches(PyObject *self, PyObject *args)
 	PyObject *text, *bins, *result;
 	struct mpatch_flist *patch;
 	const char *in;
-	int r;
+	int r = 0;
 	char *out;
 	Py_ssize_t len, outlen, inlen;
 


More information about the Mercurial-devel mailing list