diff mbox

Fix potential uninitialized variable error

Message ID CAAkRFZKgm2nCNe-Kpq=5K8zKsU_FAtk5tLw+c-bP9e+o-c18aA@mail.gmail.com
State New
Headers show

Commit Message

Xinliang David Li Aug. 14, 2013, 6:12 p.m. UTC
I committed the following patch as obvious fix.

Comments

Marek Polacek Aug. 14, 2013, 6:17 p.m. UTC | #1
On Wed, Aug 14, 2013 at 11:12:27AM -0700, Xinliang David Li wrote:
> Index: ChangeLog
> ===================================================================
> --- ChangeLog   (revision 201732)
> +++ ChangeLog   (working copy)
> @@ -1,4 +1,8 @@
>  2013-08-14  Xinliang David Li  <davidxl@google.com>
> +       * config/i386/i386.c (ix86_option_override_internal):
> +       Fix potential unitialized variable error.

The CL entry is missing a blank line.

	Marek
Jakub Jelinek Aug. 14, 2013, 6:23 p.m. UTC | #2
On Wed, Aug 14, 2013 at 08:17:55PM +0200, Marek Polacek wrote:
> On Wed, Aug 14, 2013 at 11:12:27AM -0700, Xinliang David Li wrote:
> > Index: ChangeLog
> > ===================================================================
> > --- ChangeLog   (revision 201732)
> > +++ ChangeLog   (working copy)
> > @@ -1,4 +1,8 @@
> >  2013-08-14  Xinliang David Li  <davidxl@google.com>
> > +       * config/i386/i386.c (ix86_option_override_internal):
> > +       Fix potential unitialized variable error.
> 
> The CL entry is missing a blank line.

Also, the patch is not obvious.  The uninitialization is not potential, it
is unconditional for n == 0, but more importantly, nothing ever uses
input_ranges[...].min field, so it is clearly a write only field and thus
IMHO should be dropped altogether together with the mins variable.

	Jakub
Xinliang David Li Aug. 14, 2013, 6:53 p.m. UTC | #3
Ok. Will drop it in the next patch.

David

On Wed, Aug 14, 2013 at 11:23 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Aug 14, 2013 at 08:17:55PM +0200, Marek Polacek wrote:
>> On Wed, Aug 14, 2013 at 11:12:27AM -0700, Xinliang David Li wrote:
>> > Index: ChangeLog
>> > ===================================================================
>> > --- ChangeLog   (revision 201732)
>> > +++ ChangeLog   (working copy)
>> > @@ -1,4 +1,8 @@
>> >  2013-08-14  Xinliang David Li  <davidxl@google.com>
>> > +       * config/i386/i386.c (ix86_option_override_internal):
>> > +       Fix potential unitialized variable error.
>>
>> The CL entry is missing a blank line.
>
> Also, the patch is not obvious.  The uninitialization is not potential, it
> is unconditional for n == 0, but more importantly, nothing ever uses
> input_ranges[...].min field, so it is clearly a write only field and thus
> IMHO should be dropped altogether together with the mins variable.
>
>         Jakub
diff mbox

Patch

Index: ChangeLog
===================================================================
Index: config/i386/i386.c
===================================================================
davidxl@aples2:../tot/gcc\>> svn diff
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 201732)
+++ config/i386/i386.c  (working copy)
@@ -2815,7 +2815,7 @@  ix86_parse_stringop_strategy_string (cha

   do
     {
-      int mins, maxs;
+      int mins = 0, maxs;
       stringop_alg alg;
       char alg_name[128];
       char align[16];
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 201732)
+++ ChangeLog   (working copy)
@@ -1,4 +1,8 @@ 
 2013-08-14  Xinliang David Li  <davidxl@google.com>
+       * config/i386/i386.c (ix86_option_override_internal):
+       Fix potential unitialized variable error.
+
+2013-08-14  Xinliang David Li  <davidxl@google.com>

        * config/i386/i386.opt: Define two new options.
        * config/i386/x86-tune.def: Add arch selector field in macros.