git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] Initialize variables with values

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
May 9, 2013, 12:40 UTC
Message-ID
<20130509124022.GA8685@shrek.podlesie.net>
In-Reply-To
<518AF843.6040501@cs-ware.de>
On Thu, May 09, 2013 at 03:13:39AM +0200, Sven Strickroth wrote:
Show 21 quoted lines
> With MSVC initializing a variable with "int a=a" causes a warning about
> using an uninitialized value.
> 
> Signed-off-by: Sven Strickroth <email@cs-ware.de>
> ---
>  builtin/rev-list.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> index 67701be..13afacd 100644
> --- a/builtin/rev-list.c
> +++ b/builtin/rev-list.c
> @@ -338,7 +338,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
>  		mark_edges_uninteresting(revs.commits, &revs, show_edge);
>  
>  	if (bisect_list) {
> -		int reaches = reaches, all = all;
> +		int reaches = 0, all = 0;
>  
>  		revs.commits = find_bisection(revs.commits, &reaches, &all,
>  					      bisect_find_all);
But this generates worse code, at least using gcc 4.7.2:

--- old 2013-05-09 14:33:22.000000000 +0200 +++ new 2013-05-09 14:33:02.000000000 +0200

@@ -1,2 +1,2 @@
    text	   data	    bss	    dec	    hex	filename
-   4283	      0	      0	   4283	   10bb	builtin/rev-list.o
+   4299	      0	      0	   4299	   10cb	builtin/rev-list.o

Krzysiek
Previous: Sven StrickrothNext: Jonathan Nieder
Message 6 of 9 in “MSVC fixes”
  1. 0/3 MSVC fixesSven Strickroth, May 9, 2013
  2. 1/3 poll.h lies in the same folder, so use normal quotes for includeSven Strickroth, May 9, 2013
  3. Sven StrickrothMay 9, 2013
  4. 2/3 mingw.h: Define only if necessarySven Strickroth, May 9, 2013
  5. 3/3 Initialize variables with valuesSven Strickroth, May 9, 2013
  6. Krzysztof MazurMay 9, 2013
  7. Jonathan NiederMay 9, 2013
  8. Sven StrickrothMay 9, 2013
  9. René ScharfeMay 9, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.