]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Don't reassign result pointer in dwarf_peel_type.
authorMark Wielaard <mjw@redhat.com>
Tue, 15 Sep 2015 08:55:10 +0000 (10:55 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 15 Sep 2015 09:00:50 +0000 (11:00 +0200)
GCC6 will warn about the reassignement of the nonnull result pointer.
The reassignment is indeed a little questionable. The compiler cannot
see that the pointer will not actually be reassigned since the function
will just return the same pointer value except when the dwarf_formref_die
function fails. In which case we don't use the result anymore. So the
compiler has to pessimistically assume the pointer will need to be
reloaded in the loop every time. Help the compiler generate slightly
better code by just checking whether the function fails directly instead
of reusing the pointer value for this.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_peel_type.c

index 13beefc79d058bba606bf71ed039dd876c1dbcc3..2e27ff96fef0113fdf963ac97e3f34933666dd5d 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-15  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_peel_type.c (dwarf_peel_type): Don't reassign result pointer.
+
 2015-09-09  Chih-Hung Hsieh  <chh@google.com>
 
        * dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Remove
index 9be838dd9cea4cbf4e82fc4533756c1bb99bb1e3..7b29d35a2e8c9eebacb5d8c3559f51a8f600c2b5 100644 (file)
@@ -1,5 +1,5 @@
 /* Peel type aliases and qualifier tags from a type DIE.
-   Copyright (C) 2014 Red Hat, Inc.
+   Copyright (C) 2014, 2015 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -60,8 +60,7 @@ dwarf_peel_type (die, result)
       if (attr == NULL)
        return 1;
 
-      result = INTUSE (dwarf_formref_die) (attr, result);
-      if (result == NULL)
+      if (INTUSE (dwarf_formref_die) (attr, result) == NULL)
        return -1;
 
       tag = INTUSE (dwarf_tag) (result);