binutils/readelf: Remove unused static variables

Message ID 20260401110928.4012089-1-bfilipov@amd.com
State New
Headers
Series binutils/readelf: Remove unused static variables |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed

Commit Message

Bratislav Filipovic April 1, 2026, 11:09 a.m. UTC
  Remove static variables do_ctf and do_sframe that are set but never
read, causing build failures with LLVM's extended
-Wunused-but-set-variable warning.

These variables are dead code:
- Declared at lines 244-245 as static booleans
- Set to true when --ctf or --sframe options are parsed
- Never actually used or read anywhere in the code
- The actual dump functionality is triggered by request_dump() calls

Build error with -Werror enabled:
binutils/readelf.c:244:13: error: variable 'do_ctf' set but not used
  [-Werror,-Wunused-but-set-variable]
binutils/readelf.c:245:13: error: variable 'do_sframe' set but not used
  [-Werror,-Wunused-but-set-variable]
---
 binutils/readelf.c | 4 ----
 1 file changed, 4 deletions(-)
  

Comments

Jan Beulich April 1, 2026, 12:37 p.m. UTC | #1
On 01.04.2026 13:09, Bratislav Filipovic wrote:
> Remove static variables do_ctf and do_sframe that are set but never
> read, causing build failures with LLVM's extended
> -Wunused-but-set-variable warning.
> 
> These variables are dead code:
> - Declared at lines 244-245 as static booleans
> - Set to true when --ctf or --sframe options are parsed
> - Never actually used or read anywhere in the code
> - The actual dump functionality is triggered by request_dump() calls
> 
> Build error with -Werror enabled:
> binutils/readelf.c:244:13: error: variable 'do_ctf' set but not used
>   [-Werror,-Wunused-but-set-variable]
> binutils/readelf.c:245:13: error: variable 'do_sframe' set but not used
>   [-Werror,-Wunused-but-set-variable]

Okay.

Jan
  
Filipovic, Bratislav April 2, 2026, 1:13 p.m. UTC | #2
[AMD Official Use Only - AMD Internal Distribution Only]

Hi Jan,

Can you push this since I don't have write-after-approval yet?

Regards Bratislav

-----Original Message-----
From: Jan Beulich <jbeulich@suse.com>
Sent: Wednesday, April 1, 2026 2:37 PM
To: Filipovic, Bratislav <Bratislav.Filipovic@amd.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] binutils/readelf: Remove unused static variables

[You don't often get email from jbeulich@suse.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


On 01.04.2026 13:09, Bratislav Filipovic wrote:
> Remove static variables do_ctf and do_sframe that are set but never
> read, causing build failures with LLVM's extended
> -Wunused-but-set-variable warning.
>
> These variables are dead code:
> - Declared at lines 244-245 as static booleans
> - Set to true when --ctf or --sframe options are parsed
> - Never actually used or read anywhere in the code
> - The actual dump functionality is triggered by request_dump() calls
>
> Build error with -Werror enabled:
> binutils/readelf.c:244:13: error: variable 'do_ctf' set but not used
>   [-Werror,-Wunused-but-set-variable]
> binutils/readelf.c:245:13: error: variable 'do_sframe' set but not used
>   [-Werror,-Wunused-but-set-variable]

Okay.

Jan
  
Jan Beulich April 2, 2026, 1:21 p.m. UTC | #3
On 02.04.2026 15:13, Filipovic, Bratislav wrote:
> Can you push this since I don't have write-after-approval yet?

I can (only late next week though, perhaps), sure, yet I thought you could ask
one of your colleagues at AMD to do that for you? I guess some of them have
write access?

Jan
  

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 7562fd5014f..1274fd4d169 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -241,8 +241,6 @@  static bool do_dump = false;
 static bool do_version = false;
 static bool do_histogram = false;
 static bool do_debugging = false;
-static bool do_ctf = false;
-static bool do_sframe = false;
 static bool do_arch = false;
 static bool do_notes = false;
 static bool do_archive_index = false;
@@ -6988,7 +6986,6 @@  parse_args (struct dump_data *dumpdata, int argc, char ** argv)
 	  dwarf_check = true;
 	  break;
 	case OPTION_CTF_DUMP:
-	  do_ctf = true;
 	  request_dump (dumpdata, CTF_DUMP);
 	  break;
 	case OPTION_CTF_SYMBOLS:
@@ -7004,7 +7001,6 @@  parse_args (struct dump_data *dumpdata, int argc, char ** argv)
 	  dump_ctf_parent_name = strdup (optarg);
 	  break;
 	case OPTION_SFRAME_DUMP:
-	  do_sframe = true;
 	  /* Fix PR/32589 but keep the error messaging same ?  */
 	  if (optarg != NULL && strcmp (optarg, "") == 0)
 	    {