diff mbox

Fix potential uninitialized variable error

Message ID CAAkRFZLOGXOJ-MmUtgDtSAZ-1mJjuXbZGWegRY7h_fQmvNBmJA@mail.gmail.com
State New
Headers show

Commit Message

Xinliang David Li Aug. 14, 2013, 8:50 p.m. UTC
Here is the clean up patch. Ok for trunk?

thanks,

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

Comments

Jakub Jelinek Aug. 14, 2013, 8:53 p.m. UTC | #1
On Wed, Aug 14, 2013 at 01:50:31PM -0700, Xinliang David Li wrote:
> Here is the clean up patch. Ok for trunk?

Ok.

> --- config/i386/i386.c  (revision 201735)
> +++ config/i386/i386.c  (working copy)
> @@ -2792,7 +2792,6 @@ static const char *stringop_alg_names[]
> 
>  struct stringop_size_range
>  {
> -  int min;
>    int max;
>    stringop_alg alg;
>    bool noalign;
> @@ -2815,7 +2814,7 @@ ix86_parse_stringop_strategy_string (cha
> 
>    do
>      {
> -      int mins = 0, maxs;
> +      int maxs;
>        stringop_alg alg;
>        char alg_name[128];
>        char align[16];
> @@ -2831,7 +2830,7 @@ ix86_parse_stringop_strategy_string (cha
>            return;
>          }
> 
> -      if (n > 0 && (maxs < (mins = input_ranges[n - 1].max + 1) && maxs != -1))
> +      if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1))
>          {
>            error ("size ranges of option %s should be increasing",
>                   is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy=");
> @@ -2855,7 +2854,6 @@ ix86_parse_stringop_strategy_string (cha
>            return;
>          }
> 
> -      input_ranges[n].min = mins;
>        input_ranges[n].max = maxs;
>        input_ranges[n].alg = alg;
>        if (!strcmp (align, "align"))

	Jakub
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 201735)
+++ config/i386/i386.c  (working copy)
@@ -2792,7 +2792,6 @@  static const char *stringop_alg_names[]

 struct stringop_size_range
 {
-  int min;
   int max;
   stringop_alg alg;
   bool noalign;
@@ -2815,7 +2814,7 @@  ix86_parse_stringop_strategy_string (cha

   do
     {
-      int mins = 0, maxs;
+      int maxs;
       stringop_alg alg;
       char alg_name[128];
       char align[16];
@@ -2831,7 +2830,7 @@  ix86_parse_stringop_strategy_string (cha
           return;
         }

-      if (n > 0 && (maxs < (mins = input_ranges[n - 1].max + 1) && maxs != -1))
+      if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1))
         {
           error ("size ranges of option %s should be increasing",
                  is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy=");
@@ -2855,7 +2854,6 @@  ix86_parse_stringop_strategy_string (cha
           return;
         }

-      input_ranges[n].min = mins;
       input_ranges[n].max = maxs;
       input_ranges[n].alg = alg;
       if (!strcmp (align, "align"))
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 201735)
+++ ChangeLog   (working copy)
@@ -1,6 +1,12 @@ 
 2013-08-14  Xinliang David Li  <davidxl@google.com>
+
+       * config/i386/i386.c (ix86_option_override_internal):
+       Remove unused variable and field.
+
+2013-08-14  Xinliang David Li  <davidxl@google.com>
+
        * config/i386/i386.c (ix86_option_override_internal):
-       Fix potential unitialized variable error.
+       Fix uninitialized variable error.

 2013-08-14  Xinliang David Li  <davidxl@google.com>