public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH 1/1] bfd, binutils, gas: Mark unused variables
Date: Thu, 15 Sep 2022 17:25:32 +0900	[thread overview]
Message-ID: <62b9e3a7-4dcd-40e7-b30f-7cb3776a161d@irq.a4lg.com> (raw)
In-Reply-To: <73538f81-579a-d712-9f34-84170a437491@suse.com>

On 2022/09/15 16:29, Jan Beulich wrote:
> On 15.09.2022 06:17, Tsukasa OI via Binutils wrote:
>> Clang generates a warning on unused (technically, written but not read
>> thereafter) variables.  By the default configuration (with "-Werror"), it
>> causes a build failure (unless "--disable-werror" is specified).
>>
>> This commit, instead of just removing those variables, adds
>> ATTRIBUTE_UNUSED attribute to them, which means they are *possibly* unused
>> (can be used but no warnings occur when unused).
> 
> May I ask why you chose to do so? I can see such a variable being consumed
> inside an #ifdef, but being declared unconditionally as a reason, but
> (looking just at code I'm a little familiar with) ...
> 
>> --- a/gas/config/tc-riscv.c
>> +++ b/gas/config/tc-riscv.c
>> @@ -2303,7 +2303,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
>>    char save_c = 0;
>>    struct riscv_opcode *insn;
>>    unsigned int regno;
>> -  int argnum;
>> +  int argnum ATTRIBUTE_UNUSED;
>>    const struct percent_op_match *p;
>>    struct riscv_ip_error error;
>>    error.msg = "unrecognized opcode";
>> --- a/ld/pe-dll.c
>> +++ b/ld/pe-dll.c
>> @@ -1510,8 +1510,9 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
>>    int total_relocs = 0;
>>    int i;
>>    bfd_vma sec_page = (bfd_vma) -1;
>> -  bfd_vma page_ptr, page_count;
>> -  int bi;
>> +  bfd_vma page_ptr;
>> +  bfd_vma page_count ATTRIBUTE_UNUSED;
>> +  int bi ATTRIBUTE_UNUSED;
>>    bfd *b;
>>    struct bfd_section *s;
>>  
> 
> ... in both of these cases there's truly no reading of the values,
> so I don't see why they would need maintaining.
> 
> Jan
> 

Possibly because I'm a coward?  ... I'm kidding but I must admit that I
didn't take a time to review their actual uses and chose not to break
someone's job (knowing that "someone" may not exist anymore).

bfd/elf32-lm32.c:
    It seems unused rgot_count is a part of an unimplemented feature.
    I want to keep this variable.  Existence of this variable was the
    first reason for me to keep "unused" variables.
bfd/mmo.c:
    Likewise (though that "an unimplemented feature" is never
    implemented for over 10 years).
    I want to keep this variable (but may change my mind in the future).

binutils/windmc.c:
    For this simple function, recovering i variable is very easy.
    It seems it's also a debug artifact from the earliest days.
    Removing is an option.
gas/tc-riscv.c:
    I first thought it's a part of an unimplemented feature and to help
    implementing assembler something... but it seems unused from the
    start (possibly an artifact on the first contribution?).
    Removing is an option.
ld/pe-dll.c:
    I reviewed thoroughly and concluded that, despite that they may have
    a debugging use, keeping this state over 20 years seems too long.
    Removing is an option.

bfd/elf32-nds32.c:
    The first time this variables is added, someone was clearly
    debugging their code and it may be an artifact, too.  Unlike RISC-V,
    it's not an artifact from the first NDS port and it was added
    in 2018.  Recovering this variable is not hard but...
    Removing is ... possibly an option?

I think I can remove unused variables from those files:

*   binutils/windmc.c
*   gas/tc-riscv.c
*   ld/pe-dll.c

bfd/elf32-nds32.c is a candidate of unused variable removal.


For bfd/elf32-lm32.c and bfd/mmo.c, I will choose to keep unused
variables for now. If those variables are still unused in like 2030, I
will change my mind.

I'll at least remove unused variables on three files I shown above (and
possibly on bfd/elf32-nds32.c) and resubmit that patch.

Thanks,
Tsukasa

  reply	other threads:[~2022-09-15  8:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  3:09 [PATCH 0/1] " Tsukasa OI
2022-09-15  3:09 ` [PATCH 1/1] " Tsukasa OI
2022-09-15  4:17 ` [PATCH 0/1] " Tsukasa OI
2022-09-15  4:17   ` [PATCH 1/1] " Tsukasa OI
2022-09-15  7:29     ` Jan Beulich
2022-09-15  8:25       ` Tsukasa OI [this message]
2022-09-15 23:10         ` Hans-Peter Nilsson
2022-09-15 12:46   ` [PATCH v3 0/1] bfd, binutils, gas: Remove/mark " Tsukasa OI
2022-09-15 12:46     ` [PATCH v3 1/1] " Tsukasa OI
2022-09-15 12:58       ` Jan Beulich
2022-09-20 12:50       ` Nick Clifton
2022-09-21  5:54         ` Tsukasa OI
2022-09-21  6:15           ` Jan Beulich
2022-09-21  9:55           ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62b9e3a7-4dcd-40e7-b30f-7cb3776a161d@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).