summaryrefslogtreecommitdiff
path: root/libebl
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-04-19 14:33:36 +0200
committerMark Wielaard <mark@klomp.org>2021-05-12 11:56:57 +0200
commitadc201f81902f3015a841869756ed4b9b811fe33 (patch)
tree735ab647b6e749f7bbbd1cd88256f89c2de266a9 /libebl
parent857546d176a36d2b5dc18b81dcafa3fb8ec0123d (diff)
downloadelfutils-adc201f81902f3015a841869756ed4b9b811fe33.tar.gz
Come up with startswith function.
New function in system.h that returns true if a string has a given prefix, false otherwise. Use it in place of strncmp. Signed-off-by: Martin Liška <mliska@suse.cz>
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog5
-rw-r--r--libebl/eblobjnotetypename.c5
-rw-r--r--libebl/eblopenbackend.c4
3 files changed, 10 insertions, 4 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 33208f0d..fff66b3e 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-19 Martin Liska <mliska@suse.cz>
+
+ * eblobjnotetypename.c (ebl_object_note_type_name): Use startswith.
+ * eblopenbackend.c (default_debugscn_p): Likewise.
+
2020-12-16 Dmitry V. Levin <ldv@altlinux.org>
* libeblP.h (_): Remove.
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 9daddcda..4662906d 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -31,6 +31,8 @@
# include <config.h>
#endif
+#include <system.h>
+
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
@@ -79,8 +81,7 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
}
}
- if (strncmp (name, ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX,
- strlen (ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX)) == 0)
+ if (startswith (name, ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX))
{
/* GNU Build Attribute notes (ab)use the owner name to store
most of their data. Don't decode everything here. Just
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index a8af1658..71fafed7 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -616,9 +616,9 @@ default_debugscn_p (const char *name)
/ sizeof (dwarf_scn_names[0]));
for (size_t cnt = 0; cnt < ndwarf_scn_names; ++cnt)
if (strcmp (name, dwarf_scn_names[cnt]) == 0
- || (strncmp (name, ".zdebug", strlen (".zdebug")) == 0
+ || (startswith (name, ".zdebug")
&& strcmp (&name[2], &dwarf_scn_names[cnt][1]) == 0)
- || (strncmp (name, ".gnu.debuglto_", strlen (".gnu.debuglto_")) == 0
+ || (startswith (name, ".gnu.debuglto_")
&& strcmp (&name[14], dwarf_scn_names[cnt]) == 0))
return true;