Skip to contentSkip to conversation

Fix build error when VNC is configured out

PATCH In review Christophe de Dinechin 4 participants 5 messages Jun 25, 2019 – Jul 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Fix build error when VNC is configured out

In hmp_change(), the variable hmp_mon is only used by code under #ifdef CONFIG_VNC. This results in a build error when VNC is configured out with the default of treating warnings as errors:

monitor/hmp-cmds.c: In function ‘hmp_change’:
monitor/hmp-cmds.c:1946:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable]

1946 |     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     |                 ^~~~~~~

v2: Move variable down as suggested by Philippe Mathieu-Daudé

---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
index c283dde0e9..2ae784b9b8 100644
@@ -1943,7 +1943,6 @@ static void hmp_change_read_arg(void *opaque, const char *password,
 
 void hmp_change(Monitor *mon, const QDict *qdict)
 {
-    MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     const char *device = qdict_get_str(qdict, "device");
     const char *target = qdict_get_str(qdict, "target");
     const char *arg = qdict_get_try_str(qdict, "arg");
@@ -1961,6 +1960,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
         if (strcmp(target, "passwd") == 0 ||
             strcmp(target, "password") == 0) {
             if (!arg) {
+                MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
                 monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
                 return;
             }
Signature · 1 line
2.21.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · * Christophe de Dinechin ([email protected]) wrote:

In hmp_change(), the variable hmp_mon is only used by code under #ifdef CONFIG_VNC. This results in a build error when VNC is configured out with the default of treating warnings as errors:

Quoted 8 lines

monitor/hmp-cmds.c: In function ‘hmp_change’:
monitor/hmp-cmds.c:1946:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable]

1946 |     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     |                 ^~~~~~~

v2: Move variable down as suggested by Philippe Mathieu-Daudé

Quoted 27 lines
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/hmp-cmds.c +1 -1
index c283dde0e9..2ae784b9b8 100644
@@ -1943,7 +1943,6 @@ static void hmp_change_read_arg(void *opaque, const char *password,
 
 void hmp_change(Monitor *mon, const QDict *qdict)
 {
-    MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     const char *device = qdict_get_str(qdict, "device");
     const char *target = qdict_get_str(qdict, "target");
     const char *arg = qdict_get_try_str(qdict, "arg");
@@ -1961,6 +1960,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
         if (strcmp(target, "passwd") == 0 ||
             strcmp(target, "password") == 0) {
             if (!arg) {
+                MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
                 monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
                 return;
             }
Signature · 1 line
2.21.0

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Reviewed-by on v2 1/1
#2 lore raw
In reply to Christophe de Dinechin
Quoted 11 lines · Christophe de Dinechin

In hmp_change(), the variable hmp_mon is only used by code under #ifdef CONFIG_VNC. This results in a build error when VNC is configured out with the default of treating warnings as errors:

monitor/hmp-cmds.c: In function ‘hmp_change’:
monitor/hmp-cmds.c:1946:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable]

1946 |     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     |                 ^~~~~~~

v2: Move variable down as suggested by Philippe Mathieu-Daudé

Should we move out this line from the commit message? (Maybe Dave can remove it when apply)

Quoted 5 lines
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw
Quoted 11 lines · Stefano Garzarella
Quoted 10 lines · Christophe de Dinechin

In hmp_change(), the variable hmp_mon is only used by code under #ifdef CONFIG_VNC. This results in a build error when VNC is configured out with the default of treating warnings as errors:

monitor/hmp-cmds.c: In function ‘hmp_change’:
monitor/hmp-cmds.c:1946:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable]

1946 |     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     |                 ^~~~~~~
Quoted 4 lines
Quoted 1 line

v2: Move variable down as suggested by Philippe Mathieu-Daudé

Should we move out this line from the commit message? (Maybe Dave can remove it when apply)

Yes please :) It was meant to go after the '---' separator.

Quoted 8 lines
Quoted 5 lines
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#4 lore raw
Quoted 12 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Quoted 11 lines · Stefano Garzarella
Quoted 10 lines · Christophe de Dinechin

In hmp_change(), the variable hmp_mon is only used by code under #ifdef CONFIG_VNC. This results in a build error when VNC is configured out with the default of treating warnings as errors:

monitor/hmp-cmds.c: In function ‘hmp_change’:
monitor/hmp-cmds.c:1946:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable]

1946 |     MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     |                 ^~~~~~~
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

v2: Move variable down as suggested by Philippe Mathieu-Daudé

Should we move out this line from the commit message? (Maybe Dave can remove it when apply)

Yes please :) It was meant to go after the '---' separator.

Done.

Queued.

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK