diff mbox

[12/12] xen-blkfront: Avoid that gcc 7 warns about fall-through when building with W=1

Message ID 20170817232311.25948-13-bart.vanassche@wdc.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bart Van Assche Aug. 17, 2017, 11:23 p.m. UTC
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Roger Pau Monn303251 <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org
---
 drivers/block/xen-blkfront.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Roger Pau Monné Aug. 18, 2017, 8:54 a.m. UTC | #1
On Thu, Aug 17, 2017 at 04:23:11PM -0700, Bart Van Assche wrote:
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Roger Pau Monn303251 <roger.pau@citrix.com>
> Cc: xen-devel@lists.xenproject.org
> ---
>  drivers/block/xen-blkfront.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 98e34e4c62b8..270019e3e5d8 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -2456,7 +2456,7 @@ static void blkback_changed(struct xenbus_device *dev,
>  	case XenbusStateClosed:
>  		if (dev->state == XenbusStateClosed)
>  			break;
> -		/* Missed the backend's Closing state -- fallthrough */
> +		/* fall through */

This is losing information present in the original comment. Would
splitting the comment into two make gcc happy?

Roger.
Anthony PERARD Aug. 18, 2017, 11:46 a.m. UTC | #2
On Fri, Aug 18, 2017 at 09:54:01AM +0100, Roger Pau Monn303251 wrote:
> On Thu, Aug 17, 2017 at 04:23:11PM -0700, Bart Van Assche wrote:
> > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Roger Pau Monn303251 <roger.pau@citrix.com>
> > Cc: xen-devel@lists.xenproject.org
> > ---
> >  drivers/block/xen-blkfront.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> > index 98e34e4c62b8..270019e3e5d8 100644
> > --- a/drivers/block/xen-blkfront.c
> > +++ b/drivers/block/xen-blkfront.c
> > @@ -2456,7 +2456,7 @@ static void blkback_changed(struct xenbus_device *dev,
> >  	case XenbusStateClosed:
> >  		if (dev->state == XenbusStateClosed)
> >  			break;
> > -		/* Missed the backend's Closing state -- fallthrough */
> > +		/* fall through */
> 
> This is losing information present in the original comment. Would
> splitting the comment into two make gcc happy?

What about:

-		/* Missed the backend's Closing state -- fallthrough */
+		/* fallthrough -- Missed the backend's Closing state */

FIY:
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough

A dash seems to be needed between "fall through" and a extra comment,
with fallthrough first.

Regards,
Roger Pau Monné Aug. 18, 2017, 11:57 a.m. UTC | #3
On Fri, Aug 18, 2017 at 12:46:23PM +0100, Anthony PERARD wrote:
> On Fri, Aug 18, 2017 at 09:54:01AM +0100, Roger Pau Monn303251 wrote:
> > On Thu, Aug 17, 2017 at 04:23:11PM -0700, Bart Van Assche wrote:
> > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> > > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > > Cc: Roger Pau Monn303251 <roger.pau@citrix.com>
> > > Cc: xen-devel@lists.xenproject.org
> > > ---
> > >  drivers/block/xen-blkfront.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> > > index 98e34e4c62b8..270019e3e5d8 100644
> > > --- a/drivers/block/xen-blkfront.c
> > > +++ b/drivers/block/xen-blkfront.c
> > > @@ -2456,7 +2456,7 @@ static void blkback_changed(struct xenbus_device *dev,
> > >  	case XenbusStateClosed:
> > >  		if (dev->state == XenbusStateClosed)
> > >  			break;
> > > -		/* Missed the backend's Closing state -- fallthrough */
> > > +		/* fall through */
> > 
> > This is losing information present in the original comment. Would
> > splitting the comment into two make gcc happy?
> 
> What about:
> 
> -		/* Missed the backend's Closing state -- fallthrough */
> +		/* fallthrough -- Missed the backend's Closing state */
> 
> FIY:
> https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough
> 
> A dash seems to be needed between "fall through" and a extra comment,
> with fallthrough first.

I think so, according to the documentation -Wimplicit-fallthrough=3 is
enabled with -Wextra, and requires having "fallthrough" first. Your
proposed change seems fine to me.

Roger.
diff mbox

Patch

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 98e34e4c62b8..270019e3e5d8 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2456,7 +2456,7 @@  static void blkback_changed(struct xenbus_device *dev,
 	case XenbusStateClosed:
 		if (dev->state == XenbusStateClosed)
 			break;
-		/* Missed the backend's Closing state -- fallthrough */
+		/* fall through */
 	case XenbusStateClosing:
 		if (info)
 			blkfront_closing(info);