diff options
Diffstat (limited to 'libdwfl')
-rw-r--r-- | libdwfl/ChangeLog | 10 | ||||
-rw-r--r-- | libdwfl/dwfl_frame.c | 4 | ||||
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 4 | ||||
-rw-r--r-- | libdwfl/linux-kernel-modules.c | 4 | ||||
-rw-r--r-- | libdwfl/linux-pid-attach.c | 6 | ||||
-rw-r--r-- | libdwfl/relocate.c | 8 |
6 files changed, 26 insertions, 10 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index d107e78f..fedf65a4 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,13 @@ +2021-04-19 Martin Liska <mliska@suse.cz> + + * dwfl_frame.c (dwfl_attach_state): Use startswith. + * dwfl_module_getdwarf.c (find_symtab): Likewise. + * linux-kernel-modules.c: Likewise. + * linux-pid-attach.c (linux_proc_pid_is_stopped): Likewise. + (dwfl_linux_proc_attach): Likewise. + * relocate.c (resolve_symbol): Likewise. + (relocate_section): Likewise. + 2021-02-01 Érico Nogueira <ericonr@disroot.org> * dwfl_error.c (strerror_r): Only use the GNU version when available. diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c index 5bbf850e..77e0c5cb 100644 --- a/libdwfl/dwfl_frame.c +++ b/libdwfl/dwfl_frame.c @@ -30,6 +30,8 @@ # include <config.h> #endif +#include <system.h> + #include "libdwflP.h" #include <unistd.h> @@ -172,7 +174,7 @@ dwfl_attach_state (Dwfl *dwfl, Elf *elf, pid_t pid, is called from dwfl_linux_proc_attach with elf == NULL. __libdwfl_module_getebl will call __libdwfl_getelf which will call the find_elf callback. */ - if (strncmp (mod->name, "[vdso: ", 7) == 0 + if (startswith (mod->name, "[vdso: ") || strcmp (strrchr (mod->name, ' ') ?: "", " (deleted)") == 0) continue; diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index 2f3dd0dd..6f076057 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -1162,7 +1162,7 @@ find_symtab (Dwfl_Module *mod) if (sname == NULL) goto elferr; - if (strncmp (sname, ".zdebug", strlen (".zdebug")) == 0) + if (startswith (sname, ".zdebug")) /* Try to uncompress, but it might already have been, an error might just indicate, already uncompressed. */ elf_compress_gnu (symstrscn, 0, 0); @@ -1245,7 +1245,7 @@ find_symtab (Dwfl_Module *mod) if (sname == NULL) goto elferr; - if (strncmp (sname, ".zdebug", strlen (".zdebug")) == 0) + if (startswith (sname, ".zdebug")) /* Try to uncompress, but it might already have been, an error might just indicate, already uncompressed. */ elf_compress_gnu (aux_strscn, 0, 0); diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 6edb27f2..c0f8dfa4 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -924,7 +924,7 @@ dwfl_linux_kernel_module_section_address if (!strcmp (secname, ".modinfo") || !strcmp (secname, ".data.percpu") - || !strncmp (secname, ".exit", 5)) + || startswith (secname, ".exit")) { *addr = (Dwarf_Addr) -1l; return DWARF_CB_OK; @@ -935,7 +935,7 @@ dwfl_linux_kernel_module_section_address behavior, and this cruft leaks out into the /sys information. The file name for ".init*" may actually look like "_init*". */ - const bool is_init = !strncmp (secname, ".init", 5); + const bool is_init = startswith (secname, ".init"); if (is_init) { if (asprintf (&sysfile, SECADDRDIRFMT "_%s", diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c index fdf5c9b1..cd534825 100644 --- a/libdwfl/linux-pid-attach.c +++ b/libdwfl/linux-pid-attach.c @@ -30,6 +30,8 @@ # include <config.h> #endif +#include <system.h> + #include "libelfP.h" #include "libdwflP.h" #include <sys/types.h> @@ -59,7 +61,7 @@ linux_proc_pid_is_stopped (pid_t pid) have_state = false; while (fgets (buffer, sizeof (buffer), procfile) != NULL) - if (strncmp (buffer, "State:", 6) == 0) + if (startswith (buffer, "State:")) { have_state = true; break; @@ -407,7 +409,7 @@ dwfl_linux_proc_attach (Dwfl *dwfl, pid_t pid, bool assume_ptrace_stopped) char *line = NULL; size_t linelen = 0; while (getline (&line, &linelen, procfile) >= 0) - if (strncmp (line, "Tgid:", 5) == 0) + if (startswith (line, "Tgid:")) { errno = 0; char *endptr; diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index 88b5211d..0497bd4f 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -30,6 +30,8 @@ # include <config.h> #endif +#include <system.h> + #include "libelfP.h" #include "libdwflP.h" @@ -237,7 +239,7 @@ resolve_symbol (Dwfl_Module *referer, struct reloc_symtab_cache *symtab, return DWFL_E_LIBELF; /* If the section is already decompressed, that isn't an error. */ - if (strncmp (sname, ".zdebug", strlen (".zdebug")) == 0) + if (startswith (sname, ".zdebug")) elf_compress_gnu (scn, 0, 0); if ((shdr->sh_flags & SHF_COMPRESSED) != 0) @@ -518,7 +520,7 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, Nothing to do here. */ return DWFL_E_NOERROR; - if (strncmp (tname, ".zdebug", strlen ("zdebug")) == 0) + if (startswith (tname, ".zdebug")) elf_compress_gnu (tscn, 0, 0); if ((tshdr->sh_flags & SHF_COMPRESSED) != 0) @@ -539,7 +541,7 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, if (sname == NULL) return DWFL_E_LIBELF; - if (strncmp (sname, ".zdebug", strlen ("zdebug")) == 0) + if (startswith (sname, ".zdebug")) elf_compress_gnu (scn, 0, 0); if ((shdr->sh_flags & SHF_COMPRESSED) != 0) |