aboutsummaryrefslogtreecommitdiff
path: root/gdb/gcore.c
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2015-03-06 09:42:06 +0000
committerGary Benson <gbenson@redhat.com>2015-03-06 09:42:06 +0000
commit61012eef8463764ccd9117dc1c9bc43cc452b7cc (patch)
treef576a77bcb77e71cc60e6592b56d2aa915b50c36 /gdb/gcore.c
parente80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff)
New common function "startswith"
This commit introduces a new inline common function "startswith" which takes two string arguments and returns nonzero if the first string starts with the second. It also updates the 295 places where this logic was written out longhand to use the new function. gdb/ChangeLog: * common/common-utils.h (startswith): New inline function. All places where this logic was used updated to use the above.
Diffstat (limited to 'gdb/gcore.c')
-rw-r--r--gdb/gcore.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 1ebff2a420..3e05c61267 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -387,9 +387,9 @@ make_output_phdrs (bfd *obfd, asection *osec, void *ignored)
int p_type = 0;
/* FIXME: these constants may only be applicable for ELF. */
- if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
+ if (startswith (bfd_section_name (obfd, osec), "load"))
p_type = PT_LOAD;
- else if (strncmp (bfd_section_name (obfd, osec), "note", 4) == 0)
+ else if (startswith (bfd_section_name (obfd, osec), "note"))
p_type = PT_NOTE;
else
p_type = PT_NULL;
@@ -562,7 +562,7 @@ gcore_copy_callback (bfd *obfd, asection *osec, void *ignored)
return;
/* Only interested in "load" sections. */
- if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
+ if (!startswith (bfd_section_name (obfd, osec), "load"))
return;
size = min (total_size, MAX_COPY_BYTES);