Patchwork Go patch committed: Always initialize nested_off

login
register
mail settings
Submitter Ian Taylor
Date Feb. 5, 2013, 1:12 a.m.
Message ID <mcrsj5ba7ii.fsf@google.com>
Download mbox | patch
Permalink /patch/218130/
State New
Headers show

Comments

Ian Taylor - Feb. 5, 2013, 1:12 a.m.
In PR 56198 Jakub points out that Import_archive::interpret_header did
not always initialized nested_off.  This could never be an actual
problem, as nested_off was always set when an archive member might be
used.  But it caused a compilation warning.  Fixed with this patch.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 2c7569fc43a1 go/import-archive.cc
--- a/go/import-archive.cc	Sat Feb 02 07:38:09 2013 -0800
+++ b/go/import-archive.cc	Mon Feb 04 17:06:37 2013 -0800
@@ -277,6 +277,7 @@ 
       return false;
     }
 
+  *nested_off = 0;
   if (hdr->ar_name[0] != '/')
     {
       const char* name_end = strchr(hdr->ar_name, '/');
@@ -288,7 +289,6 @@ 
 	  return false;
 	}
       pname->assign(hdr->ar_name, name_end - hdr->ar_name);
-      *nested_off = 0;
     }
   else if (hdr->ar_name[1] == ' ')
     {
@@ -327,8 +327,7 @@ 
 	  return false;
 	}
       pname->assign(name, name_end - 1 - name);
-      if (nested_off != NULL)
-        *nested_off = y;
+      *nested_off = y;
     }
 
   return true;