[dpdk-dev] [PATCH 9/9] enforce __rte_experimental at the start of symbol declarations

Thomas Monjalon thomas at monjalon.net
Fri Jun 28 15:38:54 CEST 2019


27/06/2019 14:38, Gaëtan Rivet:
> On Thu, Jun 27, 2019 at 02:23:59PM +0200, Adrien Mazarguil wrote:
> > Hey David,
> > 
> > On Thu, Jun 27, 2019 at 01:33:55PM +0200, David Marchand wrote:
> > > 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; }
> > >  ^
> > > 
> > > Let's enforce the tag is at the very start of the lines, this is not
> > > perfect but we will trust reviewers to catch the other not so easy to
> > > detect patterns.
> > > 
> > > tag=__rte_experimental
> > > git grep -l [^^]$tag |grep \\.h$ |while read file; do
> > > 	[ "$file" != 'lib/librte_eal/common/include/rte_compat.h' ] ||
> > > 		continue
> > > 	sed -i -e 's#^\(.*\)  *'$tag'#'$tag' \1#' $file
> > > 	sed -i -e 's#^\(..*\)'$tag'#'$tag' \1#' $file
> > > done
> > 
> > Just a suggestion, how about putting __rte_experimental on its own line
> > before the actual prototype? So that instead of:
> > 
> >  __rte_experimental struct rte_compressdev * __rte_experimental
> >  rte_compressdev_pmd_get_named_dev(const char *name);
> > 
> > We'd get:
> > 
> >  __rte_experimental
> >  struct rte_compressdev *
> >  rte_compressdev_pmd_get_named_dev(const char *name);
> > 
> > I personally find the latter much more readable.
> 
> +1, with the added benefit of having only one line to remove when
> making the API stable, which is critical.

You're right, but it needs a different check.
Given it is minor and we don't have a patch,
I will merge David's version, except if you can provide a patch quickly.





More information about the dev mailing list