Pino Toscano
2018-Feb-15 17:14 UTC
[Libguestfs] [PATCH] lib: qemu: help GCC 8 by break'ing a case in a switch
GCC 8 thinks that the case drive_protocol_gluster may fall through, most probably because the only code is a switch case that handles the elements of an enum, and thus letting other fall through. In reality this ought to not happen at all, so help GCC by break'ing the case, which will then lead to the abort() at the end of guestfs_int_drive_source_qemu_param. --- lib/qemu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/qemu.c b/lib/qemu.c index cd859139d..a50eca988 100644 --- a/lib/qemu.c +++ b/lib/qemu.c @@ -746,6 +746,7 @@ guestfs_int_drive_source_qemu_param (guestfs_h *g, return make_uri (g, "gluster+unix", NULL, NULL, &src->servers[0], NULL); } + break; case drive_protocol_http: return make_uri (g, "http", src->username, src->secret, -- 2.14.3
Richard W.M. Jones
2018-Feb-20 09:50 UTC
Re: [Libguestfs] [PATCH] lib: qemu: help GCC 8 by break'ing a case in a switch
On Thu, Feb 15, 2018 at 06:14:59PM +0100, Pino Toscano wrote:> GCC 8 thinks that the case drive_protocol_gluster may fall through, most > probably because the only code is a switch case that handles the > elements of an enum, and thus letting other fall through. In reality > this ought to not happen at all, so help GCC by break'ing the case, > which will then lead to the abort() at the end of > guestfs_int_drive_source_qemu_param. > --- > lib/qemu.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/qemu.c b/lib/qemu.c > index cd859139d..a50eca988 100644 > --- a/lib/qemu.c > +++ b/lib/qemu.c > @@ -746,6 +746,7 @@ guestfs_int_drive_source_qemu_param (guestfs_h *g, > return make_uri (g, "gluster+unix", NULL, NULL, > &src->servers[0], NULL); > } > + break; > > case drive_protocol_http: > return make_uri (g, "http", src->username, src->secret,ACK Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW