[PATCH v5 1/4] eal: add nonnull and access function attributes

Morten Brørup mb at smartsharesystems.com
Mon Jan 9 13:28:05 CET 2023


> From: David Marchand [mailto:david.marchand at redhat.com]
> Sent: Monday, 9 January 2023 12.22
> attributes
> 
> On Wed, Dec 28, 2022 at 4:10 PM Morten Brørup
> <mb at smartsharesystems.com> wrote:
> >
> > Add "nonnull" function attribute to help the compiler detect a NULL
> > pointer being passed to a function not accepting NULL pointers as an
> > argument at build time.
> >
> > Add "access" function attribute to tell the compiler how a function
> > accesses its pointer arguments.
> >
> > Add these attributes to the rte_memcpy() function, as the first in
> > hopefully many to come.
> >
> 
> Compilation is broken starting first patch, so patches must be
> reordered to have the fixes first.

Will do.

> 
> 
> > v5:
> > * No changes.
> > v4:
> > * No changes.
> > v3:
> > * No changes.
> > v2:
> > * Only define "nonnull" for GCC and CLANG.
> > * Append _param/_params to prepare for possible future attributes
> >   attached directly to the individual parameters, like __rte_unused.
> > * Use RTE_TOOLCHAIN_GCC instead of RTE_CC_GCC, to fix complaints
> about
> >   GCC_VERSION being undefined.
> > * Try to fix Doxygen compliants.
> 
> Patch history should be put as annotations (i.e. after --- but before
> patch content).

Will do.

[...]

> This is tightly bound to gcc syntax.
> With dedicated macros (which I find easier to read too), we can hope
> to adapt to other compilers if some of them add support for this kind
> of code cookies.
> __rte_read_only_params(indexes...)
> __rte_write_only_params(indexes...)
> __rte_no_access_params(indexes...)

I agree. Splitting the generic access macro up into dedicated access macros is probably better.



More information about the dev mailing list