From: Mark Wielaard Date: Tue, 15 Sep 2015 08:55:10 +0000 (+0200) Subject: libdw: Don't reassign result pointer in dwarf_peel_type. X-Git-Tag: elfutils-0.164~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd8bd91f39c95947ad14cd43d30c17eb8c2827fc;p=thirdparty%2Felfutils.git libdw: Don't reassign result pointer in dwarf_peel_type. 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 --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 13beefc79..2e27ff96f 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2015-09-15 Mark Wielaard + + * dwarf_peel_type.c (dwarf_peel_type): Don't reassign result pointer. + 2015-09-09 Chih-Hung Hsieh * dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Remove diff --git a/libdw/dwarf_peel_type.c b/libdw/dwarf_peel_type.c index 9be838dd9..7b29d35a2 100644 --- a/libdw/dwarf_peel_type.c +++ b/libdw/dwarf_peel_type.c @@ -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);