path: root/lib/librte_mbuf
diff options
authorDavid Marchand <>2019-06-29 13:58:53 +0200
committerThomas Monjalon <>2019-06-29 19:04:48 +0200
commit18218713bf4248c4c6b97a12231e7d59b8a86865 (patch)
tree380e87a089b57686fc4c8f99043a1ea4da4d5b8f /lib/librte_mbuf
parentcfe3aeb170b2f6277e6f96173599da51eab0654f (diff)
enforce experimental tag at beginning of declarations
Putting a '__attribute__((deprecated))' in the middle of a function prototype does not result in the expected result with gcc (while clang is fine with this syntax). $ cat deprecated.c void * __attribute__((deprecated)) incorrect() { return 0; } __attribute__((deprecated)) void *correct(void) { return 0; } int main(int argc, char *argv[]) { incorrect(); correct(); return 0; } $ gcc -o deprecated.o -c deprecated.c deprecated.c: In function ‘main’: deprecated.c:3:1: warning: ‘correct’ is deprecated (declared at deprecated.c:2) [-Wdeprecated-declarations] int main(int argc, char *argv[]) { incorrect(); correct(); return 0; } ^ Move the tag on a separate line and make it the first thing of function prototypes. This is not perfect but we will trust reviewers to catch the other not so easy to detect patterns. sed -i \ -e '/^\([^#].*\)\?__rte_experimental */{' \ -e 's//\1/; s/ *$//; i\' \ -e __rte_experimental \ -e '/^$/d}' \ $(git grep -l __rte_experimental -- '*.h') Special mention for rte_mbuf_data_addr_default(): There is either a bug or a (not yet understood) issue with gcc. gcc won't drop this inline when unused and rte_mbuf_data_addr_default() calls rte_mbuf_buf_addr() which itself is experimental. This results in a build warning when not accepting experimental apis from sources just including rte_mbuf.h. For this specific case, we hide the call to rte_mbuf_buf_addr() under the ALLOW_EXPERIMENTAL_API flag. Signed-off-by: Adrien Mazarguil <> Signed-off-by: David Marchand <>
Diffstat (limited to 'lib/librte_mbuf')
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 0d9fef0..9542488 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -866,7 +866,8 @@ rte_mbuf_from_indirect(struct rte_mbuf *mi)
* @return
* The pointer of the mbuf buffer.
-static inline char * __rte_experimental
+static inline char *
rte_mbuf_buf_addr(struct rte_mbuf *mb, struct rte_mempool *mp)
return (char *)mb + sizeof(*mb) + rte_pktmbuf_priv_size(mp);
@@ -883,10 +884,18 @@ rte_mbuf_buf_addr(struct rte_mbuf *mb, struct rte_mempool *mp)
* @return
* The pointer of the beginning of the mbuf data.
-static inline char * __rte_experimental
-rte_mbuf_data_addr_default(struct rte_mbuf *mb)
+static inline char *
+rte_mbuf_data_addr_default(__rte_unused struct rte_mbuf *mb)
+ /* gcc complains about calling this experimental function even
+ * when not using it. Hide it with ALLOW_EXPERIMENTAL_API.
+ */
return rte_mbuf_buf_addr(mb, mb->pool) + RTE_PKTMBUF_HEADROOM;
+ return NULL;
@@ -926,7 +935,8 @@ rte_mbuf_to_baddr(struct rte_mbuf *md)
* @return
* The starting address of the private data area of the given mbuf.
-static inline void * __rte_experimental
+static inline void *
rte_mbuf_to_priv(struct rte_mbuf *m)
return RTE_PTR_ADD(m, sizeof(struct rte_mbuf));