DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 06/10] lib: fix gcc 7 warnings for switch fall-through
Date: Thu,  4 May 2017 16:38:18 +0100	[thread overview]
Message-ID: <20170504153822.19461-7-bruce.richardson@intel.com> (raw)
In-Reply-To: <20170504153822.19461-1-bruce.richardson@intel.com>

With GCC 7 we need to explicitly document when we are falling through from
one switch case to another.

Fixes: af75078fece3 ("first public release")
Fixes: 8bae1da2afe0 ("hash: fallback to software CRC32 implementation")
Fixes: 9ec201f5d6e7 ("mbuf: provide bulk allocation")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_cmdline/cmdline_parse_num.c | 4 ++--
 lib/librte_hash/rte_hash_crc.h         | 6 ++++++
 lib/librte_mbuf/rte_mbuf.h             | 4 ++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/librte_cmdline/cmdline_parse_num.c b/lib/librte_cmdline/cmdline_parse_num.c
index b0f9a35..e507ec4 100644
--- a/lib/librte_cmdline/cmdline_parse_num.c
+++ b/lib/librte_cmdline/cmdline_parse_num.c
@@ -250,7 +250,7 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
 
 		case HEX:
 			st = HEX_OK;
-			/* no break */
+			/* fall-through no break */
 		case HEX_OK:
 			if (c >= '0' && c <= '9') {
 				if (add_to_res(c - '0', &res1, 16) < 0)
@@ -282,7 +282,7 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
 
 		case BIN:
 			st = BIN_OK;
-			/* no break */
+			/* fall-through */
 		case BIN_OK:
 			if (c >= '0' && c <= '1') {
 				if (add_to_res(c - '0', &res1, 2) < 0)
diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index 63e74aa..0f485b8 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -476,9 +476,15 @@ rte_hash_crc_set_alg(uint8_t alg)
 	case CRC32_SSE42_x64:
 		if (! rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T))
 			alg = CRC32_SSE42;
+#if __GNUC__ >= 7
+		__attribute__ ((fallthrough));
+#endif
 	case CRC32_SSE42:
 		if (! rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_2))
 			alg = CRC32_SW;
+#if __GNUC__ >= 7
+		__attribute__ ((fallthrough));
+#endif
 #endif
 	case CRC32_SW:
 		crc32_alg = alg;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 466ec00..9097f18 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1156,21 +1156,25 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool,
 			rte_mbuf_refcnt_set(mbufs[idx], 1);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
+			/* fall-through */
 	case 3:
 			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
 			rte_mbuf_refcnt_set(mbufs[idx], 1);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
+			/* fall-through */
 	case 2:
 			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
 			rte_mbuf_refcnt_set(mbufs[idx], 1);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
+			/* fall-through */
 	case 1:
 			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
 			rte_mbuf_refcnt_set(mbufs[idx], 1);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
+			/* fall-through */
 		}
 	}
 	return 0;
-- 
2.9.3

  parent reply	other threads:[~2017-05-04 15:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 15:38 [dpdk-dev] [PATCH 00/10] Enable DPDK core build with gcc 7 Bruce Richardson
2017-05-04 15:38 ` [dpdk-dev] [PATCH 01/10] mk: adjust gcc flags for new gcc 7 warnings Bruce Richardson
2017-05-04 16:38   ` Stephen Hemminger
2017-05-05  9:42     ` Bruce Richardson
2017-05-05 10:02       ` Thomas Monjalon
2017-05-05 10:20         ` Bruce Richardson
2017-05-05 12:18         ` Van Haaren, Harry
2017-05-04 15:38 ` [dpdk-dev] [PATCH 02/10] drivers/net: disable new gcc 7 warnings for base code Bruce Richardson
2017-05-04 15:38 ` [dpdk-dev] [PATCH 03/10] net/bnx2x: fix warnings about switch fall-through Bruce Richardson
2017-05-04 15:38 ` [dpdk-dev] [PATCH 04/10] net/ixgbe: fix gcc 7 warning for switch fallthrough Bruce Richardson
2017-05-05  0:46   ` Lu, Wenzhuo
2017-05-04 15:38 ` [dpdk-dev] [PATCH 05/10] net/vmxnet3: fix compile error with gcc 7 Bruce Richardson
2017-05-04 16:39   ` Stephen Hemminger
2017-05-04 15:38 ` Bruce Richardson [this message]
2017-05-04 15:38 ` [dpdk-dev] [PATCH 07/10] net: fix missing break inside conditional compile block Bruce Richardson
2017-05-05  9:28   ` Singh, Jasvinder
2017-05-04 15:38 ` [dpdk-dev] [PATCH 08/10] app/testpmd: document explicit switch fall-through Bruce Richardson
2017-05-04 15:38 ` [dpdk-dev] [PATCH 09/10] test/test: fix missing break in switch Bruce Richardson
2017-05-04 15:38 ` [dpdk-dev] [PATCH 10/10] test/test: fix gcc 7 compiler error Bruce Richardson
2017-05-05 16:38 ` [dpdk-dev] [PATCH 00/10] Enable DPDK core build with gcc 7 Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170504153822.19461-7-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).