From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leon Romanovsky Subject: Re: [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH Date: Wed, 1 Feb 2017 10:09:42 +0200 Message-ID: <20170201080942.GS6005@mtr-leonro.local> References: <1485896886-23517-1-git-send-email-jgunthorpe@obsidianresearch.com> <1485896886-23517-5-git-send-email-jgunthorpe@obsidianresearch.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mpBQsTDkJwM+mRv6" Return-path: Content-Disposition: inline In-Reply-To: <1485896886-23517-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Jason Gunthorpe Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Doug Ledford , Yishai Hadas , Sean Hefty , Devesh Sharma , Ram Amrani , Ariel Elior List-Id: linux-rdma@vger.kernel.org --mpBQsTDkJwM+mRv6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 31, 2017 at 02:08:04PM -0700, Jason Gunthorpe wrote: > gcc 7.0.1 now warns on these, which actually found a bug. So lets "found a bug" - is not accurate. > suppress the warning in OK places since there are not too many. > > providers/mlx4/cq.c:263:17: warning: this statement may fall through [-Wimplicit-fallthrough=] > wc->wc_flags |= IBV_WC_WITH_IMM; > ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ > > Signed-off-by: Jason Gunthorpe > --- > libibverbs/examples/asyncwatch.c | 2 ++ > librdmacm/examples/riostream.c | 2 ++ > librdmacm/examples/rstream.c | 2 ++ > librdmacm/examples/udpong.c | 2 ++ > providers/mlx4/cq.c | 3 +++ > providers/mlx5/cq.c | 3 +++ > providers/ocrdma/ocrdma_verbs.c | 3 +++ > providers/qedr/qelr_verbs.c | 3 ++- > util/compiler.h | 7 +++++++ > 9 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/libibverbs/examples/asyncwatch.c b/libibverbs/examples/asyncwatch.c > index 7af13bf936ec10..f2234e3e540159 100644 > --- a/libibverbs/examples/asyncwatch.c > +++ b/libibverbs/examples/asyncwatch.c > @@ -38,6 +38,7 @@ > #include > #include > > +#include > #include > > static const char *event_name_str(enum ibv_event_type event_type) > @@ -115,6 +116,7 @@ int main(int argc, char *argv[]) > break; > case 'h': > ret = 0; > + SWITCH_FALLTHROUGH; > default: > usage(argv[0]); > return ret; > diff --git a/librdmacm/examples/riostream.c b/librdmacm/examples/riostream.c > index d9e5fd6eb0a601..2b1b3bd70cc7d4 100644 > --- a/librdmacm/examples/riostream.c > +++ b/librdmacm/examples/riostream.c > @@ -46,6 +46,7 @@ > > #include > #include > +#include > #include "common.h" > > struct test_size_param { > @@ -644,6 +645,7 @@ int main(int argc, char **argv) > if (!set_test_opt(optarg)) > break; > /* invalid option - fall through */ > + SWITCH_FALLTHROUGH; > default: > printf("usage: %s\n", argv[0]); > printf("\t[-s server_address]\n"); > diff --git a/librdmacm/examples/rstream.c b/librdmacm/examples/rstream.c > index 14799c99712819..147466e72f9014 100644 > --- a/librdmacm/examples/rstream.c > +++ b/librdmacm/examples/rstream.c > @@ -46,6 +46,7 @@ > > #include > #include > +#include > #include "common.h" > > struct test_size_param { > @@ -673,6 +674,7 @@ int main(int argc, char **argv) > if (!set_test_opt(optarg)) > break; > /* invalid option - fall through */ > + SWITCH_FALLTHROUGH; > default: > printf("usage: %s\n", argv[0]); > printf("\t[-s server_address]\n"); > diff --git a/librdmacm/examples/udpong.c b/librdmacm/examples/udpong.c > index 71528f22676937..37653e928a1678 100644 > --- a/librdmacm/examples/udpong.c > +++ b/librdmacm/examples/udpong.c > @@ -46,6 +46,7 @@ > > #include > #include > +#include > #include "common.h" > > static int test_size[] = { > @@ -543,6 +544,7 @@ int main(int argc, char **argv) > if (!set_test_opt(optarg)) > break; > /* invalid option - fall through */ > + SWITCH_FALLTHROUGH; > default: > printf("usage: %s\n", argv[0]); > printf("\t[-s server_address]\n"); > diff --git a/providers/mlx4/cq.c b/providers/mlx4/cq.c > index 23cc3ed69dc8bc..4c0fb1023bd9d4 100644 > --- a/providers/mlx4/cq.c > +++ b/providers/mlx4/cq.c > @@ -40,6 +40,7 @@ > #include > #include > > +#include > #include > > #include "mlx4.h" > @@ -261,11 +262,13 @@ static int mlx4_poll_one(struct mlx4_cq *cq, > switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) { > case MLX4_OPCODE_RDMA_WRITE_IMM: > wc->wc_flags |= IBV_WC_WITH_IMM; > + SWITCH_FALLTHROUGH; > case MLX4_OPCODE_RDMA_WRITE: > wc->opcode = IBV_WC_RDMA_WRITE; > break; > case MLX4_OPCODE_SEND_IMM: > wc->wc_flags |= IBV_WC_WITH_IMM; > + SWITCH_FALLTHROUGH; > case MLX4_OPCODE_SEND: > wc->opcode = IBV_WC_SEND; > break; > diff --git a/providers/mlx5/cq.c b/providers/mlx5/cq.c > index 7ad27a97f3fffd..b53fa663b01727 100644 > --- a/providers/mlx5/cq.c > +++ b/providers/mlx5/cq.c > @@ -40,6 +40,7 @@ > #include > #include > > +#include > #include > > #include "mlx5.h" > @@ -189,11 +190,13 @@ static inline void handle_good_req(struct ibv_wc *wc, struct mlx5_cqe64 *cqe, st > switch (ntohl(cqe->sop_drop_qpn) >> 24) { > case MLX5_OPCODE_RDMA_WRITE_IMM: > wc->wc_flags |= IBV_WC_WITH_IMM; > + SWITCH_FALLTHROUGH; > case MLX5_OPCODE_RDMA_WRITE: > wc->opcode = IBV_WC_RDMA_WRITE; > break; > case MLX5_OPCODE_SEND_IMM: > wc->wc_flags |= IBV_WC_WITH_IMM; > + SWITCH_FALLTHROUGH; > case MLX5_OPCODE_SEND: > case MLX5_OPCODE_SEND_INVAL: > wc->opcode = IBV_WC_SEND; > diff --git a/providers/ocrdma/ocrdma_verbs.c b/providers/ocrdma/ocrdma_verbs.c > index b11f3ecb92b3b9..4d26a720e05881 100644 > --- a/providers/ocrdma/ocrdma_verbs.c > +++ b/providers/ocrdma/ocrdma_verbs.c > @@ -51,6 +51,7 @@ > #include "ocrdma_main.h" > #include "ocrdma_abi.h" > #include > +#include > > static void ocrdma_ring_cq_db(struct ocrdma_cq *cq, uint32_t armed, > int solicited, uint32_t num_cqe); > @@ -1402,6 +1403,7 @@ int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr, > case IBV_WR_SEND_WITH_IMM: > hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT); > hdr->immdt = ntohl(wr->imm_data); > + SWITCH_FALLTHROUGH; > case IBV_WR_SEND: > hdr->cw |= (OCRDMA_SEND << OCRDMA_WQE_OPCODE_SHIFT); > status = ocrdma_build_send(qp, hdr, wr); > @@ -1409,6 +1411,7 @@ int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr, > case IBV_WR_RDMA_WRITE_WITH_IMM: > hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT); > hdr->immdt = ntohl(wr->imm_data); > + SWITCH_FALLTHROUGH; > case IBV_WR_RDMA_WRITE: > hdr->cw |= (OCRDMA_WRITE << OCRDMA_WQE_OPCODE_SHIFT); > status = ocrdma_build_write(qp, hdr, wr); > diff --git a/providers/qedr/qelr_verbs.c b/providers/qedr/qelr_verbs.c > index bb09deacbf7e55..b445991c93b9a9 100644 > --- a/providers/qedr/qelr_verbs.c > +++ b/providers/qedr/qelr_verbs.c > @@ -49,6 +49,7 @@ > #include "qelr_abi.h" > #include "qelr_chain.h" > #include "qelr_verbs.h" > +#include > > #include > #include > @@ -1686,7 +1687,7 @@ static void __process_resp_one(struct qelr_qp *qp, struct qelr_cq *cq, > case QELR_RESP_RDMA_IMM: > /* update opcode */ > wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM; > - /* fall to set imm data */ > + SWITCH_FALLTHROUGH; > case QELR_RESP_IMM: > wc->imm_data = > ntohl(le32toh(resp->imm_data_or_inv_r_Key)); > diff --git a/util/compiler.h b/util/compiler.h > index 9b57e048df4b44..b2310c301b61c3 100644 > --- a/util/compiler.h > +++ b/util/compiler.h > @@ -15,4 +15,11 @@ > #define uninitialized_var(x) x = x > #endif > > +/* Use to mark fall through on switch statements as desired. */ > +#if __GNUC__ >= 7 > +#define SWITCH_FALLTHROUGH __attribute__ ((fallthrough)) > +#else > +#define SWITCH_FALLTHROUGH > +#endif > + > #endif > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --mpBQsTDkJwM+mRv6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEkhr/r4Op1/04yqaB5GN7iDZyWKcFAliRl8YACgkQ5GN7iDZy WKdmoRAAkG3uV0Y0FXjNGNC46g73SuZ30ynl+dtMJtquyhPL15MoQh9VTYBJcLpe 5hmRjmMVtXwsBBisSbm+NZM4mnVVFn6Mu6gDw5ln3Svp7H79JBtNYvvO24a2xNGh HaWzNHbMfoCVYjq2aSgW8cnxUU7UDLc5EMFkmnsTsQT0aRkgPD2ot6du8hb42Th5 +iElJtjrDJh1QgZRKNW5UnizcDPyC0oXUVaRJLv0pg5rxDoitRw+BHNWQoM7I+Pi o9tb2YWWGHVmD8IN5KBurbUi63QCicRWy88hxeQkawfOehfWKON4luES70c/hs7T T3PmwowoBlJ3H5kxbJ3JiaM8v1b6DPxOis0ypQ+ANoWZwQduY9iL5WBAF8arCBli jZF5t6YH1C3BiQ4rZBZ2N9uAC3tr3hCKKDzjgwOloT49Wjh9gxcv1rSpoubHj0Oq avKWv9tcCnd8PSgToRJLwwfID61DDgimgD1V3WAiZN/ZyvXFx3iz1VupdTnlGVLM Oa1/Nt2un9n7odpjIKEHbo1eMepeE0T/HRPjRcEMDSTn2XW8BqZNoEfuPoZ2XoSN 2K49wKwz0qjSJxXKIP7M1zit8zisk4ZoNxzYHwlashXHPB02KVkYOs0VCGo4TCgj G08vpCak/zVHpqf7/loJIGYtJpri1pozIv5PxKJVRCKkV4QYk7E= =ATJM -----END PGP SIGNATURE----- --mpBQsTDkJwM+mRv6-- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html