[dpdk-dev] [PATCH] pktgen: fix clang compiler errors / warnings

Adam Drescher adam.r.drescher at gmail.com
Tue Jun 18 22:58:00 CEST 2019


Clang complains about the following issues:
(1) unclear meaning of =- in assignment of pktgen.verbose
(2) unused function sct(), which is also defined in cli_cmds.c
(3) typo in include guard for rte_lua_vec.h
(4) duplicate inline due to expansion of __rte_always_inline

Tested the patch on both clang and gcc. Not sure how strong
pktgen's backwards compatability guarantees are, but
__rte_always_inline is good back to DPDK v18.02 at least.

Signed-off-by: Adam Drescher <adam.r.drescher at gmail.com>
---
 app/pktgen-main.c     |  2 +-
 lib/cli/cli_cmap.c    | 23 -----------------------
 lib/lua/rte_lua_vec.h |  2 +-
 lib/vec/rte_vec.h     | 32 ++++++++++++++++----------------
 4 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/app/pktgen-main.c b/app/pktgen-main.c
index 6b9d90e..e87e2f5 100644
--- a/app/pktgen-main.c
+++ b/app/pktgen-main.c
@@ -252,7 +252,7 @@ pktgen_parse_args(int argc, char **argv)
 			pktgen.flags    |= ENABLE_THEME_FLAG;
 			break;
 		case 'v':
-			pktgen.verbose =- 1;
+			pktgen.verbose = 1;
 			break;
 
 		case 'h':	/* print out the help message */
diff --git a/lib/cli/cli_cmap.c b/lib/cli/cli_cmap.c
index 66638b7..1c932d6 100644
--- a/lib/cli/cli_cmap.c
+++ b/lib/cli/cli_cmap.c
@@ -285,26 +285,3 @@ cmap_free(struct cmap *cmap)
 {
 	free(cmap);
 }
-
-/* Helper for building log strings.
- * The macro takes an existing string, a printf-like format string and optional
- * arguments. It formats the string and appends it to the existing string,
- * while avoiding possible buffer overruns.
- */
-#define strncatf(dest, fmt, ...) do {					\
-		char _buff[1024];					\
-		snprintf(_buff, sizeof(_buff), fmt, ## __VA_ARGS__);	\
-		strncat(dest, _buff, sizeof(dest) - strlen(dest) - 1);	\
-} while (0)
-
-static __inline__ uint8_t
-sct(struct cmap *cm, uint8_t s, uint8_t c, uint8_t t) {
-	lc_info_t   *lc = cm->linfo;
-	uint8_t i;
-
-	for (i = 0; i < cm->num_cores; i++, lc++)
-		if (lc->sid == s && lc->cid == c && lc->tid == t)
-			return lc->lid;
-
-	return 0;
-}
diff --git a/lib/lua/rte_lua_vec.h b/lib/lua/rte_lua_vec.h
index b329f1a..8eaf83c 100644
--- a/lib/lua/rte_lua_vec.h
+++ b/lib/lua/rte_lua_vec.h
@@ -4,7 +4,7 @@
 /* Created 2018 by Keith Wiles @ intel.com */
 
 #ifndef _RTE_LUA_VEC_H_
-#define _RTE_LUAVEC_H_
+#define _RTE_LUA_VEC_H_
 
 #include <stdint.h>
 #include <netinet/in.h>
diff --git a/lib/vec/rte_vec.h b/lib/vec/rte_vec.h
index b465525..77dc706 100644
--- a/lib/vec/rte_vec.h
+++ b/lib/vec/rte_vec.h
@@ -99,49 +99,49 @@ rte_vec_clr_dont_free(struct rte_vec *vec)
 	vec->flags &= ~VEC_DONT_FREE_FLAG;
 }
 
-static inline __rte_always_inline uint16_t
+static __rte_always_inline uint16_t
 rte_vec_len(struct rte_vec *v)
 {
 	return v->len;
 }
 
-static inline __rte_always_inline int
+static __rte_always_inline int
 rte_vec_byte_len(struct rte_vec *v)
 {
 	return v->len * sizeof(void *);
 }
 
-static inline __rte_always_inline void
+static __rte_always_inline void
 rte_vec_set_len(struct rte_vec *v, uint16_t n)
 {
 	v->len = n;
 }
 
-static inline __rte_always_inline void
+static __rte_always_inline void
 rte_vec_set_max_len(struct rte_vec *v, uint16_t n)
 {
 	v->tlen = n;
 }
 
-static inline __rte_always_inline void
+static __rte_always_inline void
 rte_vec_dec_len(struct rte_vec *v)
 {
 	v->len--;
 }
 
-static inline __rte_always_inline void
+static __rte_always_inline void
 rte_vec_inc_len(struct rte_vec *v)
 {
 	v->len++;
 }
 
-static inline __rte_always_inline uint16_t
+static __rte_always_inline uint16_t
 rte_vec_max_len(struct rte_vec *v)
 {
 	return v->tlen;
 }
 
-static inline __rte_always_inline struct rte_mbuf **
+static __rte_always_inline struct rte_mbuf **
 rte_vec_list(struct rte_vec *v)
 {
 	return (struct rte_mbuf * *)&v->list[0];
@@ -151,7 +151,7 @@ rte_vec_list(struct rte_vec *v)
 #pragma GCC diagnostic ignored "-Warray-bounds"
 
 /* return -1 on full and index value if OK */
-static inline __rte_always_inline int
+static __rte_always_inline int
 rte_vec_add1(struct rte_vec *vec, void *val)
 {
 	if (vec->len >= vec->tlen)
@@ -161,7 +161,7 @@ rte_vec_add1(struct rte_vec *vec, void *val)
 	return vec->len - 1;
 }
 
-static inline __rte_always_inline int
+static __rte_always_inline int
 rte_vec_add_at_index(struct rte_vec *vec, void *val, uint16_t n)
 {
 	if (vec->len >= vec->tlen)
@@ -171,7 +171,7 @@ rte_vec_add_at_index(struct rte_vec *vec, void *val, uint16_t n)
 	return 0;
 }
 
-static inline __rte_always_inline void *
+static __rte_always_inline void *
 rte_vec_at_index(struct rte_vec *vec, uint16_t n)
 {
 	if (n >= vec->len)
@@ -179,32 +179,32 @@ rte_vec_at_index(struct rte_vec *vec, uint16_t n)
 	return vec->list[n];
 }
 
-static inline __rte_always_inline void
+static __rte_always_inline void
 rte_vec_set_at_index(struct rte_vec *vec, uint16_t idx, void *val)
 {
 	if (idx < vec->tlen)
 		vec->list[idx] = val;
 }
 
-static inline __rte_always_inline struct rte_mbuf **
+static __rte_always_inline struct rte_mbuf **
 rte_vec_addr(struct rte_vec *vec, uint16_t n)
 {
 	return (struct rte_mbuf * *)&vec->list[n];
 }
 
-static inline __rte_always_inline struct rte_mbuf **
+static __rte_always_inline struct rte_mbuf **
 rte_vec_end(struct rte_vec *vec)
 {
 	return (struct rte_mbuf * *)&vec->list[vec->len];
 }
 
-static inline __rte_always_inline int
+static __rte_always_inline int
 rte_vec_len_remaining(struct rte_vec *vec)
 {
 	return vec->tlen - vec->len;
 }
 
-static inline __rte_always_inline int
+static __rte_always_inline int
 rte_vec_is_full(struct rte_vec *v)
 {
 	return (v->len == v->tlen);
-- 
2.20.1



More information about the dev mailing list