* [PATCH] i40iw: Use fallthrough pseudo-keyword
@ 2021-05-09 8:31 Wei Ming Chen
2021-05-09 10:50 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Wei Ming Chen @ 2021-05-09 8:31 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-rdma, Wei Ming Chen
Add pseudo-keyword macro fallthrough[1]
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
Signed-off-by: Wei Ming Chen <jj251510319013@gmail.com>
---
drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 1 +
drivers/infiniband/hw/i40iw/i40iw_uk.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
index eaea5d545eb8..c6081283217c 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
@@ -2454,6 +2454,7 @@ static enum i40iw_status_code i40iw_sc_qp_init(struct i40iw_sc_qp *qp,
return ret_code;
break;
case 5: /* fallthrough until next ABI version */
+ fallthrough;
default:
if (qp->qp_uk.max_rq_frag_cnt > I40IW_MAX_WQ_FRAGMENT_COUNT)
return I40IW_ERR_INVALID_FRAG_COUNT;
diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c b/drivers/infiniband/hw/i40iw/i40iw_uk.c
index f521be16bf31..e1c318c291c0 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_uk.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c
@@ -1004,6 +1004,7 @@ enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp,
i40iw_get_wqe_shift(info->max_rq_frag_cnt, 0, &rqshift);
break;
case 5: /* fallthrough until next ABI version */
+ fallthrough;
default:
rqshift = I40IW_MAX_RQ_WQE_SHIFT;
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i40iw: Use fallthrough pseudo-keyword
2021-05-09 8:31 [PATCH] i40iw: Use fallthrough pseudo-keyword Wei Ming Chen
@ 2021-05-09 10:50 ` Leon Romanovsky
[not found] ` <CAJwFiGLyH5aOY=MGvCawWBm7fXuPkndBO83jkT9dWhPpnrd+cw@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-05-09 10:50 UTC (permalink / raw)
To: Wei Ming Chen; +Cc: linux-kernel, linux-rdma
On Sun, May 09, 2021 at 04:31:35PM +0800, Wei Ming Chen wrote:
> Add pseudo-keyword macro fallthrough[1]
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
>
> Signed-off-by: Wei Ming Chen <jj251510319013@gmail.com>
> ---
> drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 1 +
> drivers/infiniband/hw/i40iw/i40iw_uk.c | 1 +
> 2 files changed, 2 insertions(+)
What exactly are you fixing?
"case" without any code doesn't need "fallthrough".
Thanks
>
> diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> index eaea5d545eb8..c6081283217c 100644
> --- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> +++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> @@ -2454,6 +2454,7 @@ static enum i40iw_status_code i40iw_sc_qp_init(struct i40iw_sc_qp *qp,
> return ret_code;
> break;
> case 5: /* fallthrough until next ABI version */
> + fallthrough;
> default:
> if (qp->qp_uk.max_rq_frag_cnt > I40IW_MAX_WQ_FRAGMENT_COUNT)
> return I40IW_ERR_INVALID_FRAG_COUNT;
> diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c b/drivers/infiniband/hw/i40iw/i40iw_uk.c
> index f521be16bf31..e1c318c291c0 100644
> --- a/drivers/infiniband/hw/i40iw/i40iw_uk.c
> +++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c
> @@ -1004,6 +1004,7 @@ enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp,
> i40iw_get_wqe_shift(info->max_rq_frag_cnt, 0, &rqshift);
> break;
> case 5: /* fallthrough until next ABI version */
> + fallthrough;
> default:
> rqshift = I40IW_MAX_RQ_WQE_SHIFT;
> break;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i40iw: Use fallthrough pseudo-keyword
[not found] ` <CAJwFiGLyH5aOY=MGvCawWBm7fXuPkndBO83jkT9dWhPpnrd+cw@mail.gmail.com>
@ 2021-05-09 12:22 ` Leon Romanovsky
[not found] ` <CAJwFiGK-ABAuNGcFbXAr6d6bn10_t8O+3h09Xt15WGh-7G1W3A@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-05-09 12:22 UTC (permalink / raw)
To: 陳偉銘; +Cc: RDMA mailing list
On Sun, May 09, 2021 at 08:12:42PM +0800, 陳偉銘 wrote:
> Hi,
>
> thanks for reply
>
> the purpose for the patch is to follow the regulation in this doc(
> https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
> )
>
> the following paragraph is written in the doc:
> [image: image.png]
>
> Not sure if I misunderstood anything, or actually we don't need to follow
> the regulation if no code in "case"?
Please don't top-post, use HTML emails and always CC mailing list.
I'm saying that there is a difference between two following snippets:
switch (value) {
case STATE_ONE:
do_something();
case STATE_TWO:
do_other();
break;
default:
WARN("unknown state");
}
and
switch (value) {
case STATE_ONE:
case STATE_TWO:
do_other();
break;
default:
WARN("unknown state");
}
While the first one needs "fallthrough" keyword, the second one doesn't.
Thanks
>
> Thanks
>
> Wei Ming Chen
>
> Leon Romanovsky <leon@kernel.org> 於 2021年5月9日 週日 下午6:50寫道:
>
> > On Sun, May 09, 2021 at 04:31:35PM +0800, Wei Ming Chen wrote:
> > > Add pseudo-keyword macro fallthrough[1]
> > >
> > > [1]
> > https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
> > >
> > > Signed-off-by: Wei Ming Chen <jj251510319013@gmail.com>
> > > ---
> > > drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 1 +
> > > drivers/infiniband/hw/i40iw/i40iw_uk.c | 1 +
> > > 2 files changed, 2 insertions(+)
> >
> > What exactly are you fixing?
> > "case" without any code doesn't need "fallthrough".
> >
> > Thanks
> >
> > >
> > > diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> > b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> > > index eaea5d545eb8..c6081283217c 100644
> > > --- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> > > +++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
> > > @@ -2454,6 +2454,7 @@ static enum i40iw_status_code
> > i40iw_sc_qp_init(struct i40iw_sc_qp *qp,
> > > return ret_code;
> > > break;
> > > case 5: /* fallthrough until next ABI version */
> > > + fallthrough;
> > > default:
> > > if (qp->qp_uk.max_rq_frag_cnt >
> > I40IW_MAX_WQ_FRAGMENT_COUNT)
> > > return I40IW_ERR_INVALID_FRAG_COUNT;
> > > diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c
> > b/drivers/infiniband/hw/i40iw/i40iw_uk.c
> > > index f521be16bf31..e1c318c291c0 100644
> > > --- a/drivers/infiniband/hw/i40iw/i40iw_uk.c
> > > +++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c
> > > @@ -1004,6 +1004,7 @@ enum i40iw_status_code i40iw_qp_uk_init(struct
> > i40iw_qp_uk *qp,
> > > i40iw_get_wqe_shift(info->max_rq_frag_cnt, 0,
> > &rqshift);
> > > break;
> > > case 5: /* fallthrough until next ABI version */
> > > + fallthrough;
> > > default:
> > > rqshift = I40IW_MAX_RQ_WQE_SHIFT;
> > > break;
> > > --
> > > 2.25.1
> > >
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i40iw: Use fallthrough pseudo-keyword
[not found] ` <CAJwFiGK-ABAuNGcFbXAr6d6bn10_t8O+3h09Xt15WGh-7G1W3A@mail.gmail.com>
@ 2021-05-09 14:15 ` Leon Romanovsky
0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-05-09 14:15 UTC (permalink / raw)
To: 陳偉銘; +Cc: RDMA mailing list
On Sun, May 09, 2021 at 09:55:57PM +0800, 陳偉銘 wrote:
> >Leon Romanovsky <leon@kernel.org> 於 2021年5月9日 週日 下午8:22寫道:
> > Please don't top-post, use HTML emails and always CC mailing list.
>
> > I'm saying that there is a difference between two following snippets:
> > switch (value) {
> > case STATE_ONE:
> > do_something();
> > case STATE_TWO:
> > do_other();
> > break;
> > default:
> > WARN("unknown state");
> > }
> > and
> >
> > switch (value) {
> > case STATE_ONE:
> > case STATE_TWO:
> > do_other();
> > break;
> > default:
> > WARN("unknown state");
> > }
> >
> > While the first one needs "fallthrough" keyword, the second one doesn't.
>
> > Thanks
>
> Hi,
>
> Sorry for making trouble, hope that I make it right this time.
>
> Thanks for the detailed explanation, since that it is not needed to use
> "fallthrough" if no code in "case", maybe we should clarify for this
> condition in the documentataion? Otherwise, I guess there might be someone
> else like me making this mistake again in the future.
I don't think that it is necessary.
Thanks.
>
> Thanks!
>
> Wei Ming Chen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-09 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-09 8:31 [PATCH] i40iw: Use fallthrough pseudo-keyword Wei Ming Chen
2021-05-09 10:50 ` Leon Romanovsky
[not found] ` <CAJwFiGLyH5aOY=MGvCawWBm7fXuPkndBO83jkT9dWhPpnrd+cw@mail.gmail.com>
2021-05-09 12:22 ` Leon Romanovsky
[not found] ` <CAJwFiGK-ABAuNGcFbXAr6d6bn10_t8O+3h09Xt15WGh-7G1W3A@mail.gmail.com>
2021-05-09 14:15 ` Leon Romanovsky
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.