[PATCH] libctf: Pass format argument to asprintf
Nick Alcock
nick.alcock@oracle.com
Mon Nov 23 18:32:05 GMT 2020
On 23 Nov 2020, H. J. Lu said:
> PR libctf/26934
> * ctf-dump.c (ctf_dump_objts): Pass format argument to asprintf.
> ---
> libctf/ctf-dump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
> index ccf4b3cb2b..5c3041f8e5 100644
> --- a/libctf/ctf-dump.c
> +++ b/libctf/ctf-dump.c
> @@ -403,7 +403,7 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions)
> goto out;
> }
>
> - if (asprintf (&typestr, ctf_errmsg (ctf_errno (fp))) < 0)
> + if (asprintf (&typestr, "%s", ctf_errmsg (ctf_errno (fp))) < 0)
> goto oom;
>
> err = -1;
Thanks! (Now why did none of my runs spot this?)
The intent of this stuff is to differentiate between a type we can't
represent, which is not actually an error and gets something like
foo_t -> (type not represented in CTF)
-- which hopefully makes it kind of clear that a nonrepresentable type
is not actually an error of any sort -- versus an outright error, which
should just print the error message because it's not related to the type
at all.
... but we should probably indicate in some fashion clearer than just a
lack of brackets that this is an error.
Do you mind if we do
> + if (asprintf (&typestr, _("Error: %s"), ctf_errmsg (ctf_errno (fp))) < 0)
instead?
More information about the Binutils
mailing list