Patchwork [for-1.4] qemu-char: Avoid unused variable warning in some configs

login
register
mail settings
Submitter Peter Maydell
Date Jan. 24, 2013, 4:14 p.m.
Message ID <1359044079-11742-1-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/215423/
State New
Headers show

Comments

Peter Maydell - Jan. 24, 2013, 4:14 p.m.
Avoid unused variable warnings:
qemu-char.c: In function 'qmp_chardev_open_port':
qemu-char.c:3132: warning: unused variable 'fd'
qemu-char.c:3132: warning: unused variable 'flags'

in configurations with neither HAVE_CHARDEV_TTY nor
HAVE_CHARDEV_PARPORT set.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Specifically, this happens on MacOSX.

 qemu-char.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Blue Swirl - Jan. 26, 2013, 3:08 p.m.
Thanks, applied.

On Thu, Jan 24, 2013 at 4:14 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Avoid unused variable warnings:
> qemu-char.c: In function 'qmp_chardev_open_port':
> qemu-char.c:3132: warning: unused variable 'fd'
> qemu-char.c:3132: warning: unused variable 'flags'
>
> in configurations with neither HAVE_CHARDEV_TTY nor
> HAVE_CHARDEV_PARPORT set.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Specifically, this happens on MacOSX.
>
>  qemu-char.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 9ba0573..da1db1d 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -3129,11 +3129,11 @@ static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)
>
>  static CharDriverState *qmp_chardev_open_port(ChardevPort *port, Error **errp)
>  {
> -    int flags, fd;
> -
>      switch (port->type) {
>  #ifdef HAVE_CHARDEV_TTY
>      case CHARDEV_PORT_KIND_SERIAL:
> +    {
> +        int flags, fd;
>          flags = O_RDWR;
>          fd = qmp_chardev_open_file_source(port->device, flags, errp);
>          if (error_is_set(errp)) {
> @@ -3141,15 +3141,19 @@ static CharDriverState *qmp_chardev_open_port(ChardevPort *port, Error **errp)
>          }
>          socket_set_nonblock(fd);
>          return qemu_chr_open_tty_fd(fd);
> +    }
>  #endif
>  #ifdef HAVE_CHARDEV_PARPORT
>      case CHARDEV_PORT_KIND_PARALLEL:
> +    {
> +        int flags, fd;
>          flags = O_RDWR;
>          fd = qmp_chardev_open_file_source(port->device, flags, errp);
>          if (error_is_set(errp)) {
>              return NULL;
>          }
>          return qemu_chr_open_pp_fd(fd);
> +    }
>  #endif
>      default:
>          error_setg(errp, "unknown chardev port (%d)", port->type);
> --
> 1.7.9.5
>
>

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 9ba0573..da1db1d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3129,11 +3129,11 @@  static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)
 
 static CharDriverState *qmp_chardev_open_port(ChardevPort *port, Error **errp)
 {
-    int flags, fd;
-
     switch (port->type) {
 #ifdef HAVE_CHARDEV_TTY
     case CHARDEV_PORT_KIND_SERIAL:
+    {
+        int flags, fd;
         flags = O_RDWR;
         fd = qmp_chardev_open_file_source(port->device, flags, errp);
         if (error_is_set(errp)) {
@@ -3141,15 +3141,19 @@  static CharDriverState *qmp_chardev_open_port(ChardevPort *port, Error **errp)
         }
         socket_set_nonblock(fd);
         return qemu_chr_open_tty_fd(fd);
+    }
 #endif
 #ifdef HAVE_CHARDEV_PARPORT
     case CHARDEV_PORT_KIND_PARALLEL:
+    {
+        int flags, fd;
         flags = O_RDWR;
         fd = qmp_chardev_open_file_source(port->device, flags, errp);
         if (error_is_set(errp)) {
             return NULL;
         }
         return qemu_chr_open_pp_fd(fd);
+    }
 #endif
     default:
         error_setg(errp, "unknown chardev port (%d)", port->type);