diff mbox series

[6/6] hw/s390x: Clean up global variable shadowing in quiesce_powerdown_req()

Message ID 20231009094747.54240-7-philmd@linaro.org
State Superseded
Headers show
Series hw: Clean up global variables shadowing | expand

Commit Message

Philippe Mathieu-Daudé Oct. 9, 2023, 9:47 a.m. UTC
Fix:

  hw/s390x/sclpquiesce.c:90:22: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
      QuiesceNotifier *qn = container_of(n, QuiesceNotifier, notifier);
                       ^
  hw/s390x/sclpquiesce.c:86:3: note: previous declaration is here
  } qn;
    ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/s390x/sclpquiesce.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Thomas Huth Oct. 9, 2023, 9:51 a.m. UTC | #1
On 09/10/2023 11.47, Philippe Mathieu-Daudé wrote:
> Fix:
> 
>    hw/s390x/sclpquiesce.c:90:22: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>        QuiesceNotifier *qn = container_of(n, QuiesceNotifier, notifier);
>                         ^
>    hw/s390x/sclpquiesce.c:86:3: note: previous declaration is here
>    } qn;
>      ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/s390x/sclpquiesce.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
> index ce07b16884..a641089929 100644
> --- a/hw/s390x/sclpquiesce.c
> +++ b/hw/s390x/sclpquiesce.c
> @@ -78,12 +78,10 @@ static const VMStateDescription vmstate_sclpquiesce = {
>        }
>   };
>   
> -typedef struct QuiesceNotifier QuiesceNotifier;
> -
> -static struct QuiesceNotifier {
> +typedef struct QuiesceNotifier {
>       Notifier notifier;
>       SCLPEvent *event;
> -} qn;
> +} QuiesceNotifier;
>   
>   static void quiesce_powerdown_req(Notifier *n, void *opaque)
>   {
> @@ -97,6 +95,8 @@ static void quiesce_powerdown_req(Notifier *n, void *opaque)
>   
>   static int quiesce_init(SCLPEvent *event)
>   {
> +    static QuiesceNotifier qn;
> +
>       qn.notifier.notify = quiesce_powerdown_req;
>       qn.event = event;

Reviewed-by: Thomas Huth <thuth@redhat.com>
David Hildenbrand Oct. 9, 2023, 9:52 a.m. UTC | #2
On 09.10.23 11:47, Philippe Mathieu-Daudé wrote:
> Fix:
> 
>    hw/s390x/sclpquiesce.c:90:22: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>        QuiesceNotifier *qn = container_of(n, QuiesceNotifier, notifier);
>                         ^
>    hw/s390x/sclpquiesce.c:86:3: note: previous declaration is here
>    } qn;
>      ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/s390x/sclpquiesce.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
> index ce07b16884..a641089929 100644
> --- a/hw/s390x/sclpquiesce.c
> +++ b/hw/s390x/sclpquiesce.c
> @@ -78,12 +78,10 @@ static const VMStateDescription vmstate_sclpquiesce = {
>        }
>   };
>   
> -typedef struct QuiesceNotifier QuiesceNotifier;
> -
> -static struct QuiesceNotifier {
> +typedef struct QuiesceNotifier {
>       Notifier notifier;
>       SCLPEvent *event;
> -} qn;
> +} QuiesceNotifier;
>   
>   static void quiesce_powerdown_req(Notifier *n, void *opaque)
>   {
> @@ -97,6 +95,8 @@ static void quiesce_powerdown_req(Notifier *n, void *opaque)
>   
>   static int quiesce_init(SCLPEvent *event)
>   {
> +    static QuiesceNotifier qn;
> +
>       qn.notifier.notify = quiesce_powerdown_req;
>       qn.event = event;
>   

Reviewed-by: David Hildenbrand <david@redhat.com>
Eric Farman Oct. 11, 2023, 11:58 a.m. UTC | #3
On Mon, 2023-10-09 at 11:47 +0200, Philippe Mathieu-Daudé wrote:
> Fix:
> 
>   hw/s390x/sclpquiesce.c:90:22: error: declaration shadows a variable
> in the global scope [-Werror,-Wshadow]
>       QuiesceNotifier *qn = container_of(n, QuiesceNotifier,
> notifier);
>                        ^
>   hw/s390x/sclpquiesce.c:86:3: note: previous declaration is here
>   } qn;
>     ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/s390x/sclpquiesce.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Eric Farman <farman@linux.ibm.com>
diff mbox series

Patch

diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
index ce07b16884..a641089929 100644
--- a/hw/s390x/sclpquiesce.c
+++ b/hw/s390x/sclpquiesce.c
@@ -78,12 +78,10 @@  static const VMStateDescription vmstate_sclpquiesce = {
      }
 };
 
-typedef struct QuiesceNotifier QuiesceNotifier;
-
-static struct QuiesceNotifier {
+typedef struct QuiesceNotifier {
     Notifier notifier;
     SCLPEvent *event;
-} qn;
+} QuiesceNotifier;
 
 static void quiesce_powerdown_req(Notifier *n, void *opaque)
 {
@@ -97,6 +95,8 @@  static void quiesce_powerdown_req(Notifier *n, void *opaque)
 
 static int quiesce_init(SCLPEvent *event)
 {
+    static QuiesceNotifier qn;
+
     qn.notifier.notify = quiesce_powerdown_req;
     qn.event = event;