Fix compiler warnings

Aditya K hiraditya@msn.com
Wed May 6 16:37:00 GMT 2015


Thanks! Updated patch.


2015-05-06  Aditya Kumar  <hiraditya@msn.com>

        * gcov-tool.c (do_merge): Refactored to remove int ret.
        * ipa-icf.c (sem_item::hash_referenced_symbol_properties): Changed (!type == FUNC) to (type != FUNC).
        * reload.h (struct target_reload): Changed to type of x_spill_indirect_levels from bool to unsigned char.


diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index fd27d7c..b2a4583 100644
--- a/gcc/gcov-tool.c
+++ b/gcc/gcov-tool.c
@@ -193,7 +193,6 @@ static int
 do_merge (int argc, char **argv)
 {
   int opt;
-  int ret;
   const char *output_dir = 0;
   int w1 = 1, w2 = 1;
 
@@ -222,12 +221,10 @@ do_merge (int argc, char **argv)
   if (output_dir == NULL)
     output_dir = "merged_profile";
 
-  if (argc - optind == 2)
-    ret = profile_merge (argv[optind], argv[optind+1], output_dir, w1, w2);
-  else
+  if (argc - optind != 2)
     merge_usage ();
 
-  return ret;
+  return profile_merge (argv[optind], argv[optind+1], output_dir, w1, w2);
 }
 
 /* If N_VAL is no-zero, normalize the profile by setting the largest counter
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 1fbdf6d..3c4ac05 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -505,7 +505,7 @@ sem_item::hash_referenced_symbol_properties (symtab_node *ref,
 {
   if (is_a <cgraph_node *> (ref))
     {
-      if ((!type == FUNC || address || !opt_for_fn (decl, optimize_size))
+      if ((type != FUNC || address || !opt_for_fn (decl, optimize_size))
          && !opt_for_fn (ref->decl, optimize_size)
          && !DECL_UNINLINABLE (ref->decl))
        {
diff --git a/gcc/reload.h b/gcc/reload.h
index a58b902..fb4a547 100644
--- a/gcc/reload.h
+++ b/gcc/reload.h
@@ -168,7 +168,7 @@ struct target_reload {
      value indicates the level of indirect addressing supported, e.g., two
      means that (MEM (MEM (REG n))) is also valid if (REG n) does not get
      a hard register.  */
-  bool x_spill_indirect_levels;
+  unsigned char x_spill_indirect_levels;
 
   /* True if caller-save has been reinitialized.  */
   bool x_caller_save_initialized_p;



> Date: Wed, 6 May 2015 18:26:10 +0200
> From: jakub@redhat.com
> To: hiraditya@msn.com
> CC: rdsandiford@googlemail.com; polacek@redhat.com; gcc-patches@gcc.gnu.org
> Subject: Re: Fix compiler warnings
> 
> On Wed, May 06, 2015 at 04:22:13PM +0000, Aditya K wrote:
>> Thanks Richard, Jakub and Trevor for the feedback. I have reformatted the changelog, and modified the patch addressing your comments.
>> 
>> -Aditya
>> 
>> 
>> 2015-05-06  Aditya Kumar  <hiraditya@msn.com>
>> 
>>         * gcov-tool.c (do_merge):
>>         * ipa-icf.c (sem_item::hash_referenced_symbol_properties):
>>         * reload.h (struct target_reload):
> 
> After the : you need to say what has changed.
> 
>> --- a/gcc/gcov-tool.c
>> +++ b/gcc/gcov-tool.c
>> @@ -193,7 +193,7 @@ static int
>>  do_merge (int argc, char **argv)
>>  {
>>    int opt;
>> -  int ret;
>> +  int ret = 0;
> 
> Initializing ret makes no sense then.
> 
>>    const char *output_dir = 0;
>>    int w1 = 1, w2 = 1;
>>  
>> @@ -222,11 +222,11 @@ do_merge (int argc, char **argv)
>>    if (output_dir == NULL)
>>      output_dir = "merged_profile";
>>  
>> -  if (argc - optind == 2)
>> -    ret = profile_merge (argv[optind], argv[optind+1], output_dir, w1, w2);
>> -  else
>> +  if (argc - optind != 2)
>>      merge_usage ();
>>  
>> +  ret = profile_merge (argv[optind], argv[optind+1], output_dir, w1, w2);
>> +
>>    return ret;
> 
> Perhaps better would be just
>   return profile_merge (argv[optind], argv[optind+1], output_dir, w1, w2);
> and remove ret.
> 
>> --- a/gcc/reload.h
>> +++ b/gcc/reload.h
>> @@ -168,7 +168,7 @@ struct target_reload {
>>       value indicates the level of indirect addressing supported, e.g., two
>>       means that (MEM (MEM (REG n))) is also valid if (REG n) does not get
>>       a hard register.  */
>> -  bool x_spill_indirect_levels;
>> +  signed char x_spill_indirect_levels;
> 
> As negative values make no sense, this is better unsigned char than signed.
> 
> 	Jakub
 		 	   		  


More information about the Gcc-patches mailing list