diff mbox series

[v3,11/16] util/cutils: Clean up global variable shadowing in get_relocated_path()

Message ID 20231004120019.93101-12-philmd@linaro.org
State Superseded
Headers show
Series (few more) Steps towards enabling -Wshadow | expand

Commit Message

Philippe Mathieu-Daudé Oct. 4, 2023, noon UTC
Fix:

  util/cutils.c:1147:17: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
      const char *exec_dir = qemu_get_exec_dir();
                  ^
  util/cutils.c:1035:20: note: previous declaration is here
  static const char *exec_dir;
                     ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 util/cutils.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Eric Blake Oct. 4, 2023, 6:52 p.m. UTC | #1
On Wed, Oct 04, 2023 at 02:00:14PM +0200, Philippe Mathieu-Daudé wrote:
> Fix:
> 
>   util/cutils.c:1147:17: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>       const char *exec_dir = qemu_get_exec_dir();
>                   ^
>   util/cutils.c:1035:20: note: previous declaration is here
>   static const char *exec_dir;
>                      ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  util/cutils.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/util/cutils.c b/util/cutils.c
> index 25373198ad..b44718a6a2 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -1144,7 +1144,6 @@ char *get_relocated_path(const char *dir)
>  {
>      size_t prefix_len = strlen(CONFIG_PREFIX);
>      const char *bindir = CONFIG_BINDIR;
> -    const char *exec_dir = qemu_get_exec_dir();
>      GString *result;
>      int len_dir, len_bindir;
>  
> --

Took me a few seconds to see it, but since we have this just a few lines before:

const char *qemu_get_exec_dir(void)
{
    return exec_dir;
}

the deletion of the redundant local variable is just fine.

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/util/cutils.c b/util/cutils.c
index 25373198ad..b44718a6a2 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1144,7 +1144,6 @@  char *get_relocated_path(const char *dir)
 {
     size_t prefix_len = strlen(CONFIG_PREFIX);
     const char *bindir = CONFIG_BINDIR;
-    const char *exec_dir = qemu_get_exec_dir();
     GString *result;
     int len_dir, len_bindir;