Patchwork Fix potential uninitialized variable error

login
register
mail settings
Submitter Xinliang David Li
Date Aug. 14, 2013, 6:12 p.m.
Message ID <CAAkRFZKgm2nCNe-Kpq=5K8zKsU_FAtk5tLw+c-bP9e+o-c18aA@mail.gmail.com>
Download mbox | patch
Permalink /patch/267172/
State New
Headers show

Comments

Xinliang David Li - Aug. 14, 2013, 6:12 p.m.
I committed the following patch as obvious fix.
Marek Polacek - Aug. 14, 2013, 6:17 p.m.
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.
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.
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

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.