Fix compiler warnings

Trevor Saunders tbsaunde@tbsaunde.org
Wed May 6 14:47:00 GMT 2015


On Wed, May 06, 2015 at 01:47:38PM +0000, Aditya K wrote:
> I recently compiled gcc with clang and found few useful warnings (https://gcc.gnu.org/ml/gcc/2015-05/msg00015.html, https://gcc.gnu.org/ml/gcc/2015-05/msg00041.html).
> I have a patch to fix some of those, it passes bootstrap, please apply these if it is useful.

First some general comments:

You are fixing several unrelated issues, so you should be making one
commit per issue.  That way the people who know an area only need to
review changes to that area.

Its generally prefered you send patches inline instead of as attachments
(you can use git send-email to deal with a lot of administrivia for you)

The ChangeLog isn't correctly formated you can use contrib/mklog and
compare against the existing stuff in gcc/ChangeLog.

diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index fd27d7c..8261369 100644
--- 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;

This error is actually bogus because merge_usage() calls exit() so the
only actual path to return ret; involves setting ret.  That said I
personally think it would be a cleanup to rewrite the code like this.

while (...)
  {
    ...
  }

if (...)
  merge_usage ();

int ret = merge_profiles ();
...
return ret;

index ce4aca2..2b170e1 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))

I'll leave it to honza and marxin if this is what that code meant to do.

Trev



More information about the Gcc-patches mailing list