gdb: remove unnecessary NULL checks for return value of value_from_register

Message ID 20240119153541.60269-1-simon.marchi@efficios.com
State New
Headers
Series gdb: remove unnecessary NULL checks for return value of value_from_register |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch is already merged

Commit Message

Simon Marchi Jan. 19, 2024, 3:35 p.m. UTC
  value_from_register can't return nullptr, remove some NULL checks.

Change-Id: Ia6b32b8f86e593c535e3678a89dffe5544eb7ab0
---
 gdb/findvar.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)


base-commit: dbca3300ea7ad55dfd3dfed29d8a6386736138cd
  

Comments

Tom Tromey Jan. 19, 2024, 4:26 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> value_from_register can't return nullptr, remove some NULL checks.

Ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Simon Marchi Jan. 19, 2024, 4:29 p.m. UTC | #2
On 1/19/24 11:26, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
> 
> Simon> value_from_register can't return nullptr, remove some NULL checks.
> 
> Ok.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks, pushed.

Simon
  

Patch

diff --git a/gdb/findvar.c b/gdb/findvar.c
index d0bb3fd320e7..37b859c2347d 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -623,29 +623,12 @@  language_defn::read_var_value (struct symbol *var,
       {
 	int regno = SYMBOL_REGISTER_OPS (var)
 		      ->register_number (var, get_frame_arch (frame));
-	struct value *regval;
 
 	if (var->aclass () == LOC_REGPARM_ADDR)
-	  {
-	    regval = value_from_register (lookup_pointer_type (type),
-					  regno,
-					  frame);
-
-	    if (regval == NULL)
-	      error (_("Value of register variable not available for `%s'."),
-		     var->print_name ());
-
-	    addr = value_as_address (regval);
-	  }
+	  addr = value_as_address
+	   (value_from_register (lookup_pointer_type (type), regno, frame));
 	else
-	  {
-	    regval = value_from_register (type, regno, frame);
-
-	    if (regval == NULL)
-	      error (_("Value of register variable not available for `%s'."),
-		     var->print_name ());
-	    return regval;
-	  }
+	  return value_from_register (type, regno, frame);
       }
       break;