[dpdk-dev] [PATCH 9/9] enforce __rte_experimental at the start of symbol declarations
Adrien Mazarguil
adrien.mazarguil at 6wind.com
Thu Jun 27 14:23:59 CEST 2019
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.
Here's the relevant sed expression:
sed -i \
-e '/^\([^#].*\)__rte_experimental */{' \
-e 's//\1/; s/ *$//; i\' \
-e __rte_experimental \
-e '}' \
$(git grep -l __rte_experimental -- '*.h')
Otherwise this series looks good to me.
--
Adrien Mazarguil
6WIND
More information about the dev
mailing list