* [dpdk-dev] [PATCH] pktgen: fix clang compiler errors / warnings
@ 2019-06-18 20:58 Adam Drescher
2019-06-18 21:18 ` Wiles, Keith
0 siblings, 1 reply; 2+ messages in thread
From: Adam Drescher @ 2019-06-18 20:58 UTC (permalink / raw)
To: keith.wiles; +Cc: dev, Adam Drescher
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@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] pktgen: fix clang compiler errors / warnings
2019-06-18 20:58 [dpdk-dev] [PATCH] pktgen: fix clang compiler errors / warnings Adam Drescher
@ 2019-06-18 21:18 ` Wiles, Keith
0 siblings, 0 replies; 2+ messages in thread
From: Wiles, Keith @ 2019-06-18 21:18 UTC (permalink / raw)
To: Adam Drescher; +Cc: dev
> On Jun 18, 2019, at 3:58 PM, Adam Drescher <adam.r.drescher@gmail.com> wrote:
>
> 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.
Thanks, I will review the patch and commit or reply with comments.
>
> Signed-off-by: Adam Drescher <adam.r.drescher@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
>
Regards,
Keith
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-18 21:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 20:58 [dpdk-dev] [PATCH] pktgen: fix clang compiler errors / warnings Adam Drescher
2019-06-18 21:18 ` Wiles, Keith
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).