Patchwork parsers: fix uninitialize variable warning

login
register
mail settings
Submitter David Soria Parra
Date Sept. 24, 2014, 8:20 p.m.
Message ID <2ac6c99d87db382c8757.1411590048@davidsp-mbp.local>
Download mbox | patch
Permalink /patch/5967/
State Accepted
Headers show

Comments

David Soria Parra - Sept. 24, 2014, 8:20 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1411589780 25200
#      Wed Sep 24 13:16:20 2014 -0700
# Node ID 2ac6c99d87db382c8757063f15baa235881a38dd
# Parent  12c0a6a7307c938daa8fcfe330a5b35a389c79be
parsers: fix uninitialize variable warning

The heads pointer is not initialized correctly if filter is false, causing
both clang and gcc to issue a warning. Correctly initialize heads to NULL.
Pierre-Yves David - Sept. 25, 2014, 2:54 a.m.
On 09/24/2014 01:20 PM, David Soria Parra wrote:
> # HG changeset patch
> # User David Soria Parra <davidsp@fb.com>
> # Date 1411589780 25200
> #      Wed Sep 24 13:16:20 2014 -0700
> # Node ID 2ac6c99d87db382c8757063f15baa235881a38dd
> # Parent  12c0a6a7307c938daa8fcfe330a5b35a389c79be
> parsers: fix uninitialize variable warning

Looks right, and tests suite are passing. Pushed to the clowncopter.

> The heads pointer is not initialized correctly if filter is false, causing
> both clang and gcc to issue a warning. Correctly initialize heads to NULL.
>
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -854,7 +854,7 @@
>   {
>   	Py_ssize_t i, len, addlen;
>   	char *nothead = NULL;
> -	PyObject *heads;
> +	PyObject *heads = NULL;
>   	PyObject *filter = NULL;
>   	PyObject *filteredrevs = Py_None;

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -854,7 +854,7 @@ 
 {
 	Py_ssize_t i, len, addlen;
 	char *nothead = NULL;
-	PyObject *heads;
+	PyObject *heads = NULL;
 	PyObject *filter = NULL;
 	PyObject *filteredrevs = Py_None;