[Qemu-devel] [PATCH] Fix build error when VNC is configured out

Christophe de Dinechin posted 1 patch 4 years, 10 months ago
Test checkpatch passed
Test s390x passed
Test asan passed
Test docker-mingw@fedora passed
Test FreeBSD passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/4C5F8F98-D058-46A4-81E7-D9A5D4FEE2EC@redhat.com
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
There is a newer version of this series
monitor/hmp-cmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] Fix build error when VNC is configured out
Posted by Christophe de Dinechin 4 years, 10 months ago
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);
     |                 ^~~~~~~

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 monitor/hmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index c283dde0e9..038614da8e 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -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");
@@ -1952,6 +1951,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
 #ifdef CONFIG_VNC
+    MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
     if (strcmp(device, "vnc") == 0) {
         if (read_only) {
             monitor_printf(mon,
-- 
2.20.1 


Re: [Qemu-devel] [PATCH] Fix build error when VNC is configured out
Posted by Philippe Mathieu-Daudé 4 years, 10 months ago
Hi Christophe,

On 6/25/19 11:24 AM, Christophe de Dinechin 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:
> 
> 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);
>      |                 ^~~~~~~
> 
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
>  monitor/hmp-cmds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index c283dde0e9..038614da8e 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -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");
> @@ -1952,6 +1951,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>  #ifdef CONFIG_VNC
> +    MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);

Can you move it after 'if (!arg) {', the sole place where it is used?

Regardless:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>      if (strcmp(device, "vnc") == 0) {
>          if (read_only) {
>              monitor_printf(mon,
> 

Re: [Qemu-devel] [PATCH] Fix build error when VNC is configured out
Posted by Markus Armbruster 4 years, 10 months ago
Cc: David Gilbert

Christophe de Dinechin <dinechin@redhat.com> writes:

> 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);
>      |                 ^~~~~~~
>
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
>  monitor/hmp-cmds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index c283dde0e9..038614da8e 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -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");
> @@ -1952,6 +1951,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
>      Error *err = NULL;
>  
>  #ifdef CONFIG_VNC
> +    MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
>      if (strcmp(device, "vnc") == 0) {
>          if (read_only) {
>              monitor_printf(mon,