[PATCH 0/5] Start using startswith instead of strncmp
Alan Modra
amodra@gmail.com
Thu Apr 1 12:47:06 GMT 2021
On Thu, Apr 01, 2021 at 07:21:32AM +0200, Martin Liška wrote:
> --- a/gas/config/obj-elf.c
> +++ b/gas/config/obj-elf.c
> @@ -2508,7 +2508,7 @@ adjust_stab_sections (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
> char *p;
> int strsz, nsyms;
>
> - if (strncmp (".stab", sec->name, 5))
> + if (!startswith (".stab", sec->name))
> return;
I see you caught a number of other cases like this where the args
need swapping. Please fix this one too.
> --- a/gas/config/obj-macho.c
> +++ b/gas/config/obj-macho.c
> @@ -1907,8 +1907,8 @@ obj_mach_o_is_frame_section (segT sec)
> {
> int l;
> l = strlen (segment_name (sec));
> - if ((l == 9 && strncmp (".eh_frame", segment_name (sec), 9) == 0)
> - || (l == 12 && strncmp (".debug_frame", segment_name (sec), 12) == 0))
> + if ((l == 9 && startswith (".eh_frame", segment_name (sec)))
> + || (l == 12 && startswith (".debug_frame", segment_name (sec))))
Here too. OK with those tweaks, thanks!
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list