[RFC,05/11] readelf: Fix set but not used variable

Message ID 20230206222513.1773039-6-iii@linux.ibm.com
State Superseded
Headers
Series Add Memory Sanitizer support |

Commit Message

Ilya Leoshkevich Feb. 6, 2023, 10:25 p.m. UTC
  clang complains:

    readelf.c:10250:10: error: variable 'nculist' set but not used [-Werror,-Wunused-but-set-variable]
      size_t nculist = 0;
             ^

Fix by deleting it.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 src/readelf.c | 2 --
 1 file changed, 2 deletions(-)
  

Comments

Mark Wielaard Feb. 8, 2023, 5:09 p.m. UTC | #1
Hi Ilya,

On Mon, 2023-02-06 at 23:25 +0100, Ilya Leoshkevich via Elfutils-devel
wrote:
> clang complains:
> 
>     readelf.c:10250:10: error: variable 'nculist' set but not used [-Werror,-Wunused-but-set-variable]
>       size_t nculist = 0;
>              ^
> 
> Fix by deleting it.

yeah, this is clearly a copy/paste from print_debug_macinfo_section
into print_debug_macro_section where the nculist isn't actually used.

Not much to add, so pushed as is.

Thanks,

Mark

> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>  src/readelf.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/src/readelf.c b/src/readelf.c
> index f09c5c9b..76ca65f5 100644
> --- a/src/readelf.c
> +++ b/src/readelf.c
> @@ -10247,7 +10247,6 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
>    Dwarf_Off ncu = 0;
>    size_t hsize;
>    struct mac_culist *culist = NULL;
> -  size_t nculist = 0;
>    while (dwarf_nextcu (dbg, offset = ncu, &ncu, &hsize, NULL, NULL, NULL) == 0)
>      {
>        Dwarf_Die cudie;
> @@ -10268,7 +10267,6 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
>        newp->files = NULL;
>        newp->next = culist;
>        culist = newp;
> -      ++nculist;
>      }
>  
>    const unsigned char *readp = (const unsigned char *) data->d_buf;
  

Patch

diff --git a/src/readelf.c b/src/readelf.c
index f09c5c9b..76ca65f5 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -10247,7 +10247,6 @@  print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
   Dwarf_Off ncu = 0;
   size_t hsize;
   struct mac_culist *culist = NULL;
-  size_t nculist = 0;
   while (dwarf_nextcu (dbg, offset = ncu, &ncu, &hsize, NULL, NULL, NULL) == 0)
     {
       Dwarf_Die cudie;
@@ -10268,7 +10267,6 @@  print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
       newp->files = NULL;
       newp->next = culist;
       culist = newp;
-      ++nculist;
     }
 
   const unsigned char *readp = (const unsigned char *) data->d_buf;