[01/10] Use block::containing_function

Message ID 20260501124504.2233495-2-tdevries@suse.de
State New
Headers
Series Add superblocks range loops |

Commit Message

Tom de Vries May 1, 2026, 12:44 p.m. UTC
  Add uses of block::containing_function.
---
 gdb/go-lang.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
  

Patch

diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 3b388c961fa..657679f3fe8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -430,28 +430,21 @@  go_symbol_package_name (const struct symbol *sym)
 gdb::unique_xmalloc_ptr<char>
 go_block_package_name (const struct block *block)
 {
-  while (block != NULL)
-    {
-      struct symbol *function = block->function ();
-
-      if (function != NULL)
-	{
-	  gdb::unique_xmalloc_ptr<char> package_name
-	    = go_symbol_package_name (function);
-
-	  if (package_name != NULL)
-	    return package_name;
+  struct symbol *function
+    = block != nullptr ? block->containing_function () : nullptr;
+  if (function == nullptr)
+    return nullptr;
 
-	  /* Stop looking if we find a function without a package name.
-	     We're most likely outside of Go and thus the concept of the
-	     "current" package is gone.  */
-	  return NULL;
-	}
+  gdb::unique_xmalloc_ptr<char> package_name
+    = go_symbol_package_name (function);
 
-      block = block->superblock ();
-    }
+  if (package_name != nullptr)
+    return package_name;
 
-  return NULL;
+  /* Stop looking if we find a function without a package name.
+     We're most likely outside of Go and thus the concept of the
+     "current" package is gone.  */
+  return nullptr;
 }
 
 /* See language.h.  */