From: Simon Marchi Date: Tue, 25 Nov 2025 04:04:30 +0000 (-0500) Subject: gdb/dwarf: remove nullptr prop check in dwarf2_evaluate_property X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc4187ed57d6cf648aa6dc4b4fceafab0a8b1a98;p=thirdparty%2Fbinutils-gdb.git gdb/dwarf: remove nullptr prop check in dwarf2_evaluate_property This nullptr is pointless most of the time: almost all callers either check that the prop is not nullptr or they pass the address of a local variable, which is necessarily not nullptr. I propose to remove it. I found only one call site where I needed to add a check. Change-Id: Iada84d529b8edc6b20486f3539c675dad6b364f5 Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 73e744c8b97..9ab0c70b8f7 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1646,9 +1646,6 @@ dwarf2_evaluate_property (const dynamic_prop *prop, CORE_ADDR *value, gdb::array_view push_values) { - if (prop == NULL) - return false; - /* Evaluating a property should not change the current language. Without this here this could happen if the code below selects a frame. */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9e3c07e0ee5..6736de96c04 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2431,7 +2431,8 @@ resolve_dynamic_array_or_string (struct type *type, /* Resolve the rank property to get rank value. */ struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_RANK); - if (dwarf2_evaluate_property (prop, frame, addr_stack, &value)) + if (prop != nullptr + && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { prop->set_const_val (value); rank = value;