[PATCH 11/19] RISC-V: avoid strdup()
Jiawei
jiawei@iscas.ac.cn
Wed Apr 29 05:45:31 GMT 2026
> Along with xmalloc(), xstrdup() wants using.
>
> --- a/bfd/elfxx-riscv.c
> +++ b/bfd/elfxx-riscv.c
> @@ -2589,7 +2589,7 @@ riscv_copy_subset_list (riscv_subset_lis
> {
> riscv_subset_list_t *new = xmalloc (sizeof *new);
> new->head = riscv_copy_subset (new, subset_list->head);
> - new->arch_str = strdup (subset_list->arch_str);
> + new->arch_str = xstrdup (subset_list->arch_str);
> return new;
> }
>
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -358,7 +358,7 @@ riscv_set_arch (const char *s)
> riscv_release_subset_list (riscv_rps_as.subset_list);
> riscv_parse_subset (&riscv_rps_as, s);
> riscv_arch_str (xlen, riscv_rps_as.subset_list, true/* update */);
> - file_arch_str = strdup (riscv_rps_as.subset_list->arch_str);
> + file_arch_str = xstrdup (riscv_rps_as.subset_list->arch_str);
>
> riscv_set_rvc (riscv_subset_supports (&riscv_rps_as, "c")
> || riscv_subset_supports (&riscv_rps_as, "zca"));
> @@ -1435,7 +1435,7 @@ static bool
> reglist_lookup (char **s, unsigned *reg_list)
> {
> *reg_list = 0;
> - char *reglist = strdup (*s);
> + char *reglist = xstrdup (*s);
> if (reglist != NULL)
> {
> char *token = strtok (reglist, "}");
>
LGTM.
Reviewed-by: Jiawei <jiawei@iscas.ac.cn>
More information about the Binutils
mailing list