[2/2] gdb: do minor code modernization in make_pointer_type and make_reference_type

Message ID 20260803143531.2958552-2-tankutbaris.aktemur@amd.com
State New
Headers
Series [1/2] gdb: remove dead code in make_pointer_type and make_reference_type |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Aktemur, Baris Aug. 3, 2026, 2:35 p.m. UTC
  This is a small code modernization.  There should be no behavioral
change.
---
 gdb/gdbtypes.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
  

Comments

Simon Marchi Aug. 3, 2026, 2:51 p.m. UTC | #1
On 8/3/26 10:35 AM, Tankut Baris Aktemur wrote:
> This is a small code modernization.  There should be no behavioral
> change.

Thanks, this LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2dda175237c..409601abe03 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -366,10 +366,8 @@  smash_type (struct type *type)
 type *
 make_pointer_type (type *type)
 {
-  struct type *ntype;	/* New type */
-  ntype = type->pointer_type;
-
-  if (ntype)
+  struct type *ntype = type->pointer_type;
+  if (ntype != nullptr)
     return ntype;
 
   ntype = type_allocator (type).new_type ();
@@ -403,23 +401,22 @@  lookup_pointer_type (struct type *type)
 type *
 make_reference_type (type *type, type_code refcode)
 {
-  struct type *ntype;	/* New type */
-  struct type **reftype;
-
   gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF);
 
-  ntype = (refcode == TYPE_CODE_REF ? type->reference_type
-	   : type->rvalue_reference_type);
+  struct type *ntype = (refcode == TYPE_CODE_REF
+			? type->reference_type
+			: type->rvalue_reference_type);
 
-  if (ntype)
+  if (ntype != nullptr)
     return ntype;
 
   ntype = type_allocator (type).new_type ();
   ntype->set_target_type (type);
-  reftype = (refcode == TYPE_CODE_REF ? &type->reference_type
-	     : &type->rvalue_reference_type);
 
-  *reftype = ntype;
+  if (refcode == TYPE_CODE_REF)
+    type->reference_type = ntype;
+  else
+    type->rvalue_reference_type = ntype;
 
   /* FIXME!  Assume the machine has only one representation for
      references, and that it matches the (only) representation for