Skip to content

Commit

Permalink
bfd, binutils, gas: Mark unused variables
Browse files Browse the repository at this point in the history
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).

bfd/ChangeLog:

	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Mark unused
	rgot_count variable.
	* elf32-nds32.c (elf32_nds32_unify_relax_group): Mark unused
	count variable.
	* mmo.c (mmo_scan): Mark unused lineno variable.

binutils/ChangeLog:

	* windmc.c (write_rc): Mark unused i variable.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_ip): Mark unused argnum variable.

ld/ChangeLog:

	* pe-dll.c (generate_reloc): Mark unused bi and page_count
	variables.
  • Loading branch information
a4lg committed Sep 15, 2022
1 parent fe39ffd commit 5904f60
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bfd/elf32-lm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
struct weak_symbol_list *list_start = NULL, *list_end = NULL;
int rgot_weak_count = 0;
int r32_count = 0;
int rgot_count = 0;
int rgot_count ATTRIBUTE_UNUSED = 0;
/* Look for deleted sections. */
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
Expand Down
2 changes: 1 addition & 1 deletion bfd/elf32-nds32.c
Original file line number Diff line number Diff line change
Expand Up @@ -13460,7 +13460,7 @@ elf32_nds32_unify_relax_group (bfd *abfd, asection *asec)
Elf_Internal_Rela *relocs = NULL;
enum elf_nds32_reloc_type rtype;
struct section_id_list_t *node = NULL;
int count = 0;
int count ATTRIBUTE_UNUSED = 0;

do
{
Expand Down
2 changes: 1 addition & 1 deletion bfd/mmo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ static bool
mmo_scan (bfd *abfd)
{
unsigned int i;
unsigned int lineno = 1;
unsigned int lineno ATTRIBUTE_UNUSED = 1;
bool error = false;
bfd_vma vma = 0;
asection *sec = NULL;
Expand Down
3 changes: 2 additions & 1 deletion binutils/windmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ static void
write_rc (FILE *fp)
{
mc_node_lang *n;
int i, l;
int l;
int i ATTRIBUTE_UNUSED;

fprintf (fp,
"/* Do not edit this file manually.\n"
Expand Down
2 changes: 1 addition & 1 deletion gas/config/tc-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 3 additions & 2 deletions ld/pe-dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5904f60

Please sign in to comment.