[3/4] Use gdb::checked_static_cast for code_breakpoint

Message ID 20230915-watchpoint-casts-v1-3-a4ff35c9644e@adacore.com
State New
Headers
Series Use checked_static_cast for breakpoint casts |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Sept. 15, 2023, 6:36 p.m. UTC
  This replaces some casts to 'code_breakpoint *' with
checked_static_cast.
---
 gdb/breakpoint.c | 6 ++++--
 gdb/elfread.c    | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 134ad76ce9a..5d87b17a58d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6174,10 +6174,12 @@  bpstat_run_callbacks (bpstat *bs_head)
 	  handle_jit_event (bs->bp_location_at->address);
 	  break;
 	case bp_gnu_ifunc_resolver:
-	  gnu_ifunc_resolver_stop ((code_breakpoint *) b);
+	  gnu_ifunc_resolver_stop
+	    (gdb::checked_static_cast<code_breakpoint *> (b));
 	  break;
 	case bp_gnu_ifunc_resolver_return:
-	  gnu_ifunc_resolver_return_stop ((code_breakpoint *) b);
+	  gnu_ifunc_resolver_return_stop
+	    (gdb::checked_static_cast<code_breakpoint *> (b));
 	  break;
 	}
     }
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 55e3e47ceca..8704b52f35b 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1033,7 +1033,7 @@  elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b)
 			    "gnu-indirect-function breakpoint type %d"),
 			  (int) b->type);
 	}
-      b = (code_breakpoint *) b_next;
+      b = gdb::checked_static_cast<code_breakpoint *> (b_next);
     }
   gdb_assert (b->type == bp_gnu_ifunc_resolver);
   gdb_assert (b->has_single_location ());