All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
@ 2012-07-04 12:17 Olaf Hering
  2012-07-23 10:51 ` Ian Campbell
  0 siblings, 1 reply; 7+ messages in thread
From: Olaf Hering @ 2012-07-04 12:17 UTC (permalink / raw)
  To: xen-devel

# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1341404234 -7200
# Node ID 5668cb98eebb0a27530c8b52f3ae8cce87d3b863
# Parent  42f76d536b116d2ebad1b6705ae51ecd171d2581
libxl: fix unitialized variables in libxl__primary_console_find

gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
LIBXL_DOMAIN_TYPE_INVALID properly:

cc1: warnings being treated as errors
libxl.c: In function 'libxl_primary_console_exec':
libxl.c:1408:14: error: 'domid' may be used uninitialized in this function
libxl.c:1409:9: error: 'cons_num' may be used uninitialized in this function
libxl.c:1410:24: error: 'type' may be used uninitialized in this function
libxl.c: In function 'libxl_primary_console_get_tty':
libxl.c:1421:14: error: 'domid' may be used uninitialized in this function
libxl.c:1422:9: error: 'cons_num' may be used uninitialized in this function
libxl.c:1423:24: error: 'type' may be used uninitialized in this function
make[3]: *** [libxl.o] Error 1

Fix this by adding a default case.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

diff -r 42f76d536b11 -r 5668cb98eebb tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1392,6 +1392,7 @@ static int libxl__primary_console_find(l
             *type = LIBXL_CONSOLE_TYPE_PV;
             break;
         case LIBXL_DOMAIN_TYPE_INVALID:
+        default:
             rc = ERROR_INVAL;
             goto out;
         }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
  2012-07-04 12:17 [PATCH] libxl: fix unitialized variables in libxl__primary_console_find Olaf Hering
@ 2012-07-23 10:51 ` Ian Campbell
  2012-07-23 13:43   ` Olaf Hering
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2012-07-23 10:51 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Ian Jackson

On Wed, 2012-07-04 at 13:17 +0100, Olaf Hering wrote:
> # HG changeset patch
> # User Olaf Hering <olaf@aepfle.de>
> # Date 1341404234 -7200
> # Node ID 5668cb98eebb0a27530c8b52f3ae8cce87d3b863
> # Parent  42f76d536b116d2ebad1b6705ae51ecd171d2581
> libxl: fix unitialized variables in libxl__primary_console_find

Olaf,

I have a vague recollection of some discussion of this and a different
fix but I can't actually find any such discussion and the patch is still
in my queue. Is this still needed?

> gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
> LIBXL_DOMAIN_TYPE_INVALID properly:

That's kind of lame of gcc...

I wonder if default: abort() might be more appropriate (I'm not sure
what our policy here ended up being).

> cc1: warnings being treated as errors
> libxl.c: In function 'libxl_primary_console_exec':
> libxl.c:1408:14: error: 'domid' may be used uninitialized in this function
> libxl.c:1409:9: error: 'cons_num' may be used uninitialized in this function
> libxl.c:1410:24: error: 'type' may be used uninitialized in this function
> libxl.c: In function 'libxl_primary_console_get_tty':
> libxl.c:1421:14: error: 'domid' may be used uninitialized in this function
> libxl.c:1422:9: error: 'cons_num' may be used uninitialized in this function
> libxl.c:1423:24: error: 'type' may be used uninitialized in this function
> make[3]: *** [libxl.o] Error 1
> 
> Fix this by adding a default case.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> 
> diff -r 42f76d536b11 -r 5668cb98eebb tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1392,6 +1392,7 @@ static int libxl__primary_console_find(l
>              *type = LIBXL_CONSOLE_TYPE_PV;
>              break;
>          case LIBXL_DOMAIN_TYPE_INVALID:
> +        default:
>              rc = ERROR_INVAL;
>              goto out;
>          }
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
  2012-07-23 10:51 ` Ian Campbell
@ 2012-07-23 13:43   ` Olaf Hering
  2012-07-24  8:45     ` Ian Campbell
  0 siblings, 1 reply; 7+ messages in thread
From: Olaf Hering @ 2012-07-23 13:43 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Ian Jackson

On Mon, Jul 23, Ian Campbell wrote:

> On Wed, 2012-07-04 at 13:17 +0100, Olaf Hering wrote:
> > # HG changeset patch
> > # User Olaf Hering <olaf@aepfle.de>
> > # Date 1341404234 -7200
> > # Node ID 5668cb98eebb0a27530c8b52f3ae8cce87d3b863
> > # Parent  42f76d536b116d2ebad1b6705ae51ecd171d2581
> > libxl: fix unitialized variables in libxl__primary_console_find
> 
> Olaf,
> 
> I have a vague recollection of some discussion of this and a different
> fix but I can't actually find any such discussion and the patch is still
> in my queue. Is this still needed?

Yes.

> > gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
> > LIBXL_DOMAIN_TYPE_INVALID properly:
> 
> That's kind of lame of gcc...
> 
> I wonder if default: abort() might be more appropriate (I'm not sure
> what our policy here ended up being).

libxl__domain_type is a simple and internal function. Perhaps a comment
about why a 'default' case exists is enough.

Olaf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
  2012-07-23 13:43   ` Olaf Hering
@ 2012-07-24  8:45     ` Ian Campbell
  2012-07-30 19:04       ` Olaf Hering
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2012-07-24  8:45 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Ian Jackson

On Mon, 2012-07-23 at 14:43 +0100, Olaf Hering wrote:
> On Mon, Jul 23, Ian Campbell wrote:
> 
> > On Wed, 2012-07-04 at 13:17 +0100, Olaf Hering wrote:
> > > # HG changeset patch
> > > # User Olaf Hering <olaf@aepfle.de>
> > > # Date 1341404234 -7200
> > > # Node ID 5668cb98eebb0a27530c8b52f3ae8cce87d3b863
> > > # Parent  42f76d536b116d2ebad1b6705ae51ecd171d2581
> > > libxl: fix unitialized variables in libxl__primary_console_find
> > 
> > Olaf,
> > 
> > I have a vague recollection of some discussion of this and a different
> > fix but I can't actually find any such discussion and the patch is still
> > in my queue. Is this still needed?
> 
> Yes.
> 
> > > gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
> > > LIBXL_DOMAIN_TYPE_INVALID properly:
> > 
> > That's kind of lame of gcc...
> > 
> > I wonder if default: abort() might be more appropriate (I'm not sure
> > what our policy here ended up being).
> 
> libxl__domain_type is a simple and internal function. Perhaps a comment
> about why a 'default' case exists is enough.

I think we've mostly been considering that the "abort()" is in itself
enough documentation that this should never happen.

Ian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
  2012-07-24  8:45     ` Ian Campbell
@ 2012-07-30 19:04       ` Olaf Hering
  0 siblings, 0 replies; 7+ messages in thread
From: Olaf Hering @ 2012-07-30 19:04 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel, Ian Jackson

On Tue, Jul 24, Ian Campbell wrote:

> I think we've mostly been considering that the "abort()" is in itself
> enough documentation that this should never happen.

I have posted a patch which does that. Other places in that file have
the same 'default: abort();' already.

Olaf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
  2012-07-30 16:35 Olaf Hering
@ 2012-08-01 11:47 ` Ian Campbell
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Campbell @ 2012-08-01 11:47 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel

On Mon, 2012-07-30 at 17:35 +0100, Olaf Hering wrote:
> # HG changeset patch
> # User Olaf Hering <olaf@aepfle.de>
> # Date 1343662357 -7200
> # Node ID db8adce4f09307a90f96103f7fd67efa97fc9ac0
> # Parent  cf0e661cb321b1c898c9008dc17ba21db434c976
> libxl: fix unitialized variables in libxl__primary_console_find
> 
> gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
> LIBXL_DOMAIN_TYPE_INVALID properly:
> 
> cc1: warnings being treated as errors
> libxl.c: In function 'libxl_primary_console_exec':
> libxl.c:1408:14: error: 'domid' may be used uninitialized in this function
> libxl.c:1409:9: error: 'cons_num' may be used uninitialized in this function
> libxl.c:1410:24: error: 'type' may be used uninitialized in this function
> libxl.c: In function 'libxl_primary_console_get_tty':
> libxl.c:1421:14: error: 'domid' may be used uninitialized in this function
> libxl.c:1422:9: error: 'cons_num' may be used uninitialized in this function
> libxl.c:1423:24: error: 'type' may be used uninitialized in this function
> make[3]: *** [libxl.o] Error 1
> 
> Fix this by adding a default case.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

Applied, thanks.

> 
> diff -r cf0e661cb321 -r db8adce4f093 tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1590,6 +1590,7 @@ static int libxl__primary_console_find(l
>          case LIBXL_DOMAIN_TYPE_INVALID:
>              rc = ERROR_INVAL;
>              goto out;
> +        default: abort();
>          }
>      }
>  
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] libxl: fix unitialized variables in libxl__primary_console_find
@ 2012-07-30 16:35 Olaf Hering
  2012-08-01 11:47 ` Ian Campbell
  0 siblings, 1 reply; 7+ messages in thread
From: Olaf Hering @ 2012-07-30 16:35 UTC (permalink / raw)
  To: xen-devel

# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1343662357 -7200
# Node ID db8adce4f09307a90f96103f7fd67efa97fc9ac0
# Parent  cf0e661cb321b1c898c9008dc17ba21db434c976
libxl: fix unitialized variables in libxl__primary_console_find

gcc 4.5 as shipped with openSuSE 11.4 does not recognize the case of
LIBXL_DOMAIN_TYPE_INVALID properly:

cc1: warnings being treated as errors
libxl.c: In function 'libxl_primary_console_exec':
libxl.c:1408:14: error: 'domid' may be used uninitialized in this function
libxl.c:1409:9: error: 'cons_num' may be used uninitialized in this function
libxl.c:1410:24: error: 'type' may be used uninitialized in this function
libxl.c: In function 'libxl_primary_console_get_tty':
libxl.c:1421:14: error: 'domid' may be used uninitialized in this function
libxl.c:1422:9: error: 'cons_num' may be used uninitialized in this function
libxl.c:1423:24: error: 'type' may be used uninitialized in this function
make[3]: *** [libxl.o] Error 1

Fix this by adding a default case.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

diff -r cf0e661cb321 -r db8adce4f093 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1590,6 +1590,7 @@ static int libxl__primary_console_find(l
         case LIBXL_DOMAIN_TYPE_INVALID:
             rc = ERROR_INVAL;
             goto out;
+        default: abort();
         }
     }

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-01 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-04 12:17 [PATCH] libxl: fix unitialized variables in libxl__primary_console_find Olaf Hering
2012-07-23 10:51 ` Ian Campbell
2012-07-23 13:43   ` Olaf Hering
2012-07-24  8:45     ` Ian Campbell
2012-07-30 19:04       ` Olaf Hering
2012-07-30 16:35 Olaf Hering
2012-08-01 11:47 ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.