diff mbox series

abg-ir.cc: Fix peel_typedef_type(const type_base*).

Message ID 20200319111315.162790-1-gprocida@google.com
State Committed
Headers show
Series abg-ir.cc: Fix peel_typedef_type(const type_base*). | expand

Commit Message

Giuliano Procida March 19, 2020, 11:13 a.m. UTC
The various peel_*_type functions are supposed to return either an
underlying type (when something can be "peeled") or the original
type (when not).

This overload of peel_typedef_type currently returns null if the type
isn't a typedef. This patch corrects this.

The bug hasn't bitten as all existing calls are protected by an
is_typedef check. Note that the recursive calls within the function
are to the other (const type_base_sptr&) overload.

	* src/abg-ir.cc (peel_typedef_type): In the const type_base*
        overload, return the original argument rather than null if the
        type isn't actually a typedef.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-ir.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthias Maennich March 19, 2020, 12:50 p.m. UTC | #1
On Thu, Mar 19, 2020 at 11:13:14AM +0000, Android Kernel Team wrote:
>The various peel_*_type functions are supposed to return either an
>underlying type (when something can be "peeled") or the original
>type (when not).
>
>This overload of peel_typedef_type currently returns null if the type
>isn't a typedef. This patch corrects this.
>
>The bug hasn't bitten as all existing calls are protected by an
>is_typedef check. Note that the recursive calls within the function
>are to the other (const type_base_sptr&) overload.
>
>	* src/abg-ir.cc (peel_typedef_type): In the const type_base*
>        overload, return the original argument rather than null if the
>        type isn't actually a typedef.
>
>Signed-off-by: Giuliano Procida <gprocida@google.com>

Reviewed-by: Matthias Maennich <maennich@google.com>

Cheers,
Matthias
>---
> src/abg-ir.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/src/abg-ir.cc b/src/abg-ir.cc
>index 83602b8a..27d493cc 100644
>--- a/src/abg-ir.cc
>+++ b/src/abg-ir.cc
>@@ -5249,7 +5249,7 @@ peel_typedef_type(const type_base* type)
> {
>   const typedef_decl* t = is_typedef(type);
>   if (!t)
>-    return t;
>+    return type;
>
>   return peel_typedef_type(t->get_underlying_type()).get();
> }
>-- 
>2.25.1.481.gfbce0eb801-goog
>
>
Dodji Seketeli March 20, 2020, 11:30 p.m. UTC | #2
Giuliano Procida <gprocida@google.com> a ?crit:

> The various peel_*_type functions are supposed to return either an
> underlying type (when something can be "peeled") or the original
> type (when not).
>
> This overload of peel_typedef_type currently returns null if the type
> isn't a typedef. This patch corrects this.
>
> The bug hasn't bitten as all existing calls are protected by an
> is_typedef check. Note that the recursive calls within the function
> are to the other (const type_base_sptr&) overload.
>
> 	* src/abg-ir.cc (peel_typedef_type): In the const type_base*
>         overload, return the original argument rather than null if the
>         type isn't actually a typedef.

Applied to master.

Thanks!
diff mbox series

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 83602b8a..27d493cc 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -5249,7 +5249,7 @@  peel_typedef_type(const type_base* type)
 {
   const typedef_decl* t = is_typedef(type);
   if (!t)
-    return t;
+    return type;
 
   return peel_typedef_type(t->get_underlying_type()).get();
 }