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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 7, 2016, 12:09 p.m.
Message ID <888e432366ac66145869.1470571797@mimosa>
Download mbox | patch
Permalink /patch/16172/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 7, 2016, 12:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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]);
Pierre-Yves David - Aug. 8, 2016, 12:54 a.m.
On 08/07/2016 02:09 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

I've pushed the first 3.  I would like someone who know the details a 
bit more to have a look at patch 4.

Cheers,
Jun Wu - Aug. 8, 2016, 11:36 p.m.
Patch 4 looks good to me. I will change its state to Pre-Reviewed manually.

Excerpts from Pierre-Yves David's message of 2016-08-08 02:54:56 +0200:
> On 08/07/2016 02:09 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@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
> 
> I've pushed the first 3.  I would like someone who know the details a 
> bit more to have a look at patch 4.
> 
> Cheers,
>

Patch

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;