]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/breakpoints] Rename bp_location_is_less_than to bp_location_ptr_is_less_than
authorTom de Vries <tdevries@suse.de>
Mon, 26 May 2025 13:15:31 +0000 (15:15 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 26 May 2025 13:15:31 +0000 (15:15 +0200)
commit8dd54de0a83dcf57fdaef68902c73e35e0ea274d
tree5775750afc2708d2d3bbd008b0b92109ab0c3efd
parent3e02c4891dcb37a0a12cff53232342f6d160b2c5
[gdb/breakpoints] Rename bp_location_is_less_than to bp_location_ptr_is_less_than

In breakpoint.c, we have:
...
/* A comparison function for bp_location AP and BP being interfaced to
   std::sort.  Sort elements primarily by their ADDRESS (no matter what
   bl_address_is_meaningful says), secondarily by ordering first
   permanent elements and tertiarily just ensuring the array is sorted
   stable way despite std::sort being an unstable algorithm.  */

static int
bp_location_is_less_than (const bp_location *a, const bp_location *b)
...

There are few problems here:
- the return type is int.  While std::sort allows this, because int is
  convertible to bool, it's clearer to use bool directly,
- it's not abundantly clear from either function name or comment that we can
  use this to sort std::vector<bp_location *> but not
  std::vector<bp_location>, and
- the comment mentions AP and BP, but there are no such parameters.

Fix this by:
- changing the return type to bool,
- renaming the function to bp_location_ptr_is_less_than and mentioning
  std::vector<bp_location *> in the comment, and
- updating the comment to use the correct parameter names.

Tested on x86_64-linux.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/breakpoint.c