binutils/readelf: Remove unused static variables

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

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Bratislav Filipovic March 31, 2026, 10:22 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]

Fixes: AIROCGDB-553
---
 binutils/readelf.c | 4 ----
 1 file changed, 4 deletions(-)
  

Comments

Tom de Vries March 31, 2026, 2:52 p.m. UTC | #1
On 3/31/26 12:22 PM, 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]
> 

Hi,

I think this should be submitted to the binutils mailing list ( 
binutils@sourceware.org ).

Thanks,
- Tom

> Fixes: AIROCGDB-553
> ---
>   binutils/readelf.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> 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)
>   	    {
  

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)
 	    {