public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-core 0/6] Fixes for new warnings in gcc 7
@ 2017-01-31 21:08 Jason Gunthorpe
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hopefull gcc 7 will be available in travis soon, here is enough fixing to
quiet the new warnings it finds.

Jason Gunthorpe (6):
  Add Debian experimental gcc-7 to cbuild
  hns: Fix strange placement of fprintf:
  mlx5: Fix missing break statement in sq_overhead
  Annotate correct switch fall throughs with SWITCH_FALLTHROUGH
  acm: Fix snprintf truncation
  Check the return value from snprintf when working with paths

 buildlib/cbuild                  | 12 ++++++++++++
 ibacm/prov/acmp/src/acmp.c       |  2 +-
 ibacm/src/acm.c                  |  7 +++++--
 libibverbs/examples/asyncwatch.c |  2 ++
 libibverbs/init.c                | 24 +++++++++++++++---------
 librdmacm/examples/riostream.c   |  2 ++
 librdmacm/examples/rstream.c     |  2 ++
 librdmacm/examples/udpong.c      |  2 ++
 providers/hns/hns_roce_u_hw_v1.c |  2 +-
 providers/mlx4/cq.c              |  3 +++
 providers/mlx5/cq.c              |  3 +++
 providers/mlx5/verbs.c           |  2 ++
 providers/ocrdma/ocrdma_verbs.c  |  3 +++
 providers/qedr/qelr_verbs.c      |  3 ++-
 util/CMakeLists.txt              |  1 +
 util/compiler.h                  |  7 +++++++
 util/util.h                      | 13 +++++++++++++
 17 files changed, 76 insertions(+), 14 deletions(-)
 create mode 100644 util/util.h

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 1/6] Add Debian experimental gcc-7 to cbuild
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-01-31 21:08   ` Jason Gunthorpe
  2017-01-31 21:08   ` [PATCH rdma-core 2/6] hns: Fix strange placement of fprintf: Jason Gunthorpe
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 buildlib/cbuild | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/buildlib/cbuild b/buildlib/cbuild
index 98f69dbfba3d9d..31535cb4a8473a 100755
--- a/buildlib/cbuild
+++ b/buildlib/cbuild
@@ -181,6 +181,17 @@ class jessie(APTEnvironment):
     name = "debian-8";
     aliases = {"jessie"};
 
+class debian_experimental(APTEnvironment):
+    docker_parent = "debian:experimental"
+    pkgs = (trusty.pkgs ^ {"gcc"}) | {"gcc-7"};
+    name = "debian-experimental";
+
+    def get_docker_file(self):
+        res = DockerFile(self.docker_parent);
+        res.lines.append("RUN apt-get update && apt-get -t experimental install -y --no-install-recommends %s && apt-get clean"%(
+            " ".join(sorted(self.pkgs))));
+        return res;
+
 class travis(APTEnvironment):
     """This parses the .travis.yml "apt" add on and converts it to a dockerfile,
     basically creating a container that is similar to what travis would
@@ -301,6 +312,7 @@ environments = [centos6(),
                 harlequin(),
                 malachite(),
                 tumbleweed(),
+                debian_experimental(),
 ];
 
 class ToEnvAction(argparse.Action):
-- 
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 2/6] hns: Fix strange placement of fprintf:
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2017-01-31 21:08   ` [PATCH rdma-core 1/6] Add Debian experimental gcc-7 to cbuild Jason Gunthorpe
@ 2017-01-31 21:08   ` Jason Gunthorpe
  2017-01-31 21:08   ` [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead Jason Gunthorpe
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Lijun Ou, Wei Hu(Xavier)

gcc 7.0.1 observes:

providers/hns/hns_roce_u_hw_v1.c:121:3: warning: statement will never be executed [-Wswitch-unreachable]
   fprintf(stderr, PFX "error cqe!\n");

Due to the strange placement in the switch statement.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 providers/hns/hns_roce_u_hw_v1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/providers/hns/hns_roce_u_hw_v1.c b/providers/hns/hns_roce_u_hw_v1.c
index ff39593e8740f8..263502d4a85610 100644
--- a/providers/hns/hns_roce_u_hw_v1.c
+++ b/providers/hns/hns_roce_u_hw_v1.c
@@ -114,11 +114,11 @@ static void hns_roce_update_cq_cons_index(struct hns_roce_context *ctx,
 static void hns_roce_handle_error_cqe(struct hns_roce_cqe *cqe,
 				      struct ibv_wc *wc)
 {
+	fprintf(stderr, PFX "error cqe!\n");
 	switch (roce_get_field(cqe->cqe_byte_4,
 			       CQE_BYTE_4_STATUS_OF_THE_OPERATION_M,
 			       CQE_BYTE_4_STATUS_OF_THE_OPERATION_S) &
 		HNS_ROCE_CQE_STATUS_MASK) {
-		fprintf(stderr, PFX "error cqe!\n");
 	case HNS_ROCE_CQE_SYNDROME_LOCAL_LENGTH_ERR:
 		wc->status = IBV_WC_LOC_LEN_ERR;
 		break;
-- 
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2017-01-31 21:08   ` [PATCH rdma-core 1/6] Add Debian experimental gcc-7 to cbuild Jason Gunthorpe
  2017-01-31 21:08   ` [PATCH rdma-core 2/6] hns: Fix strange placement of fprintf: Jason Gunthorpe
@ 2017-01-31 21:08   ` Jason Gunthorpe
       [not found]     ` <1485896886-23517-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2017-01-31 21:08   ` [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH Jason Gunthorpe
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Yishai Hadas

gcc 7.0.1 observes:

providers/mlx5/verbs.c:745:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
   size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 providers/mlx5/verbs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index 04a5462ce41d03..60854402fec2d4 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -743,6 +743,8 @@ static int sq_overhead(enum ibv_qp_type	qp_type)
 
 	case IBV_QPT_XRC_SEND:
 		size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
+		break;
+
 	case IBV_QPT_XRC_RECV:
 		size = max(size, sizeof(struct mlx5_wqe_ctrl_seg) +
 			   sizeof(struct mlx5_wqe_xrc_seg) +
-- 
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-01-31 21:08   ` [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead Jason Gunthorpe
@ 2017-01-31 21:08   ` Jason Gunthorpe
       [not found]     ` <1485896886-23517-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2017-01-31 21:08   ` [PATCH rdma-core 5/6] acm: Fix snprintf truncation Jason Gunthorpe
  2017-01-31 21:08   ` [PATCH rdma-core 6/6] Check the return value from snprintf when working with paths Jason Gunthorpe
  5 siblings, 1 reply; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Doug Ledford, Yishai Hadas, Sean Hefty, Devesh Sharma, Ram Amrani,
	Ariel Elior

gcc 7.0.1 now warns on these, which actually found a bug. So lets
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 <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 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 <getopt.h>
 #include <string.h>
 
+#include <util/compiler.h>
 #include <infiniband/verbs.h>
 
 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 <rdma/rdma_cma.h>
 #include <rdma/rsocket.h>
+#include <util/compiler.h>
 #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 <rdma/rdma_cma.h>
 #include <rdma/rsocket.h>
+#include <util/compiler.h>
 #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 <rdma/rdma_cma.h>
 #include <rdma/rsocket.h>
+#include <util/compiler.h>
 #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 <netinet/in.h>
 #include <string.h>
 
+#include <util/compiler.h>
 #include <infiniband/opcode.h>
 
 #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 <errno.h>
 #include <unistd.h>
 
+#include <util/compiler.h>
 #include <infiniband/opcode.h>
 
 #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 <ccan/list.h>
+#include <util/compiler.h>
 
 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 <util/compiler.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 5/6] acm: Fix snprintf truncation
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
                     ` (3 preceding siblings ...)
  2017-01-31 21:08   ` [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH Jason Gunthorpe
@ 2017-01-31 21:08   ` Jason Gunthorpe
  2017-01-31 21:08   ` [PATCH rdma-core 6/6] Check the return value from snprintf when working with paths Jason Gunthorpe
  5 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

gcc 7.0.1 remarks:

ibacm/prov/acmp/src/acmp.c: In function 'acmp_open_endpoint.part.11':
ibacm/prov/acmp/src/acmp.c:2499:29: warning: '%d' directive writing between 1 and 3 bytes into a region of size between 0 and 63 [-Wformat-overflow=]
  sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
                             ^~
ibacm/prov/acmp/src/acmp.c:2499:25: note: directive argument in the range [0, 255]
  sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
                         ^~~~~~~~~~~~
ibacm/prov/acmp/src/acmp.c:2499:25: note: directive argument in the range [0, 65535]
ibacm/prov/acmp/src/acmp.c:2499:2: note: 'sprintf' output between 7 and 75 bytes into a destination of size 64
  sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   port->port_num, endpoint->pkey);

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 ibacm/prov/acmp/src/acmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 56567ef8bf379c..fb6684f2eac1f5 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -174,7 +174,7 @@ struct acmp_ep {
 	struct ibv_mr         *mr;
 	uint8_t               *recv_bufs;
 	struct list_node      entry;
-	char		      id_string[ACM_MAX_ADDRESS];
+	char		      id_string[IBV_SYSFS_NAME_MAX + 11];
 	void                  *dest_map[ACM_ADDRESS_RESERVED - 1];
 	struct acmp_dest      mc_dest[MAX_EP_MC];
 	int                   mc_cnt;
-- 
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rdma-core 6/6] Check the return value from snprintf when working with paths
       [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
                     ` (4 preceding siblings ...)
  2017-01-31 21:08   ` [PATCH rdma-core 5/6] acm: Fix snprintf truncation Jason Gunthorpe
@ 2017-01-31 21:08   ` Jason Gunthorpe
  5 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:08 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Doug Ledford, Yishai Hadas

gcc 7.0.1 remarks:

libibverbs/init.c:109:5: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
     "%s/%s", class_path, dent->d_name);
     ^~~~~~~
libibverbs/init.c:108:3: note: 'snprintf' output 2 or more bytes (assuming 257) into a destination of size 256
   snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "%s/%s", class_path, dent->d_name);

Which is possible filename truncation when processing dents. Detect
truncation and ignore those file names.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 ibacm/src/acm.c     |  7 +++++--
 libibverbs/init.c   | 24 +++++++++++++++---------
 util/CMakeLists.txt |  1 +
 util/util.h         | 13 +++++++++++++
 4 files changed, 34 insertions(+), 11 deletions(-)
 create mode 100644 util/util.h

diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 5f4068f619b4a1..fd06a2e81fbe76 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -59,6 +59,7 @@
 #include <poll.h>
 #include <inttypes.h>
 #include <ccan/list.h>
+#include <util/util.h>
 #include "acm_mad.h"
 #include "acm_util.h"
 
@@ -2549,8 +2550,10 @@ static int acm_open_providers(void)
 		if (!strstr(dent->d_name, ".so"))
 			continue;
 
-		snprintf(file_name, sizeof(file_name), "%s/%s", prov_lib_path,
-			 dent->d_name);
+		if (!check_snprintf(file_name, sizeof(file_name), "%s/%s",
+				    prov_lib_path, dent->d_name))
+			continue;
+
 		if (lstat(file_name, &buf)) {
 			acm_log(0, "Error - could not stat: %s\n", file_name);
 			continue;
diff --git a/libibverbs/init.c b/libibverbs/init.c
index cce5c6302e0126..0594a1ff1094ad 100644
--- a/libibverbs/init.c
+++ b/libibverbs/init.c
@@ -46,6 +46,7 @@
 #include <dirent.h>
 #include <errno.h>
 
+#include <util/util.h>
 #include "ibverbs.h"
 
 int abi_ver;
@@ -85,8 +86,9 @@ static int find_sysfs_devs(void)
 	char value[8];
 	int ret = 0;
 
-	snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
-		 ibv_get_sysfs_path());
+	if (!check_snprintf(class_path, sizeof(class_path),
+			    "%s/class/infiniband_verbs", ibv_get_sysfs_path()))
+		return ENOMEM;
 
 	class_dir = opendir(class_path);
 	if (!class_dir)
@@ -105,8 +107,9 @@ static int find_sysfs_devs(void)
 			goto out;
 		}
 
-		snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
-			 "%s/%s", class_path, dent->d_name);
+		if (!check_snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
+				    "%s/%s", class_path, dent->d_name))
+			continue;
 
 		if (stat(sysfs_dev->sysfs_path, &buf)) {
 			fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n",
@@ -117,8 +120,9 @@ static int find_sysfs_devs(void)
 		if (!S_ISDIR(buf.st_mode))
 			continue;
 
-		snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
-			"%s", dent->d_name);
+		if (!check_snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
+				    "%s", dent->d_name))
+			continue;
 
 		if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
 					sysfs_dev->ibdev_name,
@@ -128,9 +132,11 @@ static int find_sysfs_devs(void)
 			continue;
 		}
 
-		snprintf(sysfs_dev->ibdev_path, sizeof sysfs_dev->ibdev_path,
-			 "%s/class/infiniband/%s", ibv_get_sysfs_path(),
-			 sysfs_dev->ibdev_name);
+		if (!check_snprintf(
+			sysfs_dev->ibdev_path, sizeof(sysfs_dev->ibdev_path),
+			"%s/class/infiniband/%s", ibv_get_sysfs_path(),
+			sysfs_dev->ibdev_name))
+			continue;
 
 		sysfs_dev->next        = sysfs_dev_list;
 		sysfs_dev->have_driver = 0;
diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt
index 1cda8905d8f44d..c0ad5861d189ee 100644
--- a/util/CMakeLists.txt
+++ b/util/CMakeLists.txt
@@ -1,3 +1,4 @@
 publish_internal_headers(util
   compiler.h
+  util.h
   )
diff --git a/util/util.h b/util/util.h
new file mode 100644
index 00000000000000..ed4ffe88573e23
--- /dev/null
+++ b/util/util.h
@@ -0,0 +1,13 @@
+/* GPLv2 or OpenIB.org BSD (MIT) See COPYING file */
+#ifndef UTIL_UTIL_H
+#define UTIL_UTIL_H
+
+/* Return true if the snprintf succeeded, false if there was truncation or
+ * error */
+#define check_snprintf(buf, len, fmt, ...)                                     \
+	({                                                                     \
+		int rc = snprintf(buf, len, fmt, ##__VA_ARGS__);               \
+		(rc < len && rc >= 0);                                         \
+	})
+
+#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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead
       [not found]     ` <1485896886-23517-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-01-31 21:12       ` Jason Gunthorpe
       [not found]         ` <20170131211239.GA22475-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:12 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Yishai Hadas

On Tue, Jan 31, 2017 at 02:08:03PM -0700, Jason Gunthorpe wrote:
> gcc 7.0.1 observes:
> 
> providers/mlx5/verbs.c:745:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>  providers/mlx5/verbs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
> index 04a5462ce41d03..60854402fec2d4 100644
> +++ b/providers/mlx5/verbs.c
> @@ -743,6 +743,8 @@ static int sq_overhead(enum ibv_qp_type	qp_type)
>  
>  	case IBV_QPT_XRC_SEND:
>  		size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
> +		break;
> +
>  	case IBV_QPT_XRC_RECV:
>  		size = max(size, sizeof(struct mlx5_wqe_ctrl_seg) +
>  			   sizeof(struct mlx5_wqe_xrc_seg) +

Hum, looking again this confusing construction was probably as
intended before.. Yishai can you let me know?

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead
       [not found]         ` <20170131211239.GA22475-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-01-31 21:37           ` Yishai Hadas
       [not found]             ` <0cf30dc4-9390-6d99-2cab-bf1a73ea32e0-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Yishai Hadas @ 2017-01-31 21:37 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Yishai Hadas

On 1/31/2017 11:12 PM, Jason Gunthorpe wrote:
> On Tue, Jan 31, 2017 at 02:08:03PM -0700, Jason Gunthorpe wrote:
>> gcc 7.0.1 observes:
>>
>> providers/mlx5/verbs.c:745:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>    size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
>>
>> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>>  providers/mlx5/verbs.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
>> index 04a5462ce41d03..60854402fec2d4 100644
>> +++ b/providers/mlx5/verbs.c
>> @@ -743,6 +743,8 @@ static int sq_overhead(enum ibv_qp_type	qp_type)
>>
>>  	case IBV_QPT_XRC_SEND:
>>  		size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
>> +		break;
>> +
>>  	case IBV_QPT_XRC_RECV:
>>  		size = max(size, sizeof(struct mlx5_wqe_ctrl_seg) +
>>  			   sizeof(struct mlx5_wqe_xrc_seg) +
>
> Hum, looking again this confusing construction was probably as
> intended before.. Yishai can you let me know?

The original code is correct, it intended to fallback to 
IBV_QPT_XRC_RECV to take into account the size of struct 
mlx5_wqe_xrc_seg in both cases.


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead
       [not found]             ` <0cf30dc4-9390-6d99-2cab-bf1a73ea32e0-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2017-01-31 21:56               ` Jason Gunthorpe
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-01-31 21:56 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Yishai Hadas

On Tue, Jan 31, 2017 at 11:37:49PM +0200, Yishai Hadas wrote:

> >Hum, looking again this confusing construction was probably as
> >intended before.. Yishai can you let me know?
> 
> The original code is correct, it intended to fallback to IBV_QPT_XRC_RECV to
> take into account the size of struct mlx5_wqe_xrc_seg in both cases.

okay thanks I updated the PR

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH
       [not found]     ` <1485896886-23517-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-02-01  8:09       ` Leon Romanovsky
  0 siblings, 0 replies; 11+ messages in thread
From: Leon Romanovsky @ 2017-02-01  8:09 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Yishai Hadas,
	Sean Hefty, Devesh Sharma, Ram Amrani, Ariel Elior

[-- Attachment #1: Type: text/plain, Size: 7690 bytes --]

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 <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---
>  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 <getopt.h>
>  #include <string.h>
>
> +#include <util/compiler.h>
>  #include <infiniband/verbs.h>
>
>  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 <rdma/rdma_cma.h>
>  #include <rdma/rsocket.h>
> +#include <util/compiler.h>
>  #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 <rdma/rdma_cma.h>
>  #include <rdma/rsocket.h>
> +#include <util/compiler.h>
>  #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 <rdma/rdma_cma.h>
>  #include <rdma/rsocket.h>
> +#include <util/compiler.h>
>  #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 <netinet/in.h>
>  #include <string.h>
>
> +#include <util/compiler.h>
>  #include <infiniband/opcode.h>
>
>  #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 <errno.h>
>  #include <unistd.h>
>
> +#include <util/compiler.h>
>  #include <infiniband/opcode.h>
>
>  #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 <ccan/list.h>
> +#include <util/compiler.h>
>
>  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 <util/compiler.h>
>
>  #include <stdio.h>
>  #include <stdlib.h>
> @@ -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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-02-01  8:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-31 21:08 [PATCH rdma-core 0/6] Fixes for new warnings in gcc 7 Jason Gunthorpe
     [not found] ` <1485896886-23517-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-31 21:08   ` [PATCH rdma-core 1/6] Add Debian experimental gcc-7 to cbuild Jason Gunthorpe
2017-01-31 21:08   ` [PATCH rdma-core 2/6] hns: Fix strange placement of fprintf: Jason Gunthorpe
2017-01-31 21:08   ` [PATCH rdma-core 3/6] mlx5: Fix missing break statement in sq_overhead Jason Gunthorpe
     [not found]     ` <1485896886-23517-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-31 21:12       ` Jason Gunthorpe
     [not found]         ` <20170131211239.GA22475-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-31 21:37           ` Yishai Hadas
     [not found]             ` <0cf30dc4-9390-6d99-2cab-bf1a73ea32e0-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-01-31 21:56               ` Jason Gunthorpe
2017-01-31 21:08   ` [PATCH rdma-core 4/6] Annotate correct switch fall throughs with SWITCH_FALLTHROUGH Jason Gunthorpe
     [not found]     ` <1485896886-23517-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-01  8:09       ` Leon Romanovsky
2017-01-31 21:08   ` [PATCH rdma-core 5/6] acm: Fix snprintf truncation Jason Gunthorpe
2017-01-31 21:08   ` [PATCH rdma-core 6/6] Check the return value from snprintf when working with paths Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox