[PATCH] libctf: Remove unused variable initialized to itself
Nick Alcock
nick.alcock@oracle.com
Fri Oct 8 14:49:16 GMT 2021
On 6 Oct 2021, Michael Forney spake thusly:
> 2021-10-06 Michael Forney <mforney@mforney.org>
>
> * ctf-link.c: Remove unused variable initialized to itself.
Oops! Why didn't that elicit a compiler warning, I wonder...
> libctf/ctf-link.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
> index cc99f818970..ebb2cffd398 100644
> --- a/libctf/ctf-link.c
> +++ b/libctf/ctf-link.c
> @@ -1594,7 +1594,6 @@ ctf_link_shuffle_syms (ctf_dict_t *fp)
>
> while ((err = ctf_dynhash_next (fp->ctf_dynsyms, &i, &name_, &sym_)) == 0)
> {
> - const char *name = (const char *) name;
> ctf_link_sym_t *symp = (ctf_link_sym_t *) sym_;
>
> if (!ctf_assert (fp, symp->st_symidx <= fp->ctf_dynsymmax))
That'll work, but you can improve thins a bit more by dropping the name_
variable as well, and turning the &name_ parameter to ctf_dynhash_next
into a NULL, which is idiomatic for "I'm not using that" in _next()
functions.
(Clearly I thought I was going to use the symbol name at one point when
I wrote this code, then ended up not using it, so didn't notice the
typo: that line was meant to read
const char *name = (const char *) name_;
to get the name into a variable of the right type; but since it's unused
that's useless.)
--
NULL && (void)
More information about the Binutils
mailing list