Skip to contentSkip to conversation

i40iw: Use fallthrough pseudo-keyword

PATCH In review Wei Ming Chen 2 participants 4 messages May 9, 2021 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40iw: Use fallthrough pseudo-keyword

Add pseudo-keyword macro fallthrough[1]

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

---
 drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 1 +
 drivers/infiniband/hw/i40iw/i40iw_uk.c   | 1 +
 2 files changed, 2 insertions(+)
drivers/infiniband/hw/i40iw/i40iw_ctrl.c +1 -0
index eaea5d545eb8..c6081283217c 100644
@@ -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;
drivers/infiniband/hw/i40iw/i40iw_uk.c +1 -0
index f521be16bf31..e1c318c291c0 100644
@@ -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;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · 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

---
 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

Quoted 28 lines
drivers/infiniband/hw/i40iw/i40iw_ctrl.c +1 -0
index eaea5d545eb8..c6081283217c 100644
@@ -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;
drivers/infiniband/hw/i40iw/i40iw_uk.c +1 -0
index f521be16bf31..e1c318c291c0 100644
@@ -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;
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): CAJwFiGLyH5aOY=MGvCawWBm7fXuPkndBO83jkT9dWhPpnrd+cw@mail.gmail.com

#3 lore raw
Quoted 8 lines · 陳偉銘

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
)

Quoted 5 lines

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

Quoted 59 lines

Thanks

Wei Ming Chen

Leon Romanovsky <[email protected]> 於 2021年5月9日 週日 下午6:50寫道:

Quoted 52 lines · Wei Ming Chen
Quoted 3 lines

Add pseudo-keyword macro fallthrough[1]

[1]

https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Quoted 6 lines
---
 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

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c

drivers/infiniband/hw/i40iw/i40iw_ctrl.c static enum i40iw_status_code

Quoted 4 lines

index eaea5d545eb8..c6081283217c 100644

drivers/infiniband/hw/i40iw/i40iw_ctrl.c +0 -0
@@ -2454,6 +2454,7 @@ static enum i40iw_status_code

i40iw_sc_qp_init(struct i40iw_sc_qp *qp,

drivers/infiniband/hw/i40iw/i40iw_ctrl.c static enum i40iw_status_code i40iw_sc_qp_init(struct i40iw_sc_qp *qp,

Quoted 6 lines
drivers/infiniband/hw/i40iw/i40iw_ctrl.c +1 -0
                      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)

Review

Quoted 2 lines
drivers/infiniband/hw/i40iw/i40iw_ctrl.c +0 -0
                      return I40IW_ERR_INVALID_FRAG_COUNT;
(quoted diff) +0 -0

b/drivers/infiniband/hw/i40iw/i40iw_uk.c

drivers/infiniband/hw/i40iw/i40iw_uk.c enum i40iw_status_code i40iw_qp_uk_init(struct

Quoted 4 lines

index f521be16bf31..e1c318c291c0 100644

drivers/infiniband/hw/i40iw/i40iw_uk.c +0 -0
@@ -1004,6 +1004,7 @@ enum i40iw_status_code i40iw_qp_uk_init(struct

i40iw_qp_uk *qp,

drivers/infiniband/hw/i40iw/i40iw_uk.c enum i40iw_status_code i40iw_qp_uk_init(struct · line 1004

Quoted 1 line
drivers/infiniband/hw/i40iw/i40iw_uk.c +0 -0
                      i40iw_get_wqe_shift(info->max_rq_frag_cnt, 0,

&rqshift);

Quoted 9 lines
drivers/infiniband/hw/i40iw/i40iw_uk.c +1 -1
                      break;
              case 5: /* fallthrough until next ABI version */
+                     fallthrough;
              default:
                      rqshift = I40IW_MAX_RQ_WQE_SHIFT;
                      break;
--

2.25.1

A message that is not in the archive (sent off-list or not yet received): CAJwFiGK-ABAuNGcFbXAr6d6bn10_t8O+3h09Xt15WGh-7G1W3A@mail.gmail.com

#5 lore raw
Quoted 28 lines · 陳偉銘
Quoted 24 lines

Leon Romanovsky <[email protected]> 於 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");
}
Quoted 3 lines

While the first one needs "fallthrough" keyword, the second one doesn't.

Thanks

Quoted 8 lines

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.

Quoted 4 lines

Thanks!

Wei Ming Chen