Message ID | 20171006213333.6721-3-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
> Avoid that gcc 7 reports the following warning when building with W=1: > > warning: this statement may fall through [-Wimplicit-fallthrough=] > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Acked-by: Sean Hefty <sean.hefty@intel.com> -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/6/2017 5:32 PM, Bart Van Assche wrote: > Avoid that gcc 7 reports the following warning when building with W=1: > > warning: this statement may fall through [-Wimplicit-fallthrough=] > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > Cc: Sean Hefty <sean.hefty@intel.com> > --- > drivers/infiniband/core/cm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c > index d80911d4abb7..5927ee4e57ca 100644 > --- a/drivers/infiniband/core/cm.c > +++ b/drivers/infiniband/core/cm.c > @@ -2808,6 +2808,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, > msg_response = CM_MSG_RESPONSE_OTHER; > break; > } > + /* fall through */ > default: > ret = -EINVAL; > goto error1; > So adding the comment is enough to make gcc shut up? Or are you just annotating the code so it's obvious it was intentional? -Dennis -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> > diff --git a/drivers/infiniband/core/cm.c > > b/drivers/infiniband/core/cm.c index d80911d4abb7..5927ee4e57ca > 100644 > > --- a/drivers/infiniband/core/cm.c > > +++ b/drivers/infiniband/core/cm.c > > @@ -2808,6 +2808,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, > > msg_response = CM_MSG_RESPONSE_OTHER; > > break; > > } > > + /* fall through */ > > default: > > ret = -EINVAL; > > goto error1; > > > > So adding the comment is enough to make gcc shut up? Or are you just > annotating the code so it's obvious it was intentional? gcc will process the comment and its intent
On Tue, Oct 10, 2017 at 03:27:11PM -0400, Dennis Dalessandro wrote: > On 10/6/2017 5:32 PM, Bart Van Assche wrote: > > Avoid that gcc 7 reports the following warning when building with W=1: > > > > warning: this statement may fall through [-Wimplicit-fallthrough=] > > > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > > Cc: Sean Hefty <sean.hefty@intel.com> > > --- > > drivers/infiniband/core/cm.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c > > index d80911d4abb7..5927ee4e57ca 100644 > > --- a/drivers/infiniband/core/cm.c > > +++ b/drivers/infiniband/core/cm.c > > @@ -2808,6 +2808,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, > > msg_response = CM_MSG_RESPONSE_OTHER; > > break; > > } > > + /* fall through */ > > default: > > ret = -EINVAL; > > goto error1; > > > > So adding the comment is enough to make gcc shut up? Or are you just > annotating the code so it's obvious it was intentional? GCC is looking for the specific comment. --- -Wimplicit-fallthrough warns when a switch case falls through. This warning has five different levels. The compiler is able to parse a wide range of fallthrough comments, depending on the level. It also handles control-flow statements, such as ifs. It's possible to suppress the warning by either adding a fallthrough comment, or by using a null statement: __attribute__ ((fallthrough)); (C, C++), or [[fallthrough]]; (C++17), or [[gnu::fallthrough]]; (C++11/C++14). --- https://gcc.gnu.org/gcc-7/changes.html Thanks > > -Dennis > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/10/2017 3:31 PM, Leon Romanovsky wrote: > On Tue, Oct 10, 2017 at 03:27:11PM -0400, Dennis Dalessandro wrote: >> On 10/6/2017 5:32 PM, Bart Van Assche wrote: >>> Avoid that gcc 7 reports the following warning when building with W=1: >>> >>> warning: this statement may fall through [-Wimplicit-fallthrough=] >>> >>> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> >>> Cc: Sean Hefty <sean.hefty@intel.com> >>> --- >>> drivers/infiniband/core/cm.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c >>> index d80911d4abb7..5927ee4e57ca 100644 >>> --- a/drivers/infiniband/core/cm.c >>> +++ b/drivers/infiniband/core/cm.c >>> @@ -2808,6 +2808,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, >>> msg_response = CM_MSG_RESPONSE_OTHER; >>> break; >>> } >>> + /* fall through */ >>> default: >>> ret = -EINVAL; >>> goto error1; >>> >> >> So adding the comment is enough to make gcc shut up? Or are you just >> annotating the code so it's obvious it was intentional? > > GCC is looking for the specific comment. > --- > -Wimplicit-fallthrough warns when a switch case falls through. > This warning has five different levels. The compiler is able to parse a wide range of fallthrough comments, > depending on the level. It also handles control-flow statements, such as ifs. > It's possible to suppress the warning by either adding a fallthrough comment, > or by using a null statement: __attribute__ ((fallthrough)); (C, C++), > or [[fallthrough]]; (C++17), or [[gnu::fallthrough]]; (C++11/C++14). > --- > https://gcc.gnu.org/gcc-7/changes.html > > Thanks Ah, makes sense now, thanks Leon. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index d80911d4abb7..5927ee4e57ca 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -2808,6 +2808,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id, msg_response = CM_MSG_RESPONSE_OTHER; break; } + /* fall through */ default: ret = -EINVAL; goto error1;
Avoid that gcc 7 reports the following warning when building with W=1: warning: this statement may fall through [-Wimplicit-fallthrough=] Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Sean Hefty <sean.hefty@intel.com> --- drivers/infiniband/core/cm.c | 1 + 1 file changed, 1 insertion(+)