diff mbox series

[dump] small source cleanup

Message ID 168d1fe1-57f1-6de2-d2e2-b93e93a68619@acm.org
State New
Headers show
Series [dump] small source cleanup | expand

Commit Message

Nathan Sidwell Oct. 24, 2019, 4:01 p.m. UTC
due to my own stupidity I found myself wandering into dump_begin, but 
then got confused due to an uninitialized pointer not pointing to 
somewhere totally insane.

Applying this cleanup patch to initialize the decls at creation time.

nathan
diff mbox series

Patch

2019-10-24  Nathan Sidwell  <nathan@acm.org>

	* dumpfile.c (dump_begin): Reorder decls to use RAII.

Index: gcc/dumpfile.c
===================================================================
--- gcc/dumpfile.c	(revision 277405)
+++ gcc/dumpfile.c	(working copy)
@@ -1533,19 +1533,15 @@  gcc::dump_manager::
 dump_begin (int phase, dump_flags_t *flag_ptr, int part)
 {
-  char *name;
-  struct dump_file_info *dfi;
-  FILE *stream;
-
   if (phase == TDI_none || !dump_phase_enabled_p (phase))
     return NULL;
 
-  name = get_dump_file_name (phase, part);
+  char *name = get_dump_file_name (phase, part);
   if (!name)
     return NULL;
-  dfi = get_dump_file_info (phase);
+  struct dump_file_info *dfi = get_dump_file_info (phase);
 
   /* We do not support re-opening of dump files with parts.  This would require
      tracking pstate per part of the dump file.  */
-  stream = dump_open (name, part != -1 || dfi->pstate < 0);
+  FILE *stream = dump_open (name, part != -1 || dfi->pstate < 0);
   if (stream)
     dfi->pstate = 1;